A VESA driver for XFree86 3.3.2: X without modelines on SuSE Linux 5.3, packaged for YaST

A VESA driver for XFree86 3.3.2: X without modelines on SuSE Linux 5.3, packaged for YaST

🌐 Leer en español

In the KDE 1.0 on SuSE Linux 5.3 post we told the pain of configuring X in 1998: SaX quitting silently, clocks measured as 28.32 MHz, «No valid modes found» and a frozen machine when testing 1024×768. The root problem belonged to the era: every card needed its own driver, its clocks and the exact monitor frequencies, and a mistake could damage a CRT monitor.

DOS games did not suffer: they used VESA, the standard video cards carry in their BIOS (the VESA BIOS Extensions, VBE). The BIOS lists its modes and sets one with a single call. So we wrote XFree86 3.3.2 a VESA driver: a «non-picky» X with no modelines, no clocks and no frequencies.

KDE 1.0 at 1280×1024 with 65 thousand colours on our VESA driver in SuSE Linux 5.3
KDE 1.0 at 1280×1024 with 65 thousand colours on our VESA driver in SuSE Linux 5.3

Code and downloads: the patch, the sources and the README are on GitHub: madgusmx/xf86vesa. The packages xf86vesa-1.0-1.i386.rpm (binary for SuSE 5.3) and xf86vesa-1.0-1.src.rpm are in the v1.0 release.

Before

Without the driver: SaX's VGA16 server measures every clock as 28.32 MHz and finds no modes
Without the driver: SaX's VGA16 server measures every clock as 28.32 MHz and finds no modes
Without the driver: SaX tests 1024×768 and the machine freezes
Without the driver: SaX tests 1024×768 and the machine freezes

How it works

The video BIOS is 16-bit real-mode code, while Linux runs in protected mode. Linux 2.0 offers the vm86() call, which puts the processor in virtual 8086 mode (the same call DOSEMU used to run MS-DOS). With it we built a small real-mode interface (vbe_rm.c), similar to the LRMI of the time:

  • Page 0 (interrupt vectors and BIOS data) is mapped privately from /dev/mem; low memory (up to 640 KB) is our own memory with a copy of the BIOS extended data area; video memory and the ROMs (0xA0000–0xFFFFF) are mapped shared.
  • A three-byte stub, int 10h; hlt, calls the BIOS. The IN/OUT instructions the BIOS runs and the kernel refuses come back as VM86_UNKNOWN and are emulated (including 32-bit ones and REP INS/OUTS). The call ends at the hlt.

With that, the driver (vesa_driver.c, for the XF86_SVGA server) uses the VBE functions:

  • 4F00 / 4F01 in the Probe: the BIOS mode list, with resolution, bits per pixel and the linear framebuffer address. Those modes are handed to X as driver built-in modes (ChipBuiltinModes), so XFree86 asks for no modelines and validates no clocks or frequencies.
  • 4F02 sets the mode, with a linear framebuffer and without clearing memory; 4F06 sets the line width; 4F03 saves the text mode to return to.
  • Going back to the console: the BIOS sets text mode and the driver restores the registers and fonts as they were.

Before touching X we tested it with our own program, vbeinfo, which lists the BIOS modes. On QEMU’s Cirrus GD5446, the BIOS (SeaBIOS) answers VBE 3.0, 4 MB and modes up to 1280×1024, all with a linear framebuffer at 0xFC000000.

vbeinfo on the Cirrus: VBE 3.0, 4 MB and the linear-framebuffer modes
vbeinfo on the Cirrus: VBE 3.0, 4 MB and the linear-framebuffer modes
The first start of X with the driver: the grey weave at 1280×1024, on the first try
The first start of X with the driver: the grey weave at 1280×1024, on the first try
xterm running top, xclock and xlogo drawing correctly
xterm running top, xclock and xlogo drawing correctly
True colour: 16 bits (5-6-5), SteelBlue background
True colour: 16 bits (5-6-5), SteelBlue background

The whole XF86Config

This is all the configuration it needs: a monitor with nothing but a name and Chipset "vesa".

Section "Monitor"
    Identifier  "Cualquiera"
EndSection

Section "Device"
    Identifier  "VESA"
    Chipset     "vesa"
EndSection

Section "Screen"
    Driver      "svga"
    Device      "VESA"
    Monitor     "Cualquiera"
    DefaultColorDepth 16
    SubSection "Display"
        Depth   16
    EndSubSection
EndSection

Without Modes, the driver uses a single mode: the BIOS’s largest up to 1280×1024, with no virtual screen, like a DOS game. With Modes "1024x768" "800x600" it uses those and Ctrl+Alt+«+» cycles through them. Depths: 8, 15, 16, 24 and 32 bits, depending on what the BIOS offers.

Why a single mode by default? Because we found that the emulated Cirrus BIOS gets function 4F07 wrong (the display start, which X uses to pan the virtual screen): asked for (127,127), it leaves (1150,1355). With several modes the picture came out shifted. The driver detects this and logs a warning.

Tested on two cards

KDE 1.0 at 1280×1024 on the VESA driver with the emulated Cirrus
KDE 1.0 at 1280×1024 on the VESA driver with the emulated Cirrus
The X log: VBE 3.0, mode 0x11a, linear framebuffer, 16 bpp 565
The X log: VBE 3.0, mode 0x11a, linear framebuffer, 16 bpp 565
vbeinfo on the standard VGA: 16 MB and many more modes
vbeinfo on the standard VGA: 16 MB and many more modes
KDE at 1280×1024 on the standard VGA, same binary and same XF86Config
KDE at 1280×1024 on the standard VGA, same binary and same XF86Config
  • Cirrus Logic GD5446 (QEMU): KDE at 1280×1024 in 16 bits; switching to the text console and back works.
  • Standard VGA (QEMU, Bochs VBE, 16 MB, framebuffer at 0xFD000000): the same binary and the same file, untouched.

A package for YaST

To install it «the 1998 way», we packaged it with SuSE’s RPM 2.4.12: xf86vesa-1.0-1.i386.rpm (1.3 MB) carries the XF86_VESA server, vbeinfo, the sample XF86Config and vesaconfig, which switches X to the VESA driver and keeps the old setup (vesaconfig --deshacer restores it). The source package is xf86vesa-1.0-1.src.rpm.

To install it with YaST we built an «extras CD» with the original SuSE catalogue plus an entry for our package in the xsrv (X servers) series. We tested it backwards: on the standard VGA, without the driver, the usual SVGA server says «A configured device found, but display modes could not be resolved» and «no screens found». Then, YaST:

Without the driver: «no screens found» on the standard VGA
Without the driver: «no screens found» on the standard VGA
YaST: xf86vesa in the xsrv series, among SuSE's X servers
YaST: xf86vesa in the xsrv series, among SuSE's X servers
YaST: xf86vesa selected for installation
YaST: xf86vesa selected for installation
YaST: the package description
YaST: the package description

YaST had its drama: first it could not find the descriptions (the series .ser files were missing) and then it kept saying «Wrong CD» until the CD had its /.S.u.S.E-disk-001 marker. After that: INSTALLATION COMPLETE, the post-install script, vesaconfig and startx: KDE at 1280×1024 where X would not start before.

YaST: «Wrong CD» before adding the disc marker
YaST: «Wrong CD» before adding the disc marker
YaST: INSTALLATION COMPLETE, with the xf86vesa post-install
YaST: INSTALLATION COMPLETE, with the xf86vesa post-install
rpm -qi xf86vesa and vesaconfig
rpm -qi xf86vesa and vesaconfig
KDE on the standard VGA after installing with YaST
KDE on the standard VGA after installing with YaST

Workshop notes

  • Building needed SuSE’s XFree86 3.3.2 tree (rpm -bp xf86.spec and make World, a few minutes in the virtual machine). SuSE’s Makefile.Linux refused to build because gcc’s specs included /usr/X11R6/lib; we removed it during the build and restored it afterwards.
  • The driver joins XF86SvgaDrivers right before generic, so it is only picked when no specific driver recognises the card, or when asked for with Chipset "vesa".
  • When changing modes the BIOS must be told not to clear video memory (bit 15 of 4F02): X does not redraw the screen on a resolution change.
  • Limits: no 2D acceleration (the processor draws everything) and no DPMS. Requires VBE 2.0 or later with a linear framebuffer.
  • All the heavy work was done in the virtual machine. On real hardware (Intel 965/910) only the result will be tried.
  • MIT/X11-style licence, like XFree86: the patch (xf86vesa-3.3.2.diff, 745 lines), the sources and the RPMs are free. Everything is on GitHub and in the v1.0 release.

Did you have this CD or the magazine? Tell us in the Telegram group: Telegram group

This post is also on our social media:

YouTube

Enjoyed it? Follow us on social media

We post new things every week: don't miss them.

YouTubeFacebookXInstagramTelegram