diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index 15d2da088..9e47dd93c 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -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 * diff --git a/src/include/ipxe/pci.h b/src/include/ipxe/pci.h index 44095afe2..f65c8c296 100644 --- a/src/include/ipxe/pci.h +++ b/src/include/ipxe/pci.h @@ -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,