From 214eadc62b5578f76c98a38a28f8b3d80ac4d6ad Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 3 Jun 2024 20:36:18 -0400 Subject: kernel: pci: Require mapping BAR using bus_map() This commit gets rid of pci_map_bar() as some devices have their base address spanning mulitple BARs. This change also exposes PCI bar size logic through pci_bar_size() Signed-off-by: Ian Moffett --- sys/dev/pci/pci.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 3be61d9..9a8eae4 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -205,21 +205,21 @@ pci_get_barreg(struct pci_device *dev, uint8_t bar) } /* - * Map a PCI(e) BAR into kernel memory. + * Get size length of memory region that a PCI(e) BAR + * covers. A returned value of zero is invalid and indicates + * an error. * - * @dev: Device of BAR to map. - * @bar: BAR number to map. - * @vap: Resulting virtual address. + * @dev: Device of BAR to get. + * @bar: BAR number. */ -int -pci_map_bar(struct pci_device *dev, uint8_t bar, void **vap) +uint32_t +pci_bar_size(struct pci_device *dev, uint8_t bar) { uint8_t bar_reg = pci_get_barreg(dev, bar); - uintptr_t tmp; - uint32_t size; + uint32_t tmp, size; if (bar_reg == 0) { - return -EINVAL; + return 0; } /* @@ -235,9 +235,7 @@ pci_map_bar(struct pci_device *dev, uint8_t bar, void **vap) /* Now we need to restore the previous value */ pci_writel(dev, bar_reg, tmp); - - /* Now do the actual mapping work */ - return bus_map(dev->bar[bar], size, 0, vap); + return size; } /* -- cgit v1.2.3