v86 icon indicating copy to clipboard operation
v86 copied to clipboard

v86 does not emulate 'chunky' VGA graphics mode.

Open Rodmatronic opened this issue 3 months ago • 11 comments

Version: ccb5e1ce (Sep 20, 2025 11:09)

v86 does not emulate the 'chunky' VGA graphics mode as seen in the NEW KERNEL/VGA demo (https://github.com/pritamzope/OS.git)

Instead of outputting pixels, it stays in the VGA text mode, but displaying an array of whatever should be onscreen as text. The text mode in v86 is incorrectly set to: 'Resolution: 80x480'.

Image

Rodmatronic avatar Sep 21 '25 23:09 Rodmatronic

Coincidentally this is also BIOS-related. Like in your other issue, it works using Bochs BIOS (or to be more specific, its VGA BIOS):

https://github.com/user-attachments/assets/da146783-4c9c-4f9a-898d-e9ebe28a7ce7

I only vaguely know about screen mode differences between the two BIOSes (Bochs and SeaBIOS), but I'm certain that mode 320x200x8 is supported by both, maybe you can find a different way to set the video mode (for example, BIOS interrupt 0x10 with mode 0x13, IIRC).

To build the CDROM image VGA_Simple_OS.iso I simply ran OS/VGA/kernel_c/Simple/run.sh.

chschnell avatar Sep 28 '25 10:09 chschnell

So, is this still a v86 issue? It does not come with the Bochs BIOS by default, yet it fixes most things. Should it be bundled by default?

Rodmatronic avatar Sep 28 '25 16:09 Rodmatronic

Bochs BIOS is bundled with V86.

It's not used in any of the presets, and I think that a small change to V86 would be needed to support presetting BIOS and VGABIOS to Bochs.

Pragmatically, Bochs could be seen as a band-aid until this is also supported in V86 when using SeaBIOS.

chschnell avatar Sep 28 '25 17:09 chschnell

Does the issue happen with qemu (which uses seabios by default)?

copy avatar Sep 29 '25 03:09 copy

No, a simple qemu-system-i386 VGA_Simple_OS.iso does not have this issue.

Image

chschnell avatar Sep 29 '25 10:09 chschnell

Exactly! I was sure QEMU used Seabios, that is why I thought all these issues were v86 related. How could the same BIOS have such different and broken affects under different emulators?

Rodmatronic avatar Sep 29 '25 11:09 Rodmatronic

Could be that v86 doesn't recognize seabios's magic values. Or some difference in the config

copy avatar Sep 29 '25 11:09 copy

Bochs with built-in BIOS works as expected: bochsout-bochs.txt, bochsrc-bochs.txt

screenshot bochs-bios

However, it doesn't work on SeaBIOS, taken from v86: bochsout-v86.txt, bochsrc-v86.txt

screenshot v86-bios

...and compiled from SeaBIOS source code: bochsout-seabios.txt, bochsrc-seabios.txt, seabios-config.txt

And for interest, ET4000AX VGA BIOS gives the correct image in v86:

screenshot et4000ax-bios

Bochs commit: https://github.com/bochs-emu/Bochs/commit/84b37f5faab6a552c97692b01db830f046572c81 SeaBIOS commit: https://github.com/coreboot/seabios/commit/0026c353eb4e220af29750fcf000d48faf8d4ab3

SuperMaxusa avatar Sep 29 '25 15:09 SuperMaxusa

I found a few more pieces to this puzzle.

Mixing SeaBIOS BIOS with Bochs VGABIOS

We do not need Bochs BIOS, we can use V86's default SeaBIOS BIOS and mix it with Bochs VGABIOS, I tested it and that's enough to make it work.

Guest OS "pritamzope/OS"

The code we tested in VGA/kernel_c/* doesn't actually use the BIOS to interface the VGA adapter, instead it writes directly to the VGA registers to setup the video mode (for example see VGA/kernel_c/Simple/vga.c, it's the same for all 4 projects in this subtree).

This means that the only difference here in regard to the VGA BIOS is the register state of the VGA adapter after the BIOS has setup the initial video mode at early boot. To my understanding, V86 loads BIOS and VGABIOS, starts the BIOS, and then the BIOS uses the VGABIOS to setup the initial VGA state. The potentially different inital VGA states might explain why the direct register access works with Bochs VGABIOS and not with SeaBIOS' VGABIOS.

Note that the code in /NEW KERNEL/VESA VBE/* uses the VBE BIOS extensions instead to setup the VGA video mode, and this works as expected under V86 with the default BIOSes, I compared the output to qemu's to make sure:

Screenshots VESA_VBE20 under V86 and qemu Image Image

Download: VESA_VBE20.zip

Qemu's default VGABIOS

From https://www.qemu.org/docs/master/system/qemu-manpage.html:

QEMU uses the PC BIOS from the Seabios project and the Plex86/Bochs LGPL VGA BIOS.

The qemu VGABIOS (Bochs, actually) project appears to be at https://github.com/bochs-emu/VGABIOS, and the VGABIOS image file it builds is VGABIOS-lgpl-latest.bin, and I'm 99% sure that this is the VGABIOS used by qemu. So far I couldn't confirm this on my Debian 12 (still looking), maybe someone else can help me to confirm this? I don't know enough about qemu.

So I tested our default SeaBIOS together with that qemu VGABIOS image file and guest OS "pritamzope/OS" works as expected under V86.

If this is indeed the default VGABIOS used by qemu, and if it should be compatible with all V86 profiles and tests, then simply switching to this VGABIOS might be a proper fix here.

Download VGABIOS-lgpl-latest.bin

chschnell avatar Oct 04 '25 10:10 chschnell

Interesting, I tried using bios.bin and vgabios-stdvga.bin (default in QEMU) from https://gitlab.com/qemu-project/qemu/-/tree/master/pc-bios and they don't work with VGA_Simple_OS.iso on v86 as expected.

SuperMaxusa avatar Oct 04 '25 16:10 SuperMaxusa

Interesting, I tried using bios.bin and vgabios-stdvga.bin (default in QEMU) from https://gitlab.com/qemu-project/qemu/-/tree/master/pc-bios and they don't work with VGA_Simple_OS.iso on v86 as expected.

Yeah, I can confirm. Did you see the README:

  • SeaBIOS (bios.bin) is the successor of pc bios.
    See http://www.seabios.org/ for more information.

  • The VGA BIOS and the Cirrus VGA BIOS come from the LGPL VGA bios
    project (http://www.nongnu.org/vgabios/).

The second link points to Bochs, it's confusing.

This leaves the main question unanswered. I checked the VGA logs of both VGABIOSes by booting both without any bootable media, this logs all VGA things that the BIOS is doing during startup.

Unsurprisingly, these logs look completely different, Bochs is about 1/3rd longer.

If I find time I will try to compare the registers states of V86's VGAAdapter at the end of these boot sequences, maybe we have a bad or missing default. That would assume that this guest does not initialize the entire VGA adapter.

chschnell avatar Oct 07 '25 13:10 chschnell