Bochs VBE Extensions: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
No edit summary |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
(20 intermediate revisions by 9 users not shown) | |||
Line 1:
The [[Bochs]] VGA BIOS supports, to an extent, the [[VBE]] specification. Since Bochs only emulates a VGA card down to the hardware level (and a Cirrus graphics card if you enable it, but that is not tied in with the Bochs VBE extensions), it emulates very simple graphics hardware that the VBE BIOS can drive. The advantage of this is that if you are running your OS in Bochs (or QEMU, which uses the Bochs VGA BIOS, or even VirtualBox), you can use this emulated hardware to directly set video modes without using VBE (which would require real mode or v86).▼
▲The [[Bochs]] VGA BIOS supports, to an extent, the VBE specification. Since Bochs only emulates a VGA card down to the hardware level (and a Cirrus graphics card if you enable it, but that is not tied in with the Bochs VBE extensions), it emulates very simple graphics hardware that the VBE BIOS can drive. The advantage of this is that if you are running your OS in Bochs (or QEMU, which uses the Bochs VGA BIOS), you can use this emulated hardware to directly set video modes without using VBE (which would require real mode or v86).
== Overview ==
The Bochs emulated graphics hardware (henceforth called BGA for Bochs Graphics Adaptor) is accessed via two 16-bit IO-ports. The first one is an index port, the second one a data port (comparable to how the VGA handles its sets of registers). Via these ports it is possible to enable or disable the VBE extensions, change the screen resolution and bit depth, and manage a larger virtual screen. There are
The Bochs sources define in vga.h, located in the subdirectory iodev/, a number of defines that are useful for programming the BGA. The names of these defines all start with VBE_DISPI. They are used in the sections below, with their numerical value between parentheses.
== BGA versions ==
As Bochs has evolved, so has the BGA.
* 0xB0C0 - setting X and Y resolution and bit depth (8 BPP only), banked mode
* 0xB0C1 - virtual width and height, X and Y offset
* 0xB0C2 - 15, 16, 24 and 32 BPP modes, support for linear frame buffer, support for retaining memory contents on mode switching
* 0xB0C3 - support for getting capabilities, support for using 8 bit DAC
* 0xB0C4 -
* 0xB0C5 - [http://marc.info/?l=bochs-cvs&m=123287460501516 VRAM increased to 16 MB?] [TODO: verify and check for other changes]
[TODO: if and when 4BPP modes are supported]
[TODO: if and when VGA attribute controller (AC) is supported]
Line 37:
=== Checking availability ===
To check whether the BGA is available, read the value from VBE_DISPI_INDEX_ID (0). If it equals
If for some reason you want Bochs to emulate an older version of the BGA, you can write the desired version to VBE_DISPI_INDEX_ID (0). If succesful, reading the register again will return the value just set. This is used by the Bochs VGA BIOS to ensure it is run with the right version of Bochs. If done from an application (or your OS), this will break
=== Setting display resolution and bit depth ===
Line 84:
=== Using a linear frame buffer (LFB) ===
When using a linear
Unlike Bochs, QEMU does not necessarily pay attention to the VBE_DISPI_LFB_ENABLED flag
'''Note:''' In older versions of Bochs and QEMU, the framebuffer was fixed at 0xE0000000, and modern versions will use that address when emulating ISA-only systems. '''It is highly inadvisable to make assumptions about the address of the linear framebuffer.''' It should always be read from the BGA's PCI BAR0.
=== Clearing display memory ===
When enabling the VBE extensions, Bochs clears the video memory (i.e. sets all bytes to 0). To prevent this from happening, use the VBE_DISPI_NOCLEARMEM flag (0x80) when enabling the VBE extensions (so write a value of VBE_DISPI_ENABLED | VBE_DISPI_NOCLEARMEM (0x81) for banked mode and VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED | VBE_DISPI_NOCLEARMEM (0xC1) for LFB).
===
Based on source code examination for Bochs (iodev/vga.cc) setting VBE_DISPI_GETCAPS in VBE_DISPI_INDEX_ENABLE makes the VBE_DISPI_INDEX_ (XRES / YRES / BPP) fields return their maximum values when read instead of the current values.
=== 8-bit DAC ===
The default palette DAC is a 3x6 bit dac; it returns a value between 0 and 63 for each color. Setting the VBE_DISPI_8BIT_DAC bit in VBE_DISPI_INDEX_ENABLE changes this to a 3x8 bit dac and converts the palette to the appropriate values. Resetting the bit moves them back again.
=== Virtual display ===
The Bochs adapter allows a virtual display that is larger than the physical one. The video memory is normally your screen width wide and at least as high as your vertical screen size, the height. The actual video memory is larger and the remainder is seen as a vertical extension.
Having this as a horizontal extension can be very useful. You can use this to make horizontal and vertical scrolling effects very cheap. You can also make a virtual display, double buffering and lots of other ideas.
The mechanism is used that the memory is a virtual display starting at location (0,0) with a size specified by the virtual width. The height is implicitly as large as it can be within the video memory. Suppose you set the virtual width to be 1024 in a 32-bpp mode (4 bytes per pixel) on a 16-meg Bochs card. That makes the vertical height 4096.
You can then specify where the video card should start reading the memory using the X and Y offset.
The variables taking care of this:
* VBE_DISPI_INDEX_VIRT_WIDTH is the virtual width.
* VBE_DISPI_INDEX_VIRT_HEIGHT is the virtual height, currently not implemented. Reasoning is above.
* VBE_DISPI_INDEX_X_OFFSET is the X offset for displaying.
* VBE_DISPI_INDEX_Y_OFFSET is the Y offset for displaying.
=== Example code ===
<
void BgaWriteRegister(unsigned short IndexValue, unsigned short DataValue)
{
Line 130 ⟶ 152:
}
</syntaxhighlight>
==External Links==
[http://cvs.savannah.nongnu.org/viewvc/*checkout*/vgabios/vgabios/vbe_display_api.txt?revision=1.14 Specification]
[[Category:Video]]
[[Category:VGA]]
|