Re: Legacy I/O ports and text mode

Michael Steil <[email protected]> Mon, 25 Jul 2005 21:39:45 +0200
Newsgroups gmane.linux.ports.xbox.devel
Message-ID <[email protected]>
Abstract: Legacy I/O ports now work both in Linux and in Cromwell. It  
is unknown how to move the start of VGA RAM. Help needed!

The follwing code enables the legacy I/O ports in Cromwell:

     outl((1 << 31) | (0<<16) | (0x1e<<11) | (0<<8) | 0x3c, 0xcf8);
     outl(inl(0xcfc) | (1<<19), 0xcfc);
     outb(0x01, 0x03c3);
     outb(0x03, 0x03c2);

This seems to be the minimal working code.
The first two lines set bit 19 of register 0x3c of the AGP-to-PCI  
bridge (0:1e.0), which enables AGP-PCI-passthrough of the legacy I/O  
ports and memory regions of VGA. In Linux, this bit is already set  
for some reason.
The third line is "video subsystem enable".
The fourth line is "enable CPU RAM access" and "show CRTC register at  
0x3d4".

By the way, the nForce VGA BIOS also includes similar code at the  
very beginning:

      6ea:    ba c3 03                 mov    $0x3c3,%dx
      6ed:    b0 01                    mov    $0x1,%al
      6ef:    ee                       out    %al,(%dx)
      6f0:    ba cc 03                 mov    $0x3cc,%dx
      6f3:    ec                       in     (%dx),%al
      6f4:    0c 01                    or     $0x1,%al
      6f6:    ba c2 03                 mov    $0x3c2,%dx
      6f9:    ee                       out    %al,(%dx)

This sets bit0 in 0x3c3 and 0x3c2 (if you want to read 0x3c2, you  
have to use 0x3cc instead).

Now it would be cool to set up a real old-style text mode, the  
problem is that VGA and CPU share the same memory on the Xbox, and  
the addresses 0 are the same for CPU and VGA. On an nForce machine,  
the CPU would see less than the total amount of RAM, and VGA memory  
starts at the end of the CPU's RAM. In the case of the Xbox, the CPU  
would think it only had 60 MB of RAM, and address 0 for VGA would be  
address 60MB for the CPU. As soon as we can change this, we should be  
able to set up a real text mode, as well as classic VGA modes such as  
320x200 at 256 colours and so on.

I have uploaded the disassembly of the nForce 420 VGA BIOS (everyone  
can download the BIOS update, so there should be no legal problem) to  
http://www.xbox-linux.org/down/nforce/cr11bt.txt , in case someone  
wants to have a look at it. Perhaps you can find out where the VGA  
ROM asks the BIOS ROM for the size of memory and stores this  
information in some VGA register.

Meanwhile Oliver Schwartz has dug up some old VGA documentation: VGA  
RAM is always mapped to 0xa0000-0xb0000. As VGA RAM is 256 KB, you  
can select one of four banks ("planes') there. 320x200x8bit mode for  
example worked completely on plane 0, while 640x480x4bit needed all  
four planes (every pixel had 1 bit on each plane).
When a text mode is set up, it can be accessed at 0xb8000, but only  
for compatibility with MDA. In reality, all even bytes are mapped to  
linear bytes at plane 0 (address 0 to 64 KB in VGA memory), and all  
odd bytes to plane 1(address 64 KB to 128 KB in VGA memory). A custom  
font can be stored in plane 3.

   Michael


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click