Code: Select all
VendorID: 0x00008086 DeviceID: 0x00008086 Class: 0x00000006 Subclass: 0x00000000
VendorID: 0x00008086 DeviceID: 0x00008086 Class: 0x00000006 Subclass: 0x00000001
I've also set bochs to emulate an NE2K NIC and a SB16 sound card
I assume that their all being emulated as ISA, but it makes me think my code for PCI is all wrong, or the article
Code:
Code: Select all
typedef struct
{
// TODO
unsigned short vendorID;
unsigned short deviceID;
} pci_config;
typedef struct
{
unsigned char bus;
unsigned char slot;
unsigned char config[256];
} pci_device;
pci_device *pci_devices;
unsigned char pciConfigReadByte(unsigned short bus, unsigned short slot, unsigned short func, unsigned short offset)
{
unsigned long address;
unsigned long lbus = (unsigned long)bus;
unsigned long lslot = (unsigned long)slot;
unsigned long lfunc = (unsigned long)func;
unsigned short tmp = 0;
/* create configuration address as per Figure 1 */
address = (unsigned long)((lbus << 16) | (lslot << 11) | (lfunc << 8) | (offset & 0xFC) | 0x80000000);
outd(0xCF8, address);
return (unsigned char)((ind(0xCFC) >> ((offset & 3) << 3)) & 0xFF);
}
unsigned short pciConfigReadWord(unsigned short bus, unsigned short slot, unsigned short func, unsigned short offset)
{
unsigned long address;
unsigned long lbus = (unsigned long)bus;
unsigned long lslot = (unsigned long)slot;
unsigned long lfunc = (unsigned long)func;
unsigned short tmp = 0;
/* create configuration address as per Figure 1 */
address = (unsigned long)((lbus << 16) | (lslot << 11) | (lfunc << 8) | (offset & 0xFC) | 0x80000000);
outd(0xCF8, address);
return (unsigned short)((ind(0xCFC) >> ((offset & 2) << 3)) & 0xFFFF);
}
unsigned long pciConfigReadDWord(unsigned short bus, unsigned short slot, unsigned short func, unsigned short offset)
{
unsigned long address;
unsigned long lbus = (unsigned long)bus;
unsigned long lslot = (unsigned long)slot;
unsigned long lfunc = (unsigned long)func;
unsigned short tmp = 0;
/* create configuration address as per Figure 1 */
address = (unsigned long)((lbus << 16) | (lslot << 11) | (lfunc << 8) | (offset & 0xFC) | 0x80000000);
outd(0xCF8, address);
return ind(0xCFC);
}
void init_pci()
{
unsigned short bus;
unsigned short slot;
for (bus = 0; bus < 0xFF; bus++)
{
for (slot = 0; slot < 0x20; slot++)
{
if (pciConfigReadDWord(bus, slot, 0, 0) != 0xFFFFFFFF)
{
pci_device device;
for (i = 0; i < 0x40; i++)
{
((unsigned long*)device.config)[i] = pciConfigReadDWord(bus, slot, 0, i << 2);
}
puts("VendorID: ");
puth(((unsigned short*)device.config)[0]);
puts(" DeviceID: ");
puth(((unsigned short*)device.config)[0]);
puts(" Class: ");
puth(device.config[0x0B]);
puts(" Subclass: ");
puth(device.config[0x0A]);
putch('\n');
}
}
}
}
Is it my code thats all wrong, the article wrong, or is it something else?