#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
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) {
rootbuses++;
lastbus = bus;
rootbus = rootbuses;
+ if (bus > MaxPCIBus)
+ MaxPCIBus = bus;
} else {
rootbus = parent->rootbus;
}