I wrote some code to detect PCI devices. And it seems to work fine, I only have some questions about the way it finds a hard disk.
I'll start with my code:
Code: Select all
static int
ol_pci_iterate()
{
ol_pci_dev_t dev = kalloc(sizeof(struct ol_pci_dev));
ol_pci_id_t id;
for(dev->bus = 0; dev->bus < OL_PCI_NUM_BUS; dev->bus++)
{
/* iterate through all busses */
for(dev->device = 0; dev->device < OL_PCI_NUM_DEV; dev->device++)
{
/* Looping trough all devices */
for(dev->func = 0; dev->func < OL_PCI_NUM_FUNC;
dev->func++)
{
id = ol_pci_read_dword(ol_pci_calculate_address(
dev, OL_PCI_REG_ID));
id >>= 16;
--> if(id == 0xffff)
{
if(dev->func == 0) break;
printclass(dev);
} <---
else
{
printclass(dev);
}
}
}
}
}
Because the class code is normal, and the device implements function did i think there was nothing wrong. But to be sure I'm asking.. is it normal? Or should I go through my code again and check for errors? This is something that only appears on a real PC (all PC's I have tested so far).http://wiki.osdev.org/PCI wrote:When a configuration access attempts to select a device that does not exist, the host bridge will complete the access without error, dropping all data on writes and returning all ones on reads. The following code segment illustrates the read of a non-existent device.
Greets,
Bietje