Xbox GPU Basics
written by Michael Steil, 1 July 2002
The Xbox graphics hardware manufactured by nVidia is nothing more or less than a PCI (or AGP) VGA card.
Being VGA compatible means that it has all MDA/CGA/EGA/VGA text modes and all CGA/EGA/VGA graphics modes, including Mode X, and that it can be programmed just like IBM's Video Graphics Array from 1988. PCI VGA cards differ from the legacy VGA architecture in concerns of I/O and video RAM access.
VGA Access Methods
The Xbox kernel bootloader configures the VGA hardware so that the legacy I/O ports from 0x3B0 to 0x3DF as well as the legacy memory region from 0xA0000 to 0xBFFFF are disabled, just like on a secondary PCI VGA card in a PC. All VGA accesses are done through the two memory regions introduced with PCI VGA cards. It might be possible to re-enable the legacy resources, but this has not been tested yet.
Like all nVidia graphics controllers, the Xbox GPU has two memory regions in the i386's 4 GB address space: one for Memory Mapped I/O (MMIO) at 0xFD000000 and one for the video RAM at 0xF0000000. Note that these locations are assigned by the Xbox kernel bootloader and can of course be changed using PCI configuration statements.
Memory Mapped I/O
All nVidia VGA hardware has a similar MMIO layout. The most important thing about it is how to access the standard VGA registers, for example to set up a text mode. The standard VGA registers can be found at the following locations in the MMIO space (add 0xFD000000 to get a valid address within the Xbox kernel):
Register Name | VGA I/O port | nVidia MMIO address |
ATTR_REG_INDEX | 0x3c0 | 0x006013c0 |
ATTR_REG_DATA | 0x3c1 | 0x006013c1 |
CRTC_REG_INDEX | 0x3d4 | 0x006013d4 |
CRTC_REG_DATA | 0x3d5 | 0x006013d5 |
GRA_REG_INDEX | 0x3ce | 0x000c03ce |
GRA_REG_DATA | 0x3cf | 0x000c03cf |
SEQ_REG_INDEX | 0x3c4 | 0x000c03c4 |
SEQ_REG_DATA | 0x3c5 | 0x000c03c5 |
MISC_REG | 0x3c2 | 0x000c03c2 |
A simple way to switch into 80x25 text mode would look like this:
void crtcout(unsigned char reg, unsigned char data) {
/* a single 16 bit access might also work */
_asm {
mov al, reg
mov ebx, 0xFD6013d4
mov [ebx], al
mov al, data
mov 1[ebx], al
}
}
void settextmode() {
crtcout(0x00, 0x5F);
crtcout(0x01, 0x4F);
crtcout(0x04, 0x54);
crtcout(0x05, 0x80);
crtcout(0x07, 0x1F);
crtcout(0x10, 0x9C);
crtcout(0x17, 0xA3);
}
Of course, we would have to set up a font first, because the Xbox GPU includes no font in ROM. This information will be important for many different efforts, because it will allow us to output debug information to the screen quite easily, once everything works.
Video RAM
Nothing is known yet on how the video RAM addresses at 0xF0000000 are related to the legacy addresses at 0xA0000.