aboutsummaryrefslogtreecommitdiff
path: root/src/pcibios.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-12-04 19:39:10 -0500
committerKevin O'Connor <kevin@koconnor.net>2008-12-04 19:39:10 -0500
commit4132e0213ea9b168dd619ca76f1f1bf075d1f4a4 (patch)
tree3ee2afa254ea118a40b68e0978ee4ff05a091083 /src/pcibios.c
parent53ab0b600cc7cd14403a9d8feafb1bd1a81e56eb (diff)
downloadseabios-hppa-4132e0213ea9b168dd619ca76f1f1bf075d1f4a4.zip
seabios-hppa-4132e0213ea9b168dd619ca76f1f1bf075d1f4a4.tar.gz
seabios-hppa-4132e0213ea9b168dd619ca76f1f1bf075d1f4a4.tar.bz2
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.
Diffstat (limited to 'src/pcibios.c')
-rw-r--r--src/pcibios.c51
1 files changed, 28 insertions, 23 deletions
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