Subject: in-kernel x86emu
To: None <current-users@netbsd.org>
From: Blair Sadewitz <blair.sadewitz@gmail.com>
List: current-users
Date: 01/19/2007 17:42:11
I've been doing some reasearch on this, and I think that the x86emu
implementation in LinuxBIOSv2 might be fairly straightforward to use
in-place of kvm86call.S. Would it work simply to let kvm86.c allocate
the 1MB of real-mode memory, set up the stack frame, etc, and then
send the memory info and trapframe to the emulator?
I am woefully inexperienced programming at this level; I started
playing around with doing this with x86emu, and it seems like I
actually might understand some of what's going on.
After I had prepared my first ugly hack, I went to build it and then
realized that, of course, kvm86 is meant for i386 and will not work as
is on another architecture.
I would like to continue to make attempts at this, as I find that I
learn the most about coding while doing stuff like this with a copy of
"The C Programming Language" on my desk. ;)
So, if someone could give me some advice on the following, I'd appreciate it:
1) At which point to I demarcate the boundary between the emulator
code and existing kernel code?
Intuitively, it seems like I should let the kernel do as much as
possible and then run the emulator on the environment the kernel
provides (stack frame, page table, etc).
2) The problem with the above is that I obviously can't just put kvm86
in the kernel on a non-i386 architecture and expect the types
(trapframe, etc) to work on a non-i386 architecture. This, I could
make a stub out of some of the x86emu functions and incorporate the
appropriate kernel functions into it (not sure if I'm up to this task
yet).
3) I am not familiar with assembly, so I'm basically just working
blindly in that respect. I will be reading more on this if necessary
(I only have so much time, and I have to work on xorg too); however,
I'm wondering which registers I have to pass to the emulator, and
which I don't.
Kvm86 passes certain registers to kvm86_call() through a trapframe.
It is unclear to me which of these are necessary to pass to the
emulator and which--if any--are merely invovled in the operation of
kvm86_call()/kvm86_return().
I do apologize if some of this seems incoherent, but I have to learn
it somehow, heh.
All the best,
--Blair
P.S. _Plan9_ uses a real-mode emulator for video!
In one email I saw, the one who implemented the emulator said that it
brought the video cards up faster than "native" real mode code did.
--
Support WFMU-FM: free-form radio for the masses!
<http://www.wfmu.org/>
91.1 FM Jersey City, NJ
90.1 FM Mt. Hope, NY
"The Reggae Schoolroom":
<http://www.wfmu.org/playlists/RS/>