diff options
author | Ian Moffett <ian@osmora.org> | 2025-10-11 16:54:48 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-10-11 16:54:48 -0400 |
commit | b4ed056d786cd4425ca1696f8bfc524764a870ec (patch) | |
tree | 83530e560d6776a4b0e2b1dd60b40982ed5ffa20 /src/sys/io/pci | |
parent | 2692a66b0956434df1411cb9c95aaa5e7a7e4e70 (diff) |
kern: pci: Support lookups via programming iface
Introduce programming interface based lookups for devices with different
kinds of interfaces
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/io/pci')
-rw-r--r-- | src/sys/io/pci/pci.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/sys/io/pci/pci.c b/src/sys/io/pci/pci.c index a21b1e8..2258d52 100644 --- a/src/sys/io/pci/pci.c +++ b/src/sys/io/pci/pci.c @@ -105,6 +105,49 @@ pci_cs_match(struct pci_device *csa, struct pci_device *csb) } /* + * Lookup hook for matching vendor device IDs and + * programming interfaces + * + * @vda: Vendor device (A) + * @vdb: Vendor device (B) + * + * Returns zero on match + */ +static int +pci_vdi_match(struct pci_device *vda, struct pci_device *vdb) +{ + if (vda == NULL || vdb == NULL) + return -EINVAL; + + if (vda->prog_if != vdb->prog_if) + return -1; + + return pci_vd_match(vda, vdb); + +} + +/* + * Lookup hook for matching class, subclass IDs and + * programming interfaces + * + * @csa: Class / subclass (A) + * @csb: Class / subclass (B) + * + * Returns zero on match + */ +static int +pci_csi_match(struct pci_device *csa, struct pci_device *csb) +{ + if (csa == NULL || csb == NULL) + return -EINVAL; + + if (csa->prog_if != csb->prog_if) + return -1; + + return pci_cs_match(csa, csb); +} + +/* * Attempt to register a PCI device and bail * if it doesn't exist on the bus. */ @@ -241,6 +284,12 @@ pci_bus_lookup(struct pci_device *lookup, lookup_type_t type) case PCI_LU_VENDEV: cmp = pci_vd_match(lookup, dp); break; + case PCI_LU_ICLASSREV: + cmp = pci_csi_match(lookup, dp); + break; + case PCI_LU_IVENDEV: + cmp = pci_vdi_match(lookup, dp); + break; } /* Does it match? */ |