OSD Home

Graphics in pmode

'How do I enable graphics from protected mode?'
  1. You don't. Graphics programming is fun, but graphics are hardly essential for an OS. Don't get side-tracked.
  2. Call the BIOS mode-set interrupt in the 16-bit boot code, before the pmode kernel starts.
  3. Use protected-mode code to program the VGA directly, without using the BIOS. This works only with VGA-compatible video boards and VGA-compatible video modes.
  4. Add a virtual 8086 mode monitor (VMM) to your OS. Call the BIOS mode-set interrupt in virtual 8086 mode.
  5. Switch from pmode to real mode, call the BIOS mode-set interrupt in real mode, then return to pmode.
  6. Write a protected-mode driver specifically for the SVGA chip used in your video board. Someone else who wants to use your OS must have the same video board (or they must write a new driver for their own video board).
  7. Call VBE 3.x BIOS functions in 16-bit protected mode. VBE 3.x is supported only by very new video cards.

Video timing

VGA

Super VGA (SVGA)

Code snippets

VGA graphics demo. Pixels, rectangular fill, horizontal and vertical lines, and text blitting in 5 different graphics modes.

Set text or graphics video modes (including text font) without using the BIOS

Simple V86 mode monitor; calls 16-bit video BIOS from 32-bit pmode.

Links

Tauron VGA utilities: http://alexfru.narod.ru/miscdocs/ega_vga/tauron30.zip

Finn Thøgersen's VGADOC: http://home.worldonline.dk/finth/

Simulated linear framebuffer:

TO DO

(S)VGA functional units:
- Miscellaneous register
- Sequencer (SEQ)
        - In unchained modes, SEQ register 2 selects one
          (or more!) planes to write
- CRT Controller (CRTC)
- Graphics Controller (GC)
        - In unchained modes, GC register 4 selects a plane to read
- Attribute Controller (AC)
        - 16-color palette in first 16 registers of AC
- 256-color palette (DAC)

Gotchas:
- 'Lock' bits in CRTC registers 3 and 17
- Screwy CGA addressing (disabled by bit b0 in CRTC register 23)
- Palette is not compact, i.e. for the 16-color palette
        entry[i] != i

REPORT BUGS OR ERRORS IN THIS DOCUMENT