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