Return max bus number in int 1a/b101 call.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 17 Aug 2008 15:08:46 +0000 (11:08 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 17 Aug 2008 15:08:46 +0000 (11:08 -0400)
Add new option CONFIG_PCI_BUS_COUNT to set max bus count.
Use that option consistently in handle_1ab101() and pci.c.
Also, clean up comments of handle_1ab101().

src/config.h
src/pci.c
src/pcibios.c

index f877101d4732dea30e017eb5df11845e5af1c58c..ba63b7e1fefcea1894ed50f7435944fcb5b1f3f8 100644 (file)
@@ -35,6 +35,8 @@
 #define CONFIG_CDROM_EMU 1
 // Support int 1a/b1 PCI BIOS calls
 #define CONFIG_PCIBIOS 1
+// Maximum number of PCI busses.
+#define CONFIG_PCI_BUS_COUNT 2
 // Support int 15/53 APM BIOS calls
 #define CONFIG_APMBIOS 1
 // Support int 19/18 system bootup support
index efcab46e545aaeb43092e740705d18d90b440272..7ed83008317f4fc023fef97561243cb631d1670d 100644 (file)
--- a/src/pci.c
+++ b/src/pci.c
@@ -8,8 +8,7 @@
 #include "pci.h" // PCIDevice
 #include "ioport.h" // outl
 #include "util.h" // dprintf
-
-#define MAX_BUS 1
+#include "config.h" // CONFIG_*
 
 void pci_config_writel(PCIDevice d, u32 addr, u32 val)
 {
@@ -58,7 +57,7 @@ pci_find_device(u16 vendid, u16 devid, int index, PCIDevice *dev)
 {
     int devfn, bus;
     u32 id = (devid << 16) | vendid;
-    for (bus=0; bus < MAX_BUS; bus++) {
+    for (bus=0; bus < CONFIG_PCI_BUS_COUNT; bus++) {
         for (devfn=0; devfn<0x100; devfn++) {
             PCIDevice d = pci_bd(bus, devfn);
             u32 v = pci_config_readl(d, 0x00);
@@ -80,7 +79,7 @@ int
 pci_find_class(u32 classid, int index, PCIDevice *dev)
 {
     int devfn, bus;
-    for (bus=0; bus < MAX_BUS; bus++) {
+    for (bus=0; bus < CONFIG_PCI_BUS_COUNT; bus++) {
         for (devfn=0; devfn<0x100; devfn++) {
             PCIDevice d = pci_bd(bus, devfn);
             u32 v = pci_config_readl(d, 0x08);
index 545ad8dd59817743131028fbdf6a4e39d4ee753c..3823c2ebedbb11c1062981ce13cccb065ce1e428 100644 (file)
 static void
 handle_1ab101(struct bregs *regs)
 {
-    regs->ax = 0x0001;
-    regs->bx = 0x0210;
-    regs->cx = 0;
-    // XXX - regs->cl should equal max bus number.
+    regs->al = 0x01; // Flags - "Config Mechanism #1" supported.
+    regs->bx = 0x0210; // PCI version 2.10
+    regs->cl = CONFIG_PCI_BUS_COUNT - 1;
     regs->edx = 0x20494350; // "PCI "
     // XXX - bochs bios code sets edi to point to 32bit code - but no
     // reference to this in spec.
-    set_success(regs);
+    set_code_success(regs);
 }
 
 // find pci device