Fixing up doxygen comments
[tpg/acess2.git] / Kernel / drv / pci.c
index 9260847..1f9e728 100644 (file)
@@ -34,10 +34,10 @@ typedef struct sPCIDevice
 \r
 // === PROTOTYPES ===\r
  int   PCI_Install(char **Arguments);\r
- int   PCI_ScanBus(int ID);\r
+ int   PCI_ScanBus(int ID, int bFill);\r
  \r
 char   *PCI_ReadDirRoot(tVFS_Node *node, int pos);\r
-tVFS_Node      *PCI_FindDirRoot(tVFS_Node *node, char *filename);\r
+tVFS_Node      *PCI_FindDirRoot(tVFS_Node *node, const char *filename);\r
 Uint64 PCI_ReadDevice(tVFS_Node *node, Uint64 pos, Uint64 length, void *buffer);\r
  \r
  int   PCI_CountDevices(Uint16 vendor, Uint16 device, Uint16 fcn);\r
@@ -79,8 +79,8 @@ Uint32        gaPCI_BusBitmap[256/32];
  \r
 // === CODE ===\r
 /**\r
- * \fn int PCI_Install()\r
  * \brief Scan the PCI Bus for devices\r
+ * \param Arguments    Boot-time parameters\r
  */\r
 int PCI_Install(char **Arguments)\r
 {\r
@@ -99,8 +99,8 @@ int PCI_Install(char **Arguments)
        for( i = 0; i < MAX_RESERVED_PORT % 32; i ++ )\r
                gaPCI_PortBitmap[MAX_RESERVED_PORT / 32] = 1 << i;\r
        \r
-       // Scan Bus\r
-       i = PCI_ScanBus(0);\r
+       // Scan Bus (Bus 0, Don't fill gPCI_Devices)\r
+       i = PCI_ScanBus(0, 0);\r
        if(i != MODULE_ERR_OK)  return i;\r
                \r
        if(giPCI_DeviceCount == 0) {\r
@@ -108,12 +108,23 @@ int PCI_Install(char **Arguments)
                return MODULE_ERR_NOTNEEDED;\r
        }\r
        \r
-       // Ensure the buffer is nice and tight\r
-       tmpPtr = realloc(gPCI_Devices, giPCI_DeviceCount*sizeof(tPCIDevice));\r
-       if(tmpPtr == NULL)\r
+       // Allocate device buffer\r
+       tmpPtr = malloc(giPCI_DeviceCount * sizeof(tPCIDevice));\r
+       if(tmpPtr == NULL) {\r
+               Log_Warning("PCI", "Malloc ERROR");\r
                return MODULE_ERR_MALLOC;\r
+       }\r
        gPCI_Devices = tmpPtr;\r
        \r
+       Log_Log("PCI", "%i devices, filling structure", giPCI_DeviceCount);\r
+       \r
+       // Reset counts\r
+       giPCI_DeviceCount = 0;\r
+       giPCI_BusCount = 0;\r
+       memset(gaPCI_BusBitmap, 0, sizeof(gaPCI_BusBitmap));\r
+       // Rescan, filling the PCI device array\r
+       PCI_ScanBus(0, 1);\r
+       \r
        // Complete Driver Structure\r
        gPCI_DriverStruct.RootNode.Size = giPCI_DeviceCount;\r
        \r
@@ -125,12 +136,13 @@ int PCI_Install(char **Arguments)
 \r
 /**\r
  * \brief Scans a specific PCI Bus\r
+ * \param BusID        PCI Bus ID to scan\r
+ * \param bFill        Fill the \a gPCI_Devices array?\r
  */\r
-int PCI_ScanBus(int BusID)\r
+int PCI_ScanBus(int BusID, int bFill)\r
 {\r
         int    dev, fcn;\r
        tPCIDevice      devInfo;\r
-       void    *tmpPtr = NULL;\r
        \r
        if( gaPCI_BusBitmap[BusID/32] & (1 << (BusID%32)) )\r
                return MODULE_ERR_OK;\r
@@ -145,12 +157,6 @@ int PCI_ScanBus(int BusID)
                        if(!PCI_EnumDevice(BusID, dev, fcn, &devInfo))\r
                                continue;\r
                        \r
-                       // Allocate\r
-                       tmpPtr = realloc(gPCI_Devices, (giPCI_DeviceCount+1)*sizeof(tPCIDevice));\r
-                       if(tmpPtr == NULL)\r
-                               return MODULE_ERR_MALLOC;\r
-                       gPCI_Devices = tmpPtr;\r
-                       \r
                        if(devInfo.oc == PCI_OC_PCIBRIDGE)\r
                        {\r
                                #if LIST_DEVICES\r
@@ -158,8 +164,8 @@ int PCI_ScanBus(int BusID)
                                        BusID, dev, fcn, devInfo.vendor, devInfo.device);\r
                                #endif\r
                                //TODO: Handle PCI-PCI Bridges\r
-                               //PCI_ScanBus( );\r
-                               giPCI_BusCount++;\r
+                               //PCI_ScanBus(devInfo.???, bFill);\r
+                               giPCI_BusCount ++;\r
                        }\r
                        else\r
                        {\r
@@ -169,8 +175,10 @@ int PCI_ScanBus(int BusID)
                                #endif\r
                        }\r
                        \r
-                       devInfo.Node.Inode = giPCI_DeviceCount;\r
-                       memcpy(&gPCI_Devices[giPCI_DeviceCount], &devInfo, sizeof(tPCIDevice));\r
+                       if( bFill ) {\r
+                               devInfo.Node.Inode = giPCI_DeviceCount;\r
+                               memcpy(&gPCI_Devices[giPCI_DeviceCount], &devInfo, sizeof(tPCIDevice));\r
+                       }\r
                        giPCI_DeviceCount ++;\r
                        \r
                        // WTF is this for?\r
@@ -202,9 +210,9 @@ char *PCI_ReadDirRoot(tVFS_Node *Node, int Pos)
        return strdup( gPCI_Devices[Pos].Name );\r
 }\r
 /**\r
- * \fn tVFS_Node *PCI_FindDirRoot(tVFS_Node *node, char *filename)\r
+ * \fn tVFS_Node *PCI_FindDirRoot(tVFS_Node *node, const char *filename)\r
  */\r
-tVFS_Node *PCI_FindDirRoot(tVFS_Node *node, char *filename)\r
+tVFS_Node *PCI_FindDirRoot(tVFS_Node *node, const char *filename)\r
 {\r
         int    bus,slot,fcn;\r
         int    i;\r

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