Re:problem with v86 mode and INT n instruction
Posted: Wed Oct 13, 2004 6:46 am
first, look out for tim robinsons vm86 tutorial. It is outta there on the web, just have your favourite searchbot crawl the web for it.
second: in esp0,ss0 give the ring0 stack of your vm86 task. It can also be an address at say 0xd0000000, provided this address space is mapped in the page directory of your vm86 task.
third: esp3 and ss3 need to be patched. Further they need to reside in an area 0x0<x<0x1ffef. Why patched: in vm86 mode, the processor requires real mode addressing. so, a part of the address is located in the ss, the other one is located in the esp3 (sp3 it will become) To achieve this patching, there are some macros available, which are described in tims tutorial.
eip needs to be patched to become a real mode address too: first it needs to reside inside the area 0x0<x<0x1ffef, second it needs to be translated to real mode cs:ip pair.
fourth: it only matters which physical pages you map from 0x0 to 0x1ffef of your vm86 task page directory if you inted to use bios calls. Then you need to map in the according physical pages - 1:1.
fifth: Don't wonder about the vm86 task trapping seamlessly into your kernel, if it is properly mapped into the page directory: the processor knows it is in vm86 mode and saves off the segment registers too - they are popped off the esp0 stack as soon as the vm86 task is to get cpu again. The thing is designed to work.
I've achieved it with software taskswitching, and that's been not exactly easy, but difficult it is neither.
Feel free to download the latest source of BlueIllusion and check out the files process.c (engl. translation) interrupt.c (engl. translation) and speichertreiber_vmm.c(engl. translation). Out of being just used to it, I keep mosta identifiers and comments in german - It is to keep language elements and identifiers outta way of each other.
second: in esp0,ss0 give the ring0 stack of your vm86 task. It can also be an address at say 0xd0000000, provided this address space is mapped in the page directory of your vm86 task.
third: esp3 and ss3 need to be patched. Further they need to reside in an area 0x0<x<0x1ffef. Why patched: in vm86 mode, the processor requires real mode addressing. so, a part of the address is located in the ss, the other one is located in the esp3 (sp3 it will become) To achieve this patching, there are some macros available, which are described in tims tutorial.
eip needs to be patched to become a real mode address too: first it needs to reside inside the area 0x0<x<0x1ffef, second it needs to be translated to real mode cs:ip pair.
fourth: it only matters which physical pages you map from 0x0 to 0x1ffef of your vm86 task page directory if you inted to use bios calls. Then you need to map in the according physical pages - 1:1.
fifth: Don't wonder about the vm86 task trapping seamlessly into your kernel, if it is properly mapped into the page directory: the processor knows it is in vm86 mode and saves off the segment registers too - they are popped off the esp0 stack as soon as the vm86 task is to get cpu again. The thing is designed to work.
I've achieved it with software taskswitching, and that's been not exactly easy, but difficult it is neither.
Feel free to download the latest source of BlueIllusion and check out the files process.c (engl. translation) interrupt.c (engl. translation) and speichertreiber_vmm.c(engl. translation). Out of being just used to it, I keep mosta identifiers and comments in german - It is to keep language elements and identifiers outta way of each other.