*/\r
#define DEBUG 0\r
#include <acess.h>\r
+#include <modules.h>\r
#include <vfs.h>\r
#include <fs_devfs.h>\r
#include <drv_pci.h>\r
#define LIST_DEVICES 1\r
\r
// === STRUCTURES ===\r
-typedef struct s_pciDevice {\r
+typedef struct sPCIDevice\r
+{\r
Uint16 bus, slot, fcn;\r
Uint16 vendor, device;\r
union {\r
- struct {Uint8 class, subclass;};\r
+ struct {\r
+ Uint8 class, subclass;\r
+ };\r
Uint16 oc;\r
};\r
Uint16 revision;\r
Uint32 ConfigCache[256/4];\r
char Name[8];\r
tVFS_Node Node;\r
-} t_pciDevice;\r
+} tPCIDevice;\r
\r
// === CONSTANTS ===\r
#define SPACE_STEP 5\r
Uint32 PCI_GetBAR5(int id);\r
Uint16 PCI_AssignPort(int id, int bar, int count);\r
\r
- int PCI_EnumDevice(Uint16 bus, Uint16 dev, Uint16 fcn, t_pciDevice *info);\r
+ int PCI_EnumDevice(Uint16 bus, Uint16 dev, Uint16 fcn, tPCIDevice *info);\r
Uint32 PCI_CfgReadDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset);\r
void PCI_CfgWriteDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset, Uint32 data);\r
Uint16 PCI_CfgReadWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset);\r
int giPCI_BusCount = 1;\r
int giPCI_InodeHandle = -1;\r
int giPCI_DeviceCount = 0;\r
-t_pciDevice *gPCI_Devices = NULL;\r
+tPCIDevice *gPCI_Devices = NULL;\r
tDevFS_Driver gPCI_DriverStruct = {\r
NULL, "pci",\r
{\r
{\r
int bus, dev, fcn, i;\r
int space = 0;\r
- t_pciDevice devInfo;\r
+ tPCIDevice devInfo;\r
void *tmpPtr = NULL;\r
\r
// Build Portmap\r
gaPCI_PortBitmap[i] = -1;\r
for( i = 0; i < MAX_RESERVED_PORT % 32; i ++ )\r
gaPCI_PortBitmap[MAX_RESERVED_PORT / 32] = 1 << i;\r
- //LogF("Done.\n");\r
\r
// Scan Busses\r
for( bus = 0; bus < giPCI_BusCount; bus++ )\r
if(giPCI_DeviceCount == space)\r
{\r
space += SPACE_STEP;\r
- tmpPtr = realloc(gPCI_Devices, space*sizeof(t_pciDevice));\r
+ tmpPtr = realloc(gPCI_Devices, space*sizeof(tPCIDevice));\r
if(tmpPtr == NULL)\r
break;\r
gPCI_Devices = tmpPtr;\r
giPCI_BusCount++;\r
}\r
devInfo.Node.Inode = giPCI_DeviceCount;\r
- memcpy(&gPCI_Devices[giPCI_DeviceCount], &devInfo, sizeof(t_pciDevice));\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
if(tmpPtr != gPCI_Devices)\r
break;\r
}\r
- tmpPtr = realloc(gPCI_Devices, giPCI_DeviceCount*sizeof(t_pciDevice));\r
+ \r
+ if(giPCI_DeviceCount == 0)\r
+ return MODULE_ERR_NOTNEEDED;\r
+ \r
+ tmpPtr = realloc(gPCI_Devices, giPCI_DeviceCount*sizeof(tPCIDevice));\r
if(tmpPtr == NULL)\r
- return 0;\r
+ return MODULE_ERR_MALLOC;\r
gPCI_Devices = tmpPtr;\r
- //LogF("Done.\n");\r
\r
// Complete Driver Structure \r
gPCI_DriverStruct.RootNode.Size = giPCI_DeviceCount;\r
// And add to DevFS\r
DevFS_AddDevice(&gPCI_DriverStruct);\r
\r
- return 1;\r
+ return MODULE_ERR_OK;\r
}\r
\r
/**\r
Uint16 portVals;\r
int gran=0;\r
int i, j;\r
- t_pciDevice *dev;\r
+ tPCIDevice *dev;\r
\r
//LogF("PCI_AssignPort: (id=%i,bar=%i,count=%i)\n", id, bar, count);\r
\r
}\r
\r
/**\r
- * \fn int PCI_EnumDevice(Uint16 bus, Uint16 slot, Uint16 fcn, t_pciDevice *info)\r
+ * \fn int PCI_EnumDevice(Uint16 bus, Uint16 slot, Uint16 fcn, tPCIDevice *info)\r
*/\r
-int PCI_EnumDevice(Uint16 bus, Uint16 slot, Uint16 fcn, t_pciDevice *info)\r
+int PCI_EnumDevice(Uint16 bus, Uint16 slot, Uint16 fcn, tPCIDevice *info)\r
{\r
Uint16 vendor;\r
int i;\r