diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-20 15:36:43 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-20 15:36:43 -0400 |
commit | 4d34c53e0691888632a64c89ce2024a7d4134a12 (patch) | |
tree | fd73029163b3fb99ae6e6e26b8dfa56ed874d548 /src/sys/io/pci/pci.c | |
parent | 1a6c982dc7aebbd14b7966170c3847c1792991db (diff) |
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 <ian@osmora.org>
Diffstat (limited to 'src/sys/io/pci/pci.c')
-rw-r--r-- | src/sys/io/pci/pci.c | 8 |
1 files changed, 8 insertions, 0 deletions
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. |