- Timestamp:
- 04/02/09 21:13:07 (3 years ago)
- Files:
-
- 1 modified
-
Whitix/trunk/include/pci.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/trunk/include/pci.h
r1887 r2008 20 20 #define PCI_H 21 21 22 #include <devices/bus.h> 22 23 #include <console.h> 24 #include <module.h> 23 25 #include <typedefs.h> 26 #include <resource.h> 24 27 25 28 struct PciBus … … 28 31 struct ListHead next; 29 32 struct ListHead deviceList; 33 struct KeBus bus; 30 34 }; 31 35 … … 34 38 struct PciDevice 35 39 { 40 /* PCI configuration information; cached. */ 41 BYTE dev, func, headerType; 42 DWORD vendorId, deviceId; 43 int irq; 44 DWORD devClass; 45 WORD subVendor, subDevice; 46 47 struct Resource spaces[6]; 48 49 /* PCI layer data. */ 36 50 struct PciBus* bus; 37 BYTE dev,func; 38 WORD vendorId,deviceId; 39 BYTE devClass,subClass,irq; 40 WORD subVendor, subDevice; 41 DWORD spaces[6]; /* I/O or memory space */ 51 struct PciDriver* driver; 52 struct KeBusEntry entry; 42 53 43 struct PciDriver* driver;44 54 void* driverData; 45 55 46 56 struct ListHead next; 47 57 }; 58 59 #define PciSetData(driver, data) ((driver)->driverData = (data)) 48 60 49 61 /* PCI BIOS structure. */ … … 69 81 #define PCI_INTERRUPT_PIN 0x3D 70 82 83 #define PCI_PRIMARY_BUS 0x18 84 #define PCI_SECONDARY_BUS 0x19 85 86 #define PCI_WRITE_TEST 0xFFFFFFFF 87 #define PCI_BAR_BASE 0x10 88 89 /* NUmber of I/O resource slots for each device. */ 90 #define PCI_NUM_RESOURCES 6 91 92 #define PCI_RESOURCE_IO 0x01 93 71 94 extern int (*PciRead)(int bus, int dev, int func, int reg, int bytes, DWORD* val); 72 95 extern int (*PciWrite)(int bus, int dev, int func, int reg, DWORD v, int bytes); … … 87 110 #define PciIdTableEnd() {0, 0, 0, 0, 0, 0, NULL} 88 111 112 #define PCI_ID_DATA(id) ((id)->data) 113 89 114 struct PciDeviceId 90 115 { … … 94 119 void* data; 95 120 }; 121 122 /* PCI device classes. */ 123 #define PCI_BASE_CLASS_DISPLAY 0x03 96 124 97 125 struct PciDriver … … 104 132 105 133 /* Internal data */ 134 struct Module* module; 106 135 struct ListHead next; 107 136 void* data; … … 110 139 /* PCI library functions. Used by drivers. */ 111 140 int PciEnableDevice(struct PciDevice* device); 112 int PciRegisterDriver(struct PciDriver* pciDriver); 113 unsigned long PciResourceStart(struct PciDevice* device, int index); 141 int PciDisableDevice(struct PciDevice* device); 142 int PciSetMaster(struct PciDevice* device); 143 int PciRegisterDriverMod(struct Module* module, struct PciDriver* pciDriver); 144 #define PciRegisterDriver(driver) (PciRegisterDriverMod(THIS_MODULE, (driver))) 145 114 146 int PciWriteConfigByte(struct PciDevice* device, int reg, BYTE value); 115 147 int PciReadConfigByte(struct PciDevice* device, int reg, BYTE* value); 116 148 int PciReadConfigWord(struct PciDevice* device, int reg, WORD* value); 149 int PciWriteConfigWord(struct PciDevice* device, int reg, WORD value); 117 150 118 151 int PciReadConfigDword(struct PciDevice* device, int reg, DWORD* value); 119 152 int PciWriteConfigDword(struct PciDevice* device, int reg, DWORD value); 120 153 154 /* Inline library functions */ 155 static inline unsigned long PciResourceStart(struct PciDevice* device, int index) 156 { 157 if (index < 0 || index >= 6) 158 return 0; 159 160 return device->spaces[index].start; 161 } 162 163 static inline unsigned long PciResourceLen(struct PciDevice* device, int index) 164 { 165 if (index < 0 || index >= 6) 166 return 0; 167 168 return device->spaces[index].len; 169 } 170 171 static inline unsigned long PciResourceFlags(struct PciDevice* device, int index) 172 { 173 if (index < 0 || index >= 6) 174 return 0; 175 176 return device->spaces[index].flags; 177 } 178 121 179 #endif
