Issues while implementing VM86 support
Posted: Mon Feb 28, 2005 7:06 am
Hi all ... I've been recently checking out OSLib (just to compare with Flux OSKit) and then i saw it had "vm86 support for BIOS VBE mode changes" ... no need to say that was highly interresting me since that's something i try to have for about 2 years now, without having time for doing "research" on the subject
<ranting>
i had a working implementation of VM86 in clicker 0.0.0, but that code was ugly, crappy and whatever other thing you could imagine. So i wasn't feeling like re-writing something from scratch
</ranting>.
About the OSLib
Despite a few compilations issues, the OSLib is simple to set up and compile for those who have a Linux environment (and almost trivial if you still have a GCC 2.95.3 somewhere). I didn't gave examples a try in a bochs, though and went directly to porting vm86 code.
The only thing i'd say "disturbing" about the OSLib is their kl/ll/xl thing: you cannot figure at a first sight where a given component will be. "vm86" was in "Low Level" library. well. "find" did found it rather quickly.
With the help of CSCOPE to retrieve definitions of symbols met, it was quite straightforward to replace OSLib definitions into Clicker definitions (mainly thanks to the fact all the intel-defined structures were ALL_CAPS names). I even was surprised that their "context switch" thing co-exists seamlessly with clicker's scheduler
So the "rewrite" took only a couple of hour and i had then the VM86 module for Clicker ...
What was less funny to discover that OSLib has no apparent support for paging (at least not in the vm86 code) so i had "debug sessions darker than the night" including crawling through bochs sources to find out why there were still tripple-faulting GPF even before any vm86 instruction was executed...
(For the curious ones, that was eventually due to the fact i left the "TSS.cr3 = 0" instruction in the code, which lead to ?ber-chaos, invalid IDT table etc.)
Finally, by sunday 22:00 pm, i see bochs window shrunking and start the Dance of Victory not for too long ... It appears that the screen is filled with garbage and that the CPU has transferred execution to the "Krash Task" of Clicker (meaning a double fault has occured somewhere), leaving me blindfolded for later debugging (oh, the niceties of graphic modes )
You might find interrest in the fact that the first thing int 0x10 does with BOCHS bios is calling int 0x6d which also was a nuisance since i had no handler for 0x6d in my IDT (no, even with IOPL=3, software interrupts are not automagically deferred to real-mode IVT and i instead get a wrongly-handled GPF )
So i've printed the OSLib-provided code and wait for a few hours to read it tonight, hoping to figure out what i still have to handle.
<ranting>
i had a working implementation of VM86 in clicker 0.0.0, but that code was ugly, crappy and whatever other thing you could imagine. So i wasn't feeling like re-writing something from scratch
</ranting>.
About the OSLib
Despite a few compilations issues, the OSLib is simple to set up and compile for those who have a Linux environment (and almost trivial if you still have a GCC 2.95.3 somewhere). I didn't gave examples a try in a bochs, though and went directly to porting vm86 code.
The only thing i'd say "disturbing" about the OSLib is their kl/ll/xl thing: you cannot figure at a first sight where a given component will be. "vm86" was in "Low Level" library. well. "find" did found it rather quickly.
With the help of CSCOPE to retrieve definitions of symbols met, it was quite straightforward to replace OSLib definitions into Clicker definitions (mainly thanks to the fact all the intel-defined structures were ALL_CAPS names). I even was surprised that their "context switch" thing co-exists seamlessly with clicker's scheduler
So the "rewrite" took only a couple of hour and i had then the VM86 module for Clicker ...
What was less funny to discover that OSLib has no apparent support for paging (at least not in the vm86 code) so i had "debug sessions darker than the night" including crawling through bochs sources to find out why there were still tripple-faulting GPF even before any vm86 instruction was executed...
(For the curious ones, that was eventually due to the fact i left the "TSS.cr3 = 0" instruction in the code, which lead to ?ber-chaos, invalid IDT table etc.)
Finally, by sunday 22:00 pm, i see bochs window shrunking and start the Dance of Victory not for too long ... It appears that the screen is filled with garbage and that the CPU has transferred execution to the "Krash Task" of Clicker (meaning a double fault has occured somewhere), leaving me blindfolded for later debugging (oh, the niceties of graphic modes )
You might find interrest in the fact that the first thing int 0x10 does with BOCHS bios is calling int 0x6d which also was a nuisance since i had no handler for 0x6d in my IDT (no, even with IOPL=3, software interrupts are not automagically deferred to real-mode IVT and i instead get a wrongly-handled GPF )
So i've printed the OSLib-provided code and wait for a few hours to read it tonight, hoping to figure out what i still have to handle.