Probe PCI existence
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 21 Sep 2011 06:16:21 +0000 (08:16 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 1 Oct 2011 14:53:39 +0000 (10:53 -0400)
This prevents lockups when trying to allocate PCI resources on an
ISA-only system like QEMU can emulate.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
src/pci.c
src/pci.h
src/pciinit.c

index 49698ac58b8d0a7481007d9e42021d9c4336155b..6031c9ffe400c5d9ed737f344612f177091e394e 100644 (file)
--- a/src/pci.c
+++ b/src/pci.c
@@ -88,9 +88,21 @@ 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");
     struct pci_device *busdevs[256];
index 3e28af29e40583d435c39ee29cafa472826afb55..a2a5a4c71f23cf25fa03928511a2cefec6298320 100644 (file)
--- a/src/pci.h
+++ b/src/pci.h
@@ -62,7 +62,8 @@ struct pci_device {
 };
 extern struct pci_device *PCIDevices;
 extern int MaxPCIBus;
-void pci_probe(void);
+int pci_probe_host(void);
+void pci_probe_devices(void);
 static inline u32 pci_classprog(struct pci_device *pci) {
     return (pci->class << 8) | pci->prog_if;
 }
index 597c8ea78173000435df7afd12754ce27e02b1f9..a857da06969b0a0cc362cc7192c28ae1c9d85c65 100644 (file)
@@ -577,7 +577,7 @@ pci_setup(void)
 {
     if (CONFIG_COREBOOT || usingXen()) {
         // PCI setup already done by coreboot or Xen - just do probe.
-        pci_probe();
+        pci_probe_devices();
         return;
     }
 
@@ -587,10 +587,13 @@ pci_setup(void)
     u32 end   = BUILD_PCIMEM_END;
 
     dprintf(1, "=== PCI bus & bridge init ===\n");
+    if (pci_probe_host() != 0) {
+        return;
+    }
     pci_bios_init_bus();
 
     dprintf(1, "=== PCI device probing ===\n");
-    pci_probe();
+    pci_probe_devices();
 
     dprintf(1, "=== PCI new allocation pass #1 ===\n");
     busses = malloc_tmp(sizeof(*busses) * busses_count);