From 4d34c53e0691888632a64c89ce2024a7d4134a12 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 20 Sep 2025 15:36:43 -0400 Subject: kern: pci: Handle base address registers (BARs) This commit handles base address registers by storing them in a bar array within the PCI device structure. We also introduced a helper header to perform operations with BARs such as getting the length of their underlying region Signed-off-by: Ian Moffett --- src/sys/io/pci/pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/sys/io') diff --git a/src/sys/io/pci/pci.c b/src/sys/io/pci/pci.c index af5c113..b785764 100644 --- a/src/sys/io/pci/pci.c +++ b/src/sys/io/pci/pci.c @@ -142,6 +142,14 @@ pci_register_dev(struct pci_device *dev) dev->class = class; dev->subclass = subclass; + /* Set up base address registers */ + dev->bar[0] = pci_readl(dev, PCIREG_BAR0); + dev->bar[1] = pci_readl(dev, PCIREG_BAR1); + dev->bar[2] = pci_readl(dev, PCIREG_BAR2); + dev->bar[3] = pci_readl(dev, PCIREG_BAR3); + dev->bar[4] = pci_readl(dev, PCIREG_BAR4); + dev->bar[5] = pci_readl(dev, PCIREG_BAR5); + /* * Log out the BDF notation as well as vendor, * and logical slot ID. -- cgit v1.2.3