From 4132e0213ea9b168dd619ca76f1f1bf075d1f4a4 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 4 Dec 2008 19:39:10 -0500 Subject: Don't allow start_bdf with new auto max bus detection code. It's not valid to set a "start bdf" when search for a device now, because we wont be able to properly detect the maximum bus unless we start at the beginning. Change callers that need to resume a search to use foreachpci() macro. Update all callers so that they don't pass in the now unused start_bdf. --- src/pcibios.c | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'src/pcibios.c') diff --git a/src/pcibios.c b/src/pcibios.c index 93cdc46..e310b18 100644 --- a/src/pcibios.c +++ b/src/pcibios.c @@ -10,6 +10,7 @@ #include "pci.h" // pci_config_readl #include "bregs.h" // struct bregs #include "biosvar.h" // GET_EBDA +#include "pci_regs.h" // PCI_VENDOR_ID #define RET_FUNC_NOT_SUPPORTED 0x81 #define RET_BAD_VENDOR_ID 0x83 @@ -22,7 +23,7 @@ handle_1ab101(struct bregs *regs) { // Find max bus. int bdf, max; - foreachpci(bdf, max, 0) { + foreachpci(bdf, max) { } regs->al = 0x01; // Flags - "Config Mechanism #1" supported. @@ -38,36 +39,40 @@ handle_1ab101(struct bregs *regs) static void handle_1ab102(struct bregs *regs) { - int bdf = -1; + u32 id = (regs->cx << 16) | regs->dx; int count = regs->si; - do { - bdf = pci_find_device(regs->dx, regs->cx, bdf+1); - if (bdf < 0) { - set_code_fail(regs, RET_DEVICE_NOT_FOUND); - return; - } - } while (count--); - - regs->bx = bdf; - set_code_success(regs); + int bdf, max; + foreachpci(bdf, max) { + u32 v = pci_config_readl(bdf, PCI_VENDOR_ID); + if (v != id) + continue; + if (count--) + continue; + regs->bx = bdf; + set_code_success(regs); + return; + } + set_code_fail(regs, RET_DEVICE_NOT_FOUND); } // find class code static void handle_1ab103(struct bregs *regs) { - int bdf = -1; int count = regs->si; - do { - bdf = pci_find_classprog(regs->ecx, bdf+1); - if (bdf < 0) { - set_code_fail(regs, RET_DEVICE_NOT_FOUND); - return; - } - } while (count--); - - regs->bx = bdf; - set_code_success(regs); + u32 classprog = regs->ecx; + int bdf, max; + foreachpci(bdf, max) { + u32 v = pci_config_readl(bdf, PCI_CLASS_REVISION); + if ((v>>8) != classprog) + continue; + if (count--) + continue; + regs->bx = bdf; + set_code_success(regs); + return; + } + set_code_fail(regs, RET_DEVICE_NOT_FOUND); } // read configuration byte -- cgit v1.1