Page 1 of 1

Emulating real mode and video modes

Posted: Mon Aug 24, 2015 11:16 pm
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!

Re: Emulating real mode and video modes

Posted: Tue Aug 25, 2015 12:51 am
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".

Re: Emulating real mode and video modes

Posted: Tue Aug 25, 2015 8:58 am
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.

Re: Emulating real mode and video modes

Posted: Tue Aug 25, 2015 9:05 am
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!