vgabios: Add scrolling for linear (packed pixel) graphics mode.
[seabios.git] / src / pci.c
index 0de8ec5feeac4b2bc463f7b2d6bc27b5de02d7c7..6031c9ffe400c5d9ed737f344612f177091e394e 100644 (file)
--- a/src/pci.c
+++ b/src/pci.c
@@ -8,8 +8,8 @@
 #include "pci.h" // pci_config_writel
 #include "ioport.h" // outl
 #include "util.h" // dprintf
-#include "config.h" // CONFIG_*
-#include "farptr.h" // CONFIG_*
+#include "paravirt.h" // romfile_loadint
+#include "farptr.h" // MAKE_FLATPTR
 #include "pci_regs.h" // PCI_VENDOR_ID
 #include "pci_ids.h" // PCI_CLASS_DISPLAY_VGA
 
@@ -88,21 +88,29 @@ pci_next(int bdf, int bus)
 struct pci_device *PCIDevices;
 int MaxPCIBus VAR16VISIBLE;
 
+// Check if PCI is available at all
+int
+pci_probe_host(void)
+{
+    outl(0x80000000, PORT_PCI_CMD);
+    if (inl(PORT_PCI_CMD) != 0x80000000) {
+        dprintf(1, "Detected non-PCI system\n");
+        return -1;
+    }
+    return 0;
+}
+
 // Find all PCI devices and populate PCIDevices linked list.
 void
-pci_probe(void)
+pci_probe_devices(void)
 {
     dprintf(3, "PCI probe\n");
-    if (CONFIG_PCI_ROOT1 && CONFIG_PCI_ROOT1 > MaxPCIBus)
-        MaxPCIBus = CONFIG_PCI_ROOT1;
-    if (CONFIG_PCI_ROOT2 && CONFIG_PCI_ROOT2 > MaxPCIBus)
-        MaxPCIBus = CONFIG_PCI_ROOT2;
-
     struct pci_device *busdevs[256];
     memset(busdevs, 0, sizeof(busdevs));
     struct pci_device **pprev = &PCIDevices;
+    int extraroots = romfile_loadint("etc/extra-pci-roots", 0);
     int bus = -1, lastbus = 0, rootbuses = 0, count=0;
-    while (bus < MaxPCIBus) {
+    while (bus < 0xff && (bus < MaxPCIBus || rootbuses < extraroots)) {
         bus++;
         int bdf;
         foreachbdf(bdf, bus) {
@@ -125,6 +133,8 @@ pci_probe(void)
                     rootbuses++;
                 lastbus = bus;
                 rootbus = rootbuses;
+                if (bus > MaxPCIBus)
+                    MaxPCIBus = bus;
             } else {
                 rootbus = parent->rootbus;
             }