X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Farmv7%2Fpci.c;fp=Kernel%2Farch%2Farmv7%2Fpci.c;h=0d25049f8b64453db2eeef646d4724c79da55a56;hb=acc4756d2e22346862ec098be4a18f52846f6dc4;hp=0000000000000000000000000000000000000000;hpb=327c86d2221d49994ad49ec0d1717444e04521b8;p=tpg%2Facess2.git diff --git a/Kernel/arch/armv7/pci.c b/Kernel/arch/armv7/pci.c new file mode 100644 index 00000000..0d25049f --- /dev/null +++ b/Kernel/arch/armv7/pci.c @@ -0,0 +1,48 @@ +/* + * + */ +#include + +// 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); +Uint32 PCI_CfgReadDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset); +Uint16 PCI_CfgReadWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset); +Uint8 PCI_CfgReadByte(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset); +#endif + +// === CODE === +void PCI_CfgWriteDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset, Uint32 data) +{ + #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) +{ + #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) +{ + return PCI_CfgReadDWord(bus, dev, func, offset & ~3) >> (8*(offset&2)); +} + +Uint8 PCI_CfgReadByte(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset) +{ + return PCI_CfgReadDWord(bus, dev, func, offset & ~3) >> (8*(offset&3)); +}