]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[pci] Provide pci_bar_is_io() to determine BAR type
authorMichael Brown <mcb30@ipxe.org>
Tue, 12 May 2026 17:33:39 +0000 (18:33 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 12 May 2026 19:50:18 +0000 (20:50 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/bus/pci.c
src/include/ipxe/pci.h

index 15d2da0888c1f76811ac017a7159eff80030ead0..9e47dd93ca2dd4e51a8bb13a64013894181887f1 100644 (file)
@@ -80,6 +80,20 @@ static unsigned long pci_bar ( struct pci_device *pci, unsigned int reg ) {
        return low;
 }
 
+/**
+ * Get PCI BAR type
+ *
+ * @v pci              PCI device
+ * @v reg              PCI register number
+ * @v is_io            BAR is an I/O BAR
+ */
+int pci_bar_is_io ( struct pci_device *pci, unsigned int reg ) {
+       unsigned long bar;
+
+       bar = pci_bar ( pci, reg );
+       return ( bar & PCI_BASE_ADDRESS_SPACE_IO );
+}
+
 /**
  * Find the start of a PCI BAR
  *
index 44095afe2d504a98b2a3bd4ecf30ca6cc7b1fb10..f65c8c2969be5315f8f4051a33a19febf1a9e2fd 100644 (file)
@@ -317,6 +317,7 @@ struct pci_driver {
        PCI_SLOT ( (pci)->busdevfn ), PCI_FUNC ( (pci)->busdevfn )
 
 extern void adjust_pci_device ( struct pci_device *pci );
+extern int pci_bar_is_io ( struct pci_device *pci, unsigned int reg );
 extern unsigned long pci_bar_start ( struct pci_device *pci,
                                     unsigned int reg );
 extern void pci_bar_set ( struct pci_device *pci, unsigned int reg,