X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fdrv%2Fpci.c;h=98acb99a6d495734589a1f0aea98afc4d8f965ad;hb=6d88cd54792fd7c848f7bb2d1b93d002e2262ae2;hp=8745080b0a3f1f2b808af629b7da6b8d8f1411cb;hpb=48743e39650eb1ef988380e9d95f27fd40d3a9ce;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/drv/pci.c b/KernelLand/Kernel/drv/pci.c index 8745080b..98acb99a 100644 --- a/KernelLand/Kernel/drv/pci.c +++ b/KernelLand/Kernel/drv/pci.c @@ -10,6 +10,7 @@ #include #include +#define USE_PORT_BITMAP 0 #define LIST_DEVICES 1 // === STRUCTURES === @@ -35,7 +36,7 @@ typedef struct sPCIDevice char *PCI_int_ReadDirRoot(tVFS_Node *node, int pos); tVFS_Node *PCI_int_FindDirRoot(tVFS_Node *node, const char *filename); Uint32 PCI_int_GetBusAddr(Uint16 Bus, Uint16 Slot, Uint16 Fcn, Uint8 Offset); -Uint64 PCI_int_ReadDevice(tVFS_Node *node, Uint64 pos, Uint64 length, void *buffer); +size_t PCI_int_ReadDevice(tVFS_Node *node, off_t Offset, size_t Length, void *buffer); int PCI_int_EnumDevice(Uint16 bus, Uint16 dev, Uint16 fcn, tPCIDevice *info); // === GLOBALS === @@ -63,7 +64,9 @@ tDevFS_Driver gPCI_DriverStruct = { .Type = &gPCI_RootNodeType } }; +#if USE_PORT_BITMAP Uint32 *gaPCI_PortBitmap = NULL; +#endif Uint32 gaPCI_BusBitmap[256/32]; // === CODE === @@ -73,9 +76,10 @@ Uint32 gaPCI_BusBitmap[256/32]; */ int PCI_Install(char **Arguments) { - int i; + int ret, bus; void *tmpPtr; + #if USE_PORT_BITMAP // Build Portmap gaPCI_PortBitmap = malloc( 1 << 13 ); if( !gaPCI_PortBitmap ) { @@ -83,14 +87,19 @@ int PCI_Install(char **Arguments) return MODULE_ERR_MALLOC; } memset( gaPCI_PortBitmap, 0, 1 << 13 ); + int i; for( i = 0; i < MAX_RESERVED_PORT / 32; i ++ ) gaPCI_PortBitmap[i] = -1; for( i = 0; i < MAX_RESERVED_PORT % 32; i ++ ) gaPCI_PortBitmap[MAX_RESERVED_PORT / 32] = 1 << i; - + #endif + // Scan Bus (Bus 0, Don't fill gPCI_Devices) - i = PCI_ScanBus(0, 0); - if(i != MODULE_ERR_OK) return i; + for( bus = 0; bus < giPCI_BusCount; bus ++ ) + { + ret = PCI_ScanBus(bus, 0); + if(ret != MODULE_ERR_OK) return ret; + } if(giPCI_DeviceCount == 0) { Log_Notice("PCI", "No devices were found"); @@ -109,10 +118,13 @@ int PCI_Install(char **Arguments) // Reset counts giPCI_DeviceCount = 0; - giPCI_BusCount = 0; + giPCI_BusCount = 1; memset(gaPCI_BusBitmap, 0, sizeof(gaPCI_BusBitmap)); // Rescan, filling the PCI device array - PCI_ScanBus(0, 1); + for( bus = 0; bus < giPCI_BusCount; bus ++ ) + { + PCI_ScanBus(bus, 1); + } // Complete Driver Structure gPCI_DriverStruct.RootNode.Size = giPCI_DeviceCount; @@ -235,8 +247,9 @@ tVFS_Node *PCI_int_FindDirRoot(tVFS_Node *node, const char *filename) } /** + * \brief Read the PCI configuration space of a device */ -Uint64 PCI_int_ReadDevice(tVFS_Node *node, Uint64 pos, Uint64 length, void *buffer) +size_t PCI_int_ReadDevice(tVFS_Node *node, off_t pos, size_t length, void *buffer) { if( pos + length > 256 ) return 0;