Networking - Reworked route table management
[tpg/acess2.git] / Kernel / drv / pci.c
index 4123336..8745080 100644 (file)
@@ -17,13 +17,8 @@ typedef struct sPCIDevice
 {\r
        Uint16  bus, slot, fcn;\r
        Uint16  vendor, device;\r
-       union {\r
-               struct {\r
-                       Uint8 class, subclass;\r
-               };\r
-               Uint16  oc;\r
-       };\r
-       Uint8   revision, progif;\r
+       Uint32  class;  // Class:Subclass:ProgIf\r
+       Uint8   revision;\r
        Uint32  ConfigCache[256/4];\r
        char    Name[8];\r
        tVFS_Node       Node;\r
@@ -49,6 +44,15 @@ MODULE_DEFINE(0, 0x0100, PCI, PCI_Install, NULL, NULL);
  int   giPCI_InodeHandle = -1;\r
  int   giPCI_DeviceCount = 0;\r
 tPCIDevice     *gPCI_Devices = NULL;\r
+tVFS_NodeType  gPCI_RootNodeType = {\r
+       .TypeName = "PCI Root Node",\r
+       .ReadDir = PCI_int_ReadDirRoot,\r
+       .FindDir = PCI_int_FindDirRoot\r
+};\r
+tVFS_NodeType  gPCI_DevNodeType = {\r
+       .TypeName = "PCI Dev Node",\r
+       .Read = PCI_int_ReadDevice\r
+};\r
 tDevFS_Driver  gPCI_DriverStruct = {\r
        NULL, "pci",\r
        {\r
@@ -56,8 +60,7 @@ tDevFS_Driver gPCI_DriverStruct = {
        .Size = -1,\r
        .NumACLs = 1,\r
        .ACLs = &gVFS_ACL_EveryoneRX,\r
-       .ReadDir = PCI_int_ReadDirRoot,\r
-       .FindDir = PCI_int_FindDirRoot\r
+       .Type = &gPCI_RootNodeType\r
        }\r
 };\r
 Uint32 *gaPCI_PortBitmap = NULL;\r
@@ -143,7 +146,7 @@ int PCI_ScanBus(int BusID, int bFill)
                        if(!PCI_int_EnumDevice(BusID, dev, fcn, &devInfo))\r
                                continue;\r
                        \r
-                       if(devInfo.oc == PCI_OC_PCIBRIDGE)\r
+                       if(devInfo.class == PCI_OC_PCIBRIDGE)\r
                        {\r
                                #if LIST_DEVICES\r
                                if( !bFill )\r
@@ -158,8 +161,8 @@ int PCI_ScanBus(int BusID, int bFill)
                        {\r
                                #if LIST_DEVICES\r
                                if( !bFill )\r
-                                       Log_Log("PCI", "Device %i,%i:%i %04x => 0x%04x:0x%04x",\r
-                                               BusID, dev, fcn, devInfo.oc, devInfo.vendor, devInfo.device);\r
+                                       Log_Log("PCI", "Device %i,%i:%i %06x => 0x%04x:0x%04x",\r
+                                               BusID, dev, fcn, devInfo.class, devInfo.vendor, devInfo.device);\r
                                #endif\r
                        }\r
                        \r
@@ -272,7 +275,7 @@ int PCI_CountDevices(Uint16 vendor, Uint16 device)
 tPCIDev PCI_GetDevice(Uint16 vendor, Uint16 device, int idx)\r
 {\r
         int    i, j=0;\r
-       for(i=0;i<giPCI_DeviceCount;i++)\r
+       for( i = 0; i < giPCI_DeviceCount; i ++ )\r
        {\r
                if(gPCI_Devices[i].vendor != vendor)    continue;\r
                if(gPCI_Devices[i].device != device)    continue;\r
@@ -288,7 +291,7 @@ tPCIDev PCI_GetDevice(Uint16 vendor, Uint16 device, int idx)
  * \param mask Mask for class comparison\r
  * \param prev ID of previous device (-1 for no previous)\r
  */\r
-tPCIDev PCI_GetDeviceByClass(Uint16 class, Uint16 mask, tPCIDev prev)\r
+tPCIDev PCI_GetDeviceByClass(Uint32 class, Uint32 mask, tPCIDev prev)\r
 {\r
         int    i;\r
        // Check if prev is negative (meaning get first)\r
@@ -297,30 +300,29 @@ tPCIDev PCI_GetDeviceByClass(Uint16 class, Uint16 mask, tPCIDev prev)
        \r
        for( ; i < giPCI_DeviceCount; i++ )\r
        {\r
-               if((gPCI_Devices[i].oc & mask) == class)\r
+               if((gPCI_Devices[i].class & mask) == class)\r
                        return i;\r
        }\r
        return -1;\r
 }\r
 \r
-int PCI_GetDeviceInfo(tPCIDev ID, Uint16 *Vendor, Uint16 *Device, Uint16 *Class)\r
+int PCI_GetDeviceInfo(tPCIDev ID, Uint16 *Vendor, Uint16 *Device, Uint32 *Class)\r
 {\r
        tPCIDevice      *dev = &gPCI_Devices[ID];\r
        if(ID < 0 || ID >= giPCI_DeviceCount)   return 1;\r
        \r
        if(Vendor)      *Vendor = dev->vendor;\r
        if(Device)      *Device = dev->device;\r
-       if(Class)       *Class = dev->oc;\r
+       if(Class)       *Class = dev->class;\r
        return 0;\r
 }\r
 \r
-int PCI_GetDeviceVersion(tPCIDev ID, Uint8 *Revision, Uint8 *ProgIF)\r
+int PCI_GetDeviceVersion(tPCIDev ID, Uint8 *Revision)\r
 {\r
        tPCIDevice      *dev = &gPCI_Devices[ID];\r
        if(ID < 0 || ID >= giPCI_DeviceCount)   return 1;\r
        \r
        if(Revision)    *Revision = dev->revision;\r
-       if(ProgIF)      *ProgIF = dev->progif;\r
        return 0;\r
 }\r
 \r
@@ -442,7 +444,7 @@ int PCI_int_EnumDevice(Uint16 bus, Uint16 slot, Uint16 fcn, tPCIDevice *info)
                return 0;\r
 \r
        info->ConfigCache[0] = vendor_dev;\r
-       for( i = 1; i < 256/4; i ++, addr += 4 )\r
+       for( i = 1, addr += 4; i < 256/4; i ++, addr += 4 )\r
        {\r
                info->ConfigCache[i] = PCI_CfgReadDWord(addr);\r
        }       \r
@@ -453,14 +455,14 @@ int PCI_int_EnumDevice(Uint16 bus, Uint16 slot, Uint16 fcn, tPCIDevice *info)
        info->vendor = vendor_dev & 0xFFFF;\r
        info->device = vendor_dev >> 16;\r
        tmp = info->ConfigCache[2];\r
-       info->revision = tmp & 0xFFFF;\r
-       info->oc = tmp >> 16;\r
+       info->revision = tmp & 0xFF;\r
+       info->class = tmp >> 8;\r
        \r
-       //#if LIST_DEVICES\r
-       //Log("BAR0 0x%08x BAR1 0x%08x BAR2 0x%08x", info->ConfigCache[4], info->ConfigCache[5], info->ConfigCache[6]);\r
-       //Log("BAR3 0x%08x BAR4 0x%08x BAR5 0x%08x", info->ConfigCache[7], info->ConfigCache[8], info->ConfigCache[9]);\r
-       //Log("Class: 0x%04x", info->oc);\r
-       //#endif\r
+//     #if LIST_DEVICES\r
+//     Log("BAR0 0x%08x BAR1 0x%08x BAR2 0x%08x", info->ConfigCache[4], info->ConfigCache[5], info->ConfigCache[6]);\r
+//     Log("BAR3 0x%08x BAR4 0x%08x BAR5 0x%08x", info->ConfigCache[7], info->ConfigCache[8], info->ConfigCache[9]);\r
+//     Log("Class: 0x%06x", info->class);\r
+//     #endif\r
        \r
        // Make node name\r
        info->Name[0] = '0' + bus/10;\r
@@ -479,7 +481,7 @@ int PCI_int_EnumDevice(Uint16 bus, Uint16 slot, Uint16 fcn, tPCIDevice *info)
        info->Node.NumACLs = 1;\r
        info->Node.ACLs = &gVFS_ACL_EveryoneRO;\r
        \r
-       info->Node.Read = PCI_int_ReadDevice;\r
+       info->Node.Type = &gPCI_RootNodeType;\r
        \r
        return 1;\r
 }\r

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