driver: init device driver from PCI layer
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
6340e5d450
commit
2340c41a37
6 changed files with 57 additions and 11 deletions
|
|
@ -395,7 +395,7 @@ void ahci_init()
|
|||
list_t dev_list;
|
||||
list_create(&dev_list);
|
||||
|
||||
driver_register("ahci", DRIVER_PCI, ahci_init_device, NULL, 1, 6);
|
||||
driver_register("ahci", DRIVER_PCI, ahci_init_device, NULL, pci_driver_class(1, 6, 1));
|
||||
|
||||
krdy("AHCI ready\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ static void host_probe_devices(struct pci_host *host)
|
|||
|
||||
pdev->class_major = (class_reg >> 24) & 0xFF;
|
||||
pdev->class_minor = (class_reg >> 16) & 0xFF;
|
||||
pdev->prog_if = (class_reg >> 8) & 0xFF;
|
||||
pdev->revision = (class_reg) & 0xFF;
|
||||
|
||||
u32 bars[6];
|
||||
for (int i = 0; i < 6; i++) {
|
||||
|
|
@ -130,6 +132,15 @@ static void host_probe_devices(struct pci_host *host)
|
|||
break;
|
||||
}
|
||||
|
||||
/* call the driver */
|
||||
u32 driverclass = pci_driver_class(pdev->class_major, pdev->class_minor, pdev->prog_if);
|
||||
struct driver *driver = driver_find(DRIVER_PCI, driverclass);
|
||||
|
||||
if (driver && driver->init_device) {
|
||||
pci_init_t f = driver->init_device;
|
||||
f(pdev);
|
||||
}
|
||||
|
||||
kdebug("PCI device: vendor=%04x, id=%x, major=%x, minor=%x\n", pdev->vendor, pdev->device_id,
|
||||
pdev->class_major, pdev->class_minor);
|
||||
}
|
||||
|
|
@ -137,6 +148,17 @@ static void host_probe_devices(struct pci_host *host)
|
|||
}
|
||||
}
|
||||
|
||||
u32 pci_driver_class(u8 major, u8 minor, u8 prog_if)
|
||||
{
|
||||
u32 ret = major;
|
||||
ret <<= 8;
|
||||
ret |= minor;
|
||||
ret <<= 8;
|
||||
ret |= prog_if;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void pci_init()
|
||||
{
|
||||
pci_device_cache = slab_create("pci_device_cache", sizeof(struct pci_device), 4 * KB, 8);
|
||||
|
|
|
|||
Loading…
Reference in a new issue