aboutsummaryrefslogtreecommitdiff
path: root/sys/include/dev/pci
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-05-07 19:15:26 -0400
committerIan Moffett <ian@osmora.org>2024-05-07 19:17:11 -0400
commit139d593640cf8e7cc666818a29a689d5def541ef (patch)
tree9a9fafab290a7c4b8507b63fc928d1fe7b7befdc /sys/include/dev/pci
parent293cb0eab638c682e951e68c404dc214772539c2 (diff)
kernel: pci: Add macros for fetching BAR base
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/include/dev/pci')
-rw-r--r--sys/include/dev/pci/pci.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/include/dev/pci/pci.h b/sys/include/dev/pci/pci.h
index 66ecb91..ad3f7ac 100644
--- a/sys/include/dev/pci/pci.h
+++ b/sys/include/dev/pci/pci.h
@@ -34,6 +34,7 @@
#include <sys/queue.h>
#include <sys/cdefs.h>
#include <dev/pci/pciregs.h>
+#include <vm/vm.h>
/* Lookup bits */
#define PCI_DEVICE_ID __BIT(0)
@@ -41,6 +42,14 @@
#define PCI_CLASS __BIT(2)
#define PCI_SUBCLASS __BIT(3)
+/* Base address masks for BARs */
+#define PCI_BAR_MEMMASK ~7
+#define PCI_BAR_IOMASK ~3
+
+/* Macros to fetch base address from BAR */
+#define PCI_BAR_MEMBASE(BAR) PHYS_TO_VIRT(BAR & PCI_BAR_MEMMASK)
+#define PCI_BAR_IOBASE(BAR) PHYS_TO_VIRT(BAR & PCI_BAR_IOMASK)
+
/* For PCI lookups */
struct pci_lookup {
uint16_t device_id;