Hi,
I am thinking about adding a software 8086 emulator to my OS to handle real mode BIOS calls (specifically to the VIDEO Card BIOS) rather than forcing the CPU into actually enter some kind of "real mode", and I notice that the Virtual 8086 Mode page on the wiki is really quite limited in the information it provides (not really offering suggestions for a software solution), as well as all the links at the bottom of the page are now all broken.
https://wiki.osdev.org/Virtual_8086_Mode
Virtual 8086 Mode
Virtual 8086 Mode
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su
Discord:https://discord.gg/zn2vV2Su
Re: Virtual 8086 Mode
Well, the two aren't related. V8086 mode needs a monitor and is only available in Protected Mode on x86, while x86 emulation is available anywhere (Long Mode on x86, or on any other architecture), but requires an actual emulator. While you can solve the same problem with both of them (running BIOS/expansion ROM code while not in a state to do so natively), for one, usually better solutions exist (for storage: Write a native driver for your OS; for graphics. Write a native driver, or use firmware/bootloader to set a good video mode and only touch the framebuffer afterwards), and for two, they are completely different approaches.bloodline wrote:I am thinking about adding a software 8086 emulator to my OS to handle real mode BIOS calls (specifically to the VIDEO Card BIOS) rather than forcing the CPU into actually enter some kind of "real mode", and I notice that the Virtual 8086 Mode page on the wiki is really quite limited in the information it provides (not really offering suggestions for a software solution),
The article you mentioned does have a link to the Virtual Monitor page, which sports two of the same links. Maybe Virtual Monitor and V8086 Mode should be merged (they are basically the same topic, anyway), and a page on x86 emulation be added and then linked from the V8086 Mode page.
My advice on getting your own emulator started is getting stuck in the appendices of the AMD APM vol. 3. That's the one with the general purpose instructions. The appendices detail the format of instructions (including prefixes and operand encodings in the different operating modes). If I were to write such an emulator, I would do it as I would write every CPU emulator: Define a structure containing all the registers you wish to implement. Design functions to handle memory read/write in all four sizes, as well as I/O read/write in all four sizes (well, OK, legacy BIOS code is unlikely to use Long Mode, so maybe you only need to support three sizes). For memory, emulate a system that has the BIOS IVT (as read at system start), and the BDA at 0x400, and the EBDA at wherever that one was, and the BIOS ROM at its various locations, and a tiny program at 0x600 (which should at least not be allocated by BIOS). I'm thinking of just putting an "int XX" opcode there. And then:
Code: Select all
regs.cs = 0;
regs.ip = 0x600;
while (regs.cs != 0 || regs.ip != 0x602)
x86_step(®s);
Then you can put all of this stuff into its own kernel task, so it does not clog up the machine, and Bob should be your uncle.
Well, one of them isn't. But yes, the dead ones should be removed or updated. However, the links to x86emu don't belong on that page, IMHO. Again, emulation and V8086 mode are quite different.bloodline wrote: as well as all the links at the bottom of the page are now all broken.
Carpe diem!