From 1330e1e54c38d6ba0391d556b694813ae389daa1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 19 Sep 2025 18:00:05 -0400 Subject: kernel: pci: Add PCI lookup routine This commit adds a new 'lookup_type_t' for representing the various kinds of lookups one can perform on the PCI bus. The actual code to drive the lookups is exposed as the pci_bus_lookup() routine. When doing a lookup of a PCI device, you must specify the kind of lookup to perform. If a PCI_LU_CLASSREV is requested, only the PCI class and subclass fields in the PCI lookup are used. If the PCI_LU_VENDEV is requested, only the PCI vendor ID and device ID are used in the lookup. Signed-off-by: Ian Moffett --- src/sys/include/io/pci/pci.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/sys/include') diff --git a/src/sys/include/io/pci/pci.h b/src/sys/include/io/pci/pci.h index bc39647..cff5f0a 100644 --- a/src/sys/include/io/pci/pci.h +++ b/src/sys/include/io/pci/pci.h @@ -58,6 +58,20 @@ struct pci_device { TAILQ_ENTRY(pci_device) link; }; +typedef enum { + PCI_LU_VENDEV, /* Vendor / device */ + PCI_LU_CLASSREV, /* Class / subclass */ +} lookup_type_t; + +/* + * Lookup a device on the PCI(e) bus by using the pci_descriptor + * as a lookup key. + * + * @lookup: Lookup descriptor that must match a device + * @type: Lookup type + */ +int pci_bus_lookup(struct pci_device *lookup, lookup_type_t type); + /* * Read from a specific register on a specific PCI * enabled device. -- cgit v1.2.3