From 54c9c5246e28a8a3d586a5f7346e38648ef2b3f9 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 9 Jul 2024 01:46:04 -0400 Subject: kernel: pci: Add PCI device lookups Signed-off-by: Ian Moffett --- sys/include/dev/pci/pci.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sys/include/dev') diff --git a/sys/include/dev/pci/pci.h b/sys/include/dev/pci/pci.h index 4e2ceec..3d37b05 100644 --- a/sys/include/dev/pci/pci.h +++ b/sys/include/dev/pci/pci.h @@ -33,8 +33,22 @@ #include #include +/* Lookup bits */ +#define PCI_DEVICE_ID BIT(0) +#define PCI_VENDOR_ID BIT(1) +#define PCI_CLASS BIT(2) +#define PCI_SUBCLASS BIT(3) + typedef uint32_t pcireg_t; +/* For PCI lookups */ +struct pci_lookup { + uint16_t device_id; + uint16_t vendor_id; + uint8_t pci_class; + uint8_t pci_subclass; +}; + struct pci_device { uint8_t bus; uint8_t slot; @@ -51,6 +65,8 @@ struct pci_device { }; pcireg_t pci_readl(struct pci_device *dev, uint32_t offset); +struct pci_device *pci_get_device(struct pci_lookup lookup, uint16_t lookup_type); + void pci_writel(struct pci_device *dev, uint32_t offset, pcireg_t val); int pci_init(void); -- cgit v1.2.3