PCI enumeration [solved]
Posted: Thu Mar 13, 2008 2:18 pm
hey, can somebody check my code please. It seems right to me, but i'm trying to enumerate the PCI, and load drivers from the data gathered (Well... print a message and _eventually_ enable the driver).
This is the code i'm using the get the Class code etc, and i then switch this using:
I get 32 entries in the PCI for Qemu, and 16 for bochs (is this right?), but the Class Code is always 0x00.
any thoughts or obvious errors?
thanks, luke
Code: Select all
static PCI_Device_t* pci_getdevice(int bus, int device, int function)
{
static PCI_Device_t* pci_device;
unsigned short vendor = 0, deviceid = 0;
unsigned char classcode = 0, subclass = 0;
if ((vendor = pci_read(bus,device,0,0)) != 0xFFFF)
{
deviceid = pci_read(bus,device,0,2);
classcode = (pci_read(bus,device,0,10) << 4 );
subclass = (pci_read(bus,device,0,10) >> 4 );
pci_device->ClassCode = classcode;
pci_device->SubClass = subclass;
pci_device->VendorID = vendor;
pci_device->DeviceID = deviceid;
}
pci_device->VendorID = vendor;
return pci_device;
}
This is the code i'm using the get the Class code etc, and i then switch this using:
Code: Select all
switch(tmp->ClassCode)
{
//Pre-PCI Items
case 0x00:
if(tmp->SubClass == 0x01)
//Load VGA driver
kprintf("VGA driver loading (legacy)... \n");
break;
//Mass storage devices
case 0x01:
if(tmp->SubClass == 0x01)
//IDE
kprintf("ATA (IDE) driver loading... [TODO]\n");
if(tmp->SubClass == 0x02)
//Floppy
kprintf("Floppy legacy driver loading... [TODO]\n");
if(tmp->SubClass == 0x80)
kprintf("Mass storage device controller driver loading... [TODO]\n");
break;
...
any thoughts or obvious errors?
thanks, luke