More work on x86_64 port, near compiling now
[tpg/acess2.git] / Kernel / drv / pci.c
index 9f1dd6e..e205d4f 100644 (file)
@@ -56,7 +56,7 @@ Uint16        PCI_CfgReadWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset);
 Uint8  PCI_CfgReadByte(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset);\r
 \r
 // === GLOBALS ===\r
-//MODULE_DEFINE(0, 0x0100, PCI, PCI_Install, NULL);\r
+MODULE_DEFINE(0, 0x0100, PCI, PCI_Install, NULL, NULL);\r
  int   giPCI_BusCount = 1;\r
  int   giPCI_InodeHandle = -1;\r
  int   giPCI_DeviceCount = 0;\r
@@ -97,15 +97,13 @@ int PCI_Install(char **Arguments)
        // Scan Busses\r
        for( bus = 0; bus < giPCI_BusCount; bus++ )\r
        {\r
-               for( dev = 0; dev < 10; dev++ ) // 10 Devices per bus\r
+               for( dev = 0; dev < 32; dev++ ) // 32 Devices per bus\r
                {\r
-                       for( fcn = 0; fcn < 8; fcn++ )  // 8 functions per device\r
+                       for( fcn = 0; fcn < 8; fcn++ )  // Max 8 functions per device\r
                        {\r
                                // Check if the device/function exists\r
                                if(!PCI_EnumDevice(bus, dev, fcn, &devInfo))\r
-                               {\r
                                        continue;\r
-                               }\r
                                \r
                                if(giPCI_DeviceCount == space)\r
                                {\r
@@ -118,20 +116,26 @@ int PCI_Install(char **Arguments)
                                if(devInfo.oc == PCI_OC_PCIBRIDGE)\r
                                {\r
                                        #if LIST_DEVICES\r
-                                       Log("[PCI ] Bridge @ %i,%i:%i (0x%x:0x%x)",\r
+                                       Log_Log("PCI", "Bridge @ %i,%i:%i (0x%x:0x%x)",\r
                                                bus, dev, fcn, devInfo.vendor, devInfo.device);\r
                                        #endif\r
                                        giPCI_BusCount++;\r
                                }\r
+                               else\r
+                               {\r
+                                       #if LIST_DEVICES\r
+                                       Log_Log("PCI", "Device %i,%i:%i %04x => 0x%04x:0x%04x",\r
+                                               bus, dev, fcn, devInfo.oc, devInfo.vendor, devInfo.device);\r
+                                       #endif\r
+                               }\r
+                               \r
                                devInfo.Node.Inode = giPCI_DeviceCount;\r
                                memcpy(&gPCI_Devices[giPCI_DeviceCount], &devInfo, sizeof(tPCIDevice));\r
                                giPCI_DeviceCount ++;\r
-                               #if LIST_DEVICES\r
-                               Log("[PCI ] Device %i,%i:%i => 0x%x:0x%x",\r
-                                       bus, dev, fcn, devInfo.vendor, devInfo.device);\r
-                               #endif\r
                                \r
                                // WTF is this for?\r
+                               // Maybe bit 23 must be set for the device to be valid?\r
+                               // - Actually, maybe 23 means that there are sub-functions\r
                                if(fcn == 0) {\r
                                        if( !(devInfo.ConfigCache[3] & 0x800000) )\r
                                                break;\r
@@ -152,7 +156,7 @@ int PCI_Install(char **Arguments)
                return MODULE_ERR_MALLOC;\r
        gPCI_Devices = tmpPtr;\r
        \r
-       // Complete Driver Structure    \r
+       // Complete Driver Structure\r
        gPCI_DriverStruct.RootNode.Size = giPCI_DeviceCount;\r
        \r
        // And add to DevFS\r
@@ -290,8 +294,8 @@ int PCI_GetDeviceByClass(Uint16 class, Uint16 mask, int prev)
        \r
        for( ; i < giPCI_DeviceCount; i++ )\r
        {\r
-               if((gPCI_Devices[i].oc & mask) != class)        continue;\r
-               return i;\r
+               if((gPCI_Devices[i].oc & mask) == class)\r
+                       return i;\r
        }\r
        return -1;\r
 }\r

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