Kernel/arm7 - Fiddling with PCI etc
[tpg/acess2.git] / Kernel / arch / arm7 / pci.c
index 91cfe99..0d25049 100644 (file)
@@ -3,6 +3,12 @@
  */
 #include <acess.h>
 
+// Realview
+//#define PCI_BASE     0x60000000
+
+//#define PCI_BASE     0xF0400000      // VMM Mapping
+#define PCI_BASE       0
+
 // === PROTOTYPES ===
 #if 1
 void   PCI_CfgWriteDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset, Uint32 data);
@@ -14,13 +20,21 @@ Uint8       PCI_CfgReadByte(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset);
 // === CODE ===
 void PCI_CfgWriteDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset, Uint32 data)
 {
-       // TODO: Use PCI_ADDRESS constant
+       #if PCI_BASE
+       Uint32  address = PCI_BASE | ((Uint)bus<<16) | ((Uint)dev<<11) | ((Uint)func<<8) | (offset&0xFC);
+       *(Uint32*)(address) = data;
+       #else
+       #endif
 }
 
 Uint32 PCI_CfgReadDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset)
 {
-       // TODO: Locate PCI base and read/write data
-       return 0;
+       #if PCI_BASE
+       Uint32  address = PCI_BASE | ((Uint)bus<<16) | ((Uint)dev<<11) | ((Uint)func<<8) | (offset&0xFC);
+       return *(Uint32*)address;
+       #else
+       return 0xFFFFFFFF;
+       #endif
 }
 
 Uint16 PCI_CfgReadWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset)

UCC git Repository :: git.ucc.asn.au