ahci: load AHCI as module

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-08-12 16:06:58 -04:00
commit cb2c3e1053
Signed by: michaelsshaw
GPG key ID: 5A5E0FB20708A9E7
6 changed files with 74 additions and 13 deletions

View file

@ -392,11 +392,8 @@ static int ahci_init_device(struct pci_device *device)
void ahci_init()
{
list_t dev_list;
list_create(&dev_list);
driver_register("ahci", DRIVER_PCI, ahci_init_device, NULL, pci_driver_class(1, 6, 1));
krdy("AHCI ready\n");
}
DRIVER_ENTRY_PRIORITY(ahci_init, 2);
DRIVER_ALIAS("pci:010601");

View file

@ -76,6 +76,17 @@ size_t pci_find_device(u16 major, u16 minor, list_t *out)
return n;
}
static void device_init(struct pci_device *pdev)
{
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);
}
}
static void host_probe_devices(struct pci_host *host)
{
for (int bus = 0; bus < 256; bus++) {
@ -138,14 +149,7 @@ 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);
}
device_init(pdev);
kdebug("PCI device: vendor=%04x, id=%x, major=%x, minor=%x\n", pdev->vendor, pdev->device_id,
pdev->class_major, pdev->class_minor);