Annotation of wikisrc/users/rkujawa/g-rex.mdwn, revision 1.4

1.1       rkujawa     1: [[!meta title="G-REX"]]
                      2: 
                      3: Programming the G-REX PCI bridge
1.2       rkujawa     4: 
1.3       rkujawa     5: document version 0.1 - THIS IS A WORK IN PROGRESS!
1.1       rkujawa     6: 
                      7: # 0. Introduction
                      8: 
1.4     ! rkujawa     9: This document describes software/hardware interface of the G-REX PCI bridge 
        !            10: for Amiga computers. What you're reading is a result of reverse engineering, 
        !            11: which was long and difficult process. 
        !            12: 
        !            13: Next time when you're going to buy a hardware product for your Amiga, don't 
        !            14: forget to ask the vendor to make the programming documentation publicly 
        !            15: available! Remeber that hardware without software is just a piece of junk...
1.1       rkujawa    16: and you can't write software without hardware documentation.
                     17: 
                     18: In case you've noticed an error in this document please let me know. 
                     19: 
                     20: # 1. Theory of operation
                     21: 
1.3       rkujawa    22: G-REX is an evolution of PCI bridge used previously on CyberVisionPPC and 
                     23: BlizzardVisionPPC cards. These products share a lot of similiarities (at 
1.4     ! rkujawa    24: least when it comes to PCI interface). In fact CVPPC/BVPPC can be treated as
        !            25: a special one-slot version of G-REX. Maybe actually it's the other way around
        !            26: ;-). 
1.3       rkujawa    27: 
                     28: Firmware does the dirty job of assigning PCI resources (BARs, interrupt lines, 
                     29: etc.) before the OS is running. Therefore G-REX does not need any special 
                     30: initialization.
1.1       rkujawa    31: 
                     32: # 2. Memory map
                     33: 
1.3       rkujawa    34: G-REX is configured as multipie AutoConf boards. Confusingly, they all have the same vendor (8512) and product (101).
1.1       rkujawa    35: 
                     36: 0xFFFA0000 - PCI I/O register space, 64KB.
1.2       rkujawa    37: 
1.1       rkujawa    38: 0xFFFC0000 - PCI configuration space, 128KB.
1.2       rkujawa    39: 
1.1       rkujawa    40: 0xFFFE0000 - Bridge configuration registers, 4kB.
                     41: 
                     42: 0x80000000 - PCI memory space, variable size and number of boards, depending on cards installed. 
                     43: 
1.4     ! rkujawa    44: # 2a. PCI configuration space (0xFFFA0000)
1.1       rkujawa    45: 
1.3       rkujawa    46: Access to configuration space is a bit tricky. Be warned that access to 
                     47: addresses not used by G-REX generates bus error (esp. to configuration 
                     48: locations which are unused because there is no card in the slot). Depending on 
                     49: how these errors are supported in your OS, it may be important to trap them and
                     50: handle correctly. 
1.1       rkujawa    51: 
1.4     ! rkujawa    52: Configuration data for first slot seems to be accessible at offset +0x1000 (on 
        !            53: CVPPC/BVPPC there's aslo a mirror on +0x0).
1.1       rkujawa    54: 
                     55: [TO BE COMPLETED]
                     56: 
1.4     ! rkujawa    57: # 2b. PCI I/O registers space (0xFFFC0000)
1.1       rkujawa    58: 
                     59: This space offers access to I/O registers of all PCI cards.
                     60: 
1.3       rkujawa    61: BAR addresses in this space are treated as relative to 0xFFFA0000. Card with 
                     62: I/O BAR set to 0x100 will actually be available at 0xFFFA0100. 
1.1       rkujawa    63: 
1.4     ! rkujawa    64: # 2c. PCI memory space (0x80000000)
1.1       rkujawa    65: 
1.3       rkujawa    66: This space offers access to memory (and memory-mapped registers) of PCI cards. 
                     67: Each PCI memory BAR is assigned a separate AutoConf board during firmware 
1.4     ! rkujawa    68: initialization.
        !            69: 
        !            70: For example Voodoo 3, which has two 32MB memory BARs, will be visible as 
        !            71: two 8512/101 boards somewhere at 0x80000000 (or later).
1.1       rkujawa    72: 
1.3       rkujawa    73: Addresses in this space are treated as absolute. Memory BAR register set to 
                     74: 0x80000000 means it is configured at this address.  
1.1       rkujawa    75: 
                     76: # 2d. Bridge configuration registers
                     77: 
                     78: Offset - meaning
1.3       rkujawa    79: 
1.1       rkujawa    80: 0x0000 - Endianness swapper mode, write 0x02 to switch bridge into big endian mode
1.3       rkujawa    81: 
1.1       rkujawa    82: 0x0010 - Interrupt enable, write 0x01 to enable interrupts (INT2 on Amiga side)
                     83: 
                     84: No need to fiddle with these registers, as they've been already configured properly by the firmware.
                     85: 
                     86: # 3. Reconfiguring the bus.
                     87: 
1.3       rkujawa    88: If needed, it's possible to reconfigure bus just by writing new values into 
                     89: configuration space. Keep in mind that any previously initialized chips will 
                     90: need to be reset and initialized again (for example 3Dfx Voodoo 3, which is
1.1       rkujawa    91: initialized by the firmware so it can display early startup menu). 
                     92: 
                     93: # 4. Interrupts
                     94: 
1.3       rkujawa    95: All interrupts are converted into Amiga INT2 interrupt. There's no such thing 
                     96: as interrupt acknowledge register.
1.1       rkujawa    97: 
                     98: # 5. DMA
                     99: 
1.3       rkujawa   100: The bridge is certainly capable of DMA, but it needs further reverse 
                    101: engineering.
1.1       rkujawa   102: 
                    103: [TO BE COMPLETED]
                    104: 
1.3       rkujawa   105: There were at least two different revisions of G-REX 1200. Later revision 
                    106: probably does support DMA in two slots.
1.1       rkujawa   107: 
                    108: G-REX 4000D probably has busmaster DMA capability in all slots.
                    109: 
                    110: # 6. Sample PCI bridge driver implementation
                    111: 
1.3       rkujawa   112: The NetBSD [[p5pb|http://netbsd.gw.com/cgi-bin/man-cgi?p5pb+4.amiga+NetBSD-current]] 
                    113: driver serves as an example driver implementation. It was written using the 
                    114: same knowledge that went into this document.
                    115: 
                    116: The driver consists of several files in [[src/sys/arch/amiga/pci|http://nxr.netbsd.org/xref/src/sys/arch/amiga/pci/]] directory.
                    117: 
                    118: p5membar.c - Dummy driver handling AutoConf resources.
                    119: p5membarvar.h - Structures used by the p5membar.
                    120: p5pb.c - Main driver code.
                    121: p5pbreg.h - Inlcude file containing register locations.
                    122: p5pbvar.h - Structures used by the p5pb.
                    123: 
                    124: The p5pb does attach on top of p5bus, however p5membar drivers attach on top of zbus (since 8512/101 entries are seen as Zorro boards).
1.1       rkujawa   125: 
1.4     ! rkujawa   126: # 7. Thanks
        !           127: 
        !           128: [[AmiBay|http://www.amibay.com]] users d0pefish and ramborolf helped testing 
        !           129: early versions of p5pb driver. Without their help this document would not 
        !           130: exist.
        !           131: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb