kexts: pci: score driver matches, allow fallback class drivers

This commit is contained in:
2023-07-08 15:51:12 +01:00
parent 65db7cfbda
commit 9d2644ffa7
4 changed files with 44 additions and 16 deletions

View File

@@ -18,7 +18,11 @@ static void init_pci_device(uint32_t device, uint16_t vendid, uint16_t devid, vo
pci_get_slot(device),
pci_get_func(device));
printk("pci: found device %s (vend:%04x, dev:%04x)", dev->dev_name, vendid, devid);
uint8_t c = pci_read_field(device, PCI_REG_CLASS, 1);
uint8_t sc = pci_read_field(device, PCI_REG_SUBCLASS, 1);
printk("pci: found device %s (vend:%04x, dev:%04x, class:%02x, subclass:%02x)",
dev->dev_name, vendid, devid, c, sc);
struct pci_device *pci_dev = kmalloc(sizeof *pci_dev, VM_NORMAL);
if (!pci_dev) {
@@ -28,6 +32,8 @@ static void init_pci_device(uint32_t device, uint16_t vendid, uint16_t devid, vo
pci_dev->pci_id.pci_vendor_id = vendid;
pci_dev->pci_id.pci_device_id = devid;
pci_dev->pci_id.pci_class_id = c;
pci_dev->pci_id.pci_subclass_id = sc;
pci_dev->pci_bus = pci_get_bus(device);
pci_dev->pci_slot = pci_get_slot(device);
pci_dev->pci_func = pci_get_func(device);
@@ -38,7 +44,7 @@ static void init_pci_device(uint32_t device, uint16_t vendid, uint16_t devid, vo
if we find a suitable driver for this device, that device will re-register it as theirs. */
device_register(dev, pci_driver, bus_device_base(pci_bus));
struct pci_driver *driver = find_driver_for_pci_device(vendid, devid);
struct pci_driver *driver = find_driver_for_pci_device(&pci_dev->pci_id);
if (driver && driver->probe) {
driver->probe(driver, dev);
}