Added class and subclass for PCI enumerating

This commit is contained in:
Adrien Bourmault 2020-02-17 18:47:23 +01:00
parent 90b65e20ba
commit c817e97ae4
2 changed files with 19 additions and 6 deletions

View File

@ -35,11 +35,18 @@
// //
// Device registers offsets // Device registers offsets
// //
#define PCI_REG_VENDOR 0 #define PCI_REG_VENDOR 0x00
#define PCI_REG_DEVICE 2 #define PCI_REG_DEVICE 0x02
#define PCI_REG_COMMAND 4 #define PCI_REG_COMMAND 0x04
#define PCI_REG_STATUS 6 #define PCI_REG_STATUS 0x06
//.. #define PCI_REG_REVISION 0x08
#define PCI_REG_PROGIF 0x09
#define PCI_REG_SUBCLASS 0x0A
#define PCI_REG_CLASS 0x0B
#define PCI_REG_CACHE_LINE_SIZE 0x0C
#define PCI_REG_LATENCY_TIMER 0x0D
#define PCI_REG_HEADER_TYPE 0x0E
#define PCI_REG_BIST 0x0F
#define PCI_REG_BAR0 0x10 #define PCI_REG_BAR0 0x10
#define PCI_REG_BAR1 0x14 #define PCI_REG_BAR1 0x14
#define PCI_REG_BAR2 0x18 #define PCI_REG_BAR2 0x18
@ -57,6 +64,10 @@
struct PciDev_t { struct PciDev_t {
ushort vendorID; ushort vendorID;
ushort deviceID; ushort deviceID;
uchar classID;
uchar subclassID;
void* configAddr; void* configAddr;
}; };

View File

@ -115,7 +115,9 @@ void IoPciEnumerate()
for(uchar function = 0; function < 8; function++) { for(uchar function = 0; function < 8; function++) {
ushort vendor = pciReadConfigWord((uchar)bus, device, function, PCI_REG_VENDOR); ushort vendor = pciReadConfigWord((uchar)bus, device, function, PCI_REG_VENDOR);
if(vendor == 0xffff) continue; if(vendor == 0xffff) continue;
DebugLog("PCI device vendor: %x, device: %x\n", DebugLog("PCI device class: %x, subclass: %x, vendor: %x, device: %x\n",
pciReadConfigByte((uchar)bus, device, function, PCI_REG_CLASS),
pciReadConfigByte((uchar)bus, device, function, PCI_REG_SUBCLASS),
vendor, vendor,
pciReadConfigWord((uchar)bus, device, function, PCI_REG_DEVICE) pciReadConfigWord((uchar)bus, device, function, PCI_REG_DEVICE)
); );