[SeaBIOS] [PATCH v2 0/4] vgabios: three fixes for Cirrus chips

Christian Quante posted 4 patches 19 hours ago
vgasrc/bochsvga.c |  9 +++++++-
vgasrc/bochsvga.h |  1 +
vgasrc/clext.c    | 54 +++++++++++++++++++++++++++++------------------
vgasrc/stdvga.c   | 10 ++++++++-
vgasrc/stdvga.h   |  1 +
vgasrc/vbe.c      |  3 +--
vgasrc/vgahw.h    |  8 +++++++
vgasrc/vgautil.h  |  2 +-
8 files changed, 63 insertions(+), 25 deletions(-)
[SeaBIOS] [PATCH v2 0/4] vgabios: three fixes for Cirrus chips
Posted by Christian Quante 19 hours ago
Three fixes for the Cirrus part of SeaVGABIOS (vgasrc/clext.c), found
while running OS/2 2.1 and OS/2 Warp 3 with their Cirrus display drivers
on QEMU's cirrus-vga and isa-cirrus-vga, and one patch that prepares the
second fix without a change in behavior.

Changes in v2:
 - New patch 2, as Kevin suggested: replace the global
   VBE_win_granularity with bochsvga_get_win_granularity(),
   clext_get_win_granularity() and stdvga_get_win_granularity(), so
   that vgahw.h only calls the driver functions.
 - Patch 3 (patch 2 in v1) now changes only vgasrc/clext.c, without the
   comment above clext_get_win_granularity().
 - Patches 1 and 4 (patch 3 in v1) are unchanged.

Patch 1: int 10h ax=12xxh bl=80h reads CR27 on each call.  In a DOS
session in a window under OS/2 2.1, before the Cirrus display driver is
installed, the VGA ports are virtualized, the read does not return the
chip id, and SeaVGABIOS reports 0xff (unknown chip).  The installer of
the OS/2 display driver package for the CL-GD5436/46 runs its chip check
(IDCHIP.EXE) in such a session and stops.  The patch reads CR27 once at
init time, as is done for the memory size.

Patch 2: vbe_104f01() reports the window granularity from a global
variable, so it is the same for all modes.  The patch replaces it with a
function for each driver, which gets the mode.  It does not change what
VBE 4f01h reports.

Patch 3: SeaVGABIOS sets 16K bank granularity for the Cirrus modes.  In
my measurements, the Cirrus BIOS uses 4K for modes up to 1MB and 16K
above, for int 10h mode sets and VBE alike, and VBE 4f01h reports the
matching value.  The patch does the same.  Software that switches banks
by itself after a BIOS mode set depends on it; OS/2 2.1 draws its
desktop in bands without it.

Patch 4: SeaVGABIOS writes 0x04 to SR12 for every Cirrus mode, which
selects the 64x64 hardware cursor.  The Cirrus BIOS writes 0x00 to SR12
and SR13 on each mode set that I measured.  The WIN-OS/2 full screen
drivers of OS/2 Warp 3 load a 32x32 cursor and change only bit 0 and
bit 1 of SR12; with SeaVGABIOS the mouse pointer is a white block
instead of the arrow.  The patch writes 0x00 to SR12 and SR13 as the
Cirrus BIOS does.

Tests, each with SeaBIOS master (81ec9ec0) and with the patches,
SeaVGABIOS built with QEMU's config.vga-cirrus, on QEMU 11.1.2 or QEMU
master.  My pending Cirrus patches for QEMU do not touch the registers
that these tests read:

 - Register state after 13 mode sets (int 10h 5fh 5ch 60h 6dh 64h 74h,
   VBE 101h 103h 105h 107h 111h 114h 117h), read by a boot sector test:
   GR0B, the VBE granularity and GR9 after 4f05h are the same as with
   the CL-GD5436/46 PCI VGA BIOS 1.25 on cirrus-vga and with the
   CL-GD543x VGA BIOS 1.00a on isa-cirrus-vga.  SR12 and SR13 after the
   same mode sets and after int 10h 03h, 12h and 13h are the same too.
 - IDCHIP.EXE in an OS/2 2.1 DOS window, cirrus-vga: "Chiptype is
   0xff" -> "Chiptype is 0x39".
 - OS/2 2.1 "SVGA ON": SVGADATA.PMI records GR0B = 0x20 -> 0x00 for the
   256 color modes; the desktop at 1024x768 is in bands -> correct.
   OS/2 2.1 knows only the CL-GD5422, CL-GD5424 and CL-GD5426, so I ran
   this with a local QEMU build in which isa-cirrus-vga reports a
   CL-GD5426.  OS/2 also needs my QEMU patch "hw/display/cirrus_vga:
   read back the cursor position bits of SR10/SR11" to find the Cirrus
   chip; I will send it to qemu-devel soon.
 - OS/2 Warp 3 on isa-cirrus-vga, desktop 1024x768 with 65536 colors,
   WIN-OS/2 full screen, TCG: white 64x64 block -> arrow, which follows
   the mouse.  Warp 3 with its Cirrus driver also needs that QEMU patch.
 - Windows for Workgroups 3.11 with the CL-GD5436/46 driver for Windows
   3.1, and OS/2 2.1 with the CL-GD5436/46 display driver: both work
   with patches 1 and 3 (they use the linear frame buffer).  With patch
   4, Windows shows the same picture as without it.  Windows for
   Workgroups with this driver needs my Cirrus patches for QEMU (the
   first series is <20261018050643.9288-1-christian@quante.one>).
 - Patch 2: a boot sector test calls VBE 4f01h for each mode of the
   4f00h mode list and for modes 03h, 12h and 13h, and reads the window
   attributes, granularity, size and segment.  Before and after patch 2
   the results are the same on VGA, isa-vga, vmware-svga, virtio-vga,
   bochs-display, ramfb, cirrus-vga and isa-cirrus-vga, each with the
   matching config.vga-* build of SeaVGABIOS.
 - All nine vgabios configurations of QEMU build without new warnings.

The guest tests above (IDCHIP.EXE, OS/2, Windows) are from v1.  For v2
I repeated the boot sector tests: v1 and v2 give the same results.

The patches apply to rel-1.17.0 as well.

Christian Quante (4):
  clext: report the chip id that was read at init time
  vgasrc: replace VBE_win_granularity with a function per driver
  clext: set the bank granularity per mode, as the Cirrus BIOS does
  clext: leave the hardware cursor off and at 32x32 after a mode set

 vgasrc/bochsvga.c |  9 +++++++-
 vgasrc/bochsvga.h |  1 +
 vgasrc/clext.c    | 54 +++++++++++++++++++++++++++++------------------
 vgasrc/stdvga.c   | 10 ++++++++-
 vgasrc/stdvga.h   |  1 +
 vgasrc/vbe.c      |  3 +--
 vgasrc/vgahw.h    |  8 +++++++
 vgasrc/vgautil.h  |  2 +-
 8 files changed, 63 insertions(+), 25 deletions(-)

-- 
2.53.0

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH v2 0/4] vgabios: three fixes for Cirrus chips
Posted by Kevin O'Connor via SeaBIOS 8 hours ago
On Mon, Oct 19, 2026 at 06:39:15AM +0200, Christian Quante wrote:
> Three fixes for the Cirrus part of SeaVGABIOS (vgasrc/clext.c), found
> while running OS/2 2.1 and OS/2 Warp 3 with their Cirrus display drivers
> on QEMU's cirrus-vga and isa-cirrus-vga, and one patch that prepares the
> second fix without a change in behavior.
> 
> Changes in v2:
>  - New patch 2, as Kevin suggested: replace the global
>    VBE_win_granularity with bochsvga_get_win_granularity(),
>    clext_get_win_granularity() and stdvga_get_win_granularity(), so
>    that vgahw.h only calls the driver functions.
>  - Patch 3 (patch 2 in v1) now changes only vgasrc/clext.c, without the
>    comment above clext_get_win_granularity().
>  - Patches 1 and 4 (patch 3 in v1) are unchanged.

Thanks.  The series looks good to me.  I'll give a few days to see if
there are any other comments and otherwise look to commit.

-Kevin

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org