summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/pci_io.h
diff options
context:
space:
mode:
authorMichael Brown2022-09-15 17:47:04 +0200
committerMichael Brown2022-09-15 17:49:47 +0200
commitff228f745c15594291fd3cbf3c02af27753a3885 (patch)
tree20fcd06b1407db029e1969095c9f4a449451ba64 /src/include/ipxe/pci_io.h
parent[pci] Check for wraparound in callers of pci_find_next() (diff)
downloadipxe-ff228f745c15594291fd3cbf3c02af27753a3885.tar.gz
ipxe-ff228f745c15594291fd3cbf3c02af27753a3885.tar.xz
ipxe-ff228f745c15594291fd3cbf3c02af27753a3885.zip
[pci] Generalise pci_num_bus() to pci_discover()
Allow pci_find_next() to discover devices beyond the first PCI segment, by generalising pci_num_bus() (which implicitly assumes that there is only a single PCI segment) with pci_discover() (which has the ability to return an arbitrary contiguous chunk of PCI bus:dev.fn address space). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/pci_io.h')
-rw-r--r--src/include/ipxe/pci_io.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/include/ipxe/pci_io.h b/src/include/ipxe/pci_io.h
index 2dcdd9b28..91359cec8 100644
--- a/src/include/ipxe/pci_io.h
+++ b/src/include/ipxe/pci_io.h
@@ -14,6 +14,20 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/iomap.h>
#include <config/ioapi.h>
+struct pci_device;
+
+/** A PCI bus:dev.fn address range */
+struct pci_range {
+ /** Starting bus:dev.fn address */
+ uint32_t start;
+ /** Number of bus:dev.fn addresses within this range */
+ unsigned int count;
+};
+
+#define PCI_BUSDEVFN( segment, bus, slot, func ) \
+ ( ( (segment) << 16 ) | ( (bus) << 8 ) | \
+ ( (slot) << 3 ) | ( (func) << 0 ) )
+
/**
* Calculate static inline PCI I/O API function name
*
@@ -51,11 +65,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <bits/pci_io.h>
/**
- * Determine number of PCI buses within system
+ * Find next PCI bus:dev.fn address range in system
*
- * @ret num_bus Number of buses
+ * @v busdevfn Starting PCI bus:dev.fn address
+ * @v range PCI bus:dev.fn address range to fill in
*/
-int pci_num_bus ( void );
+void pci_discover ( uint32_t busdevfn, struct pci_range *range );
/**
* Read byte from PCI configuration space