aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2010-06-22 17:57:46 +0900
committerKevin O'Connor <kevin@koconnor.net>2010-07-04 08:51:39 -0400
commitedd99116920fa870191d2e99877ec527a0c6bb14 (patch)
treeb674a935b277fbdea3da662ebe2e559a99f15fb3
parentf79a462e521b622694c5e2e474008a43de690d7d (diff)
downloadseabios-edd99116920fa870191d2e99877ec527a0c6bb14.tar.gz
seabios: pci: introduce foreachpci_in_bus() helper macro.
This patch introduces foreachpci_in_bus() helper macro for depth first recursion. foreachpci() is for width first recursion. The macro will be used later to initialize pci bridge that requires depth first recursion. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
-rw-r--r--src/pci.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pci.h b/src/pci.h
index 8a21c06b..e40e1169 100644
--- a/src/pci.h
+++ b/src/pci.h
@@ -21,6 +21,9 @@ static inline u8 pci_bdf_to_fn(u16 bdf) {
static inline u16 pci_to_bdf(int bus, int dev, int fn) {
return (bus<<8) | (dev<<3) | fn;
}
+static inline u16 pci_bus_devfn_to_bdf(int bus, u16 devfn) {
+ return (bus << 8) | devfn;
+}
static inline u32 pci_vd(u16 vendor, u16 device) {
return (device << 16) | vendor;
@@ -50,6 +53,13 @@ int pci_next(int bdf, int *pmax);
; BDF >= 0 \
; BDF=pci_next(BDF+1, &MAX))
+#define foreachpci_in_bus(BDF, MAX, BUS) \
+ for (MAX = pci_bus_devfn_to_bdf(BUS, 0) + 0x0100, \
+ BDF = pci_next(pci_bus_devfn_to_bdf(BUS, 0), &MAX) \
+ ; BDF >= 0 && BDF < pci_bus_devfn_to_bdf(BUS, 0) + 0x0100 \
+ ; MAX = pci_bus_devfn_to_bdf(BUS, 0) + 0x0100, \
+ BDF = pci_next(BDF + 1, &MAX))
+
// pirtable.c
void create_pirtable(void);