Support multiple independent root buses (if known at compile time).
authorKevin O'Connor <kevin@koconnor.net>
Sat, 28 Feb 2009 17:26:39 +0000 (12:26 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 28 Feb 2009 17:26:39 +0000 (12:26 -0500)
Allow extra root buses to be specified in src/config.h.
This is based on a patch by Myles Watson.

src/config.h
src/pci.c

index 13b847261134f4da60c6bf0a54fd8175109912c3..56e5302652b1fdc64f46647fd6d4810e735a0ddc 100644 (file)
 #define CONFIG_KBD_CALL_INT15_4F 1
 // Support for int15c2 mouse calls
 #define CONFIG_PS2_MOUSE 1
+// If the target machine has multiple independent root buses, the
+// extra buses may be specified here.
+#define CONFIG_PCI_ROOT1 0x00
+#define CONFIG_PCI_ROOT2 0x00
 // Support finding and running option roms during post.
 #define CONFIG_OPTIONROMS 1
 // Set if option roms are already copied to 0xc0000-0xf0000
index a59af0742f0d6336a7885a4004f07f0dd2dc9075..349c8cd734abade65f4b1aeca02c25961ace287d 100644 (file)
--- a/src/pci.c
+++ b/src/pci.c
@@ -10,7 +10,6 @@
 #include "util.h" // dprintf
 #include "config.h" // CONFIG_*
 #include "pci_regs.h" // PCI_VENDOR_ID
-#include "farptr.h" // SET_VAR
 
 void pci_config_writel(u16 bdf, u32 addr, u32 val)
 {
@@ -59,8 +58,15 @@ pci_next(int bdf, int *pmax)
 
     int max = *pmax;
     for (;;) {
-        if (bdf >= max)
-            return -1;
+        if (bdf >= max) {
+            if (CONFIG_PCI_ROOT1 && bdf <= (CONFIG_PCI_ROOT1 << 8))
+                bdf = CONFIG_PCI_ROOT1 << 8;
+            else if (CONFIG_PCI_ROOT2 && bdf <= (CONFIG_PCI_ROOT2 << 8))
+                bdf = CONFIG_PCI_ROOT2 << 8;
+            else
+               return -1;
+            *pmax = max = bdf + 0x0100;
+        }
 
         u16 v = pci_config_readw(bdf, PCI_VENDOR_ID);
         if (v != 0x0000 && v != 0xffff)