Emulating real mode and video modes

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Emulating real mode and video modes

Post by kzinti »

I have integrated libx86emu into my OS so that I can run the BIOS under emulation.

I am able to call int 10h for normal VGA and for SVGA functions. The returned results are good. For example I can list SVGA video modes, set one using 0x4F02 and I get "success".

But, for some reason the video mode will not actually change (tried both QEmu and Bochs). Nothing in the logs. I suspect something is wrong with my VM setup, but I'm not sure what. I tried both VGA modes (0x0013) and SVGA modes (0x4f02).

Anyone has any experience doing this?

My emulation code lives here:
https://github.com/kiznit/kiznix/blob/m ... x86/bios.c

x86emu setup here:
https://github.com/kiznit/kiznix/blob/m ... ios.c#L164

test code here:
https://github.com/kiznit/kiznix/blob/m ... ios.c#L233

Note that my first 1 MB of physical memory (DOS/BIOS area) is mapped at ISA_IO_BASE (which is 0xC0000000 VMA).

Thanks!
User avatar
Artlav
Member
Member
Posts: 178
Joined: Fri Aug 21, 2009 5:54 am
Location: Moscow, Russia
Contact:

Re: Emulating real mode and video modes

Post by Artlav »

kiznit wrote:Anyone has any experience doing this?!
I don't see where you pass IO port access from and to the VM to and from the real HW.
Look for "x86emu_set_memio_handler".
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: Emulating real mode and video modes

Post by kzinti »

Artlav wrote:I don't see where you pass IO port access from and to the VM to and from the real HW.
Look for "x86emu_set_memio_handler".
My understanding is that libx86emu will use the in*/out* functions in sys/io.h by default:
https://github.com/kiznit/kiznix/blob/m ... e/sys/io.h

In my case, the functions are simply redirected to:
https://github.com/kiznit/kiznix/blob/m ... l/x86/io.h

I'll double check that this is indeed the case.
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: Emulating real mode and video modes

Post by kzinti »

Yes, it looks like the emulator isn't calling my in*/out* port functions. Thanks!

EDIT: I tracked down the problem to M.io.iopl_ok being false.

#defining WITH_IOPL to 0 in x86emu_int.h fixed the problems. Ports are now accessed and stuff is crashing in the BIOS ROM. Thanks again!
Post Reply