summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c/src/lib/libbsp/i386/shared/pci/pcibios.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/c/src/lib/libbsp/i386/shared/pci/pcibios.c b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
index cdb8a6f2cb..c23d483dd8 100644
--- a/c/src/lib/libbsp/i386/shared/pci/pcibios.c
+++ b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
@@ -232,6 +232,8 @@ pci_bus_count(void)
if ( ucBusCount == 0xff ) {
unsigned char bus;
unsigned char dev;
+ unsigned char fun;
+ unsigned char nfn;
unsigned char hd = 0;
uint32_t d = 0;
int sig;
@@ -243,15 +245,29 @@ pci_bus_count(void)
sig = PCIB_DEVSIG_MAKE(bus,dev,0);
pcib_conf_read32(sig, PCI_VENDOR_ID, &d);
- if ( d != -1 ) {
- pcib_conf_read32(sig, PCI_CLASS_REVISION, &d);
+ if ( -1 == d ) {
+ continue;
+ }
+
+ pcib_conf_read8(sig, PCI_HEADER_TYPE, &hd);
+ nfn = (hd & 0x80) ? PCI_MAX_FUNCTIONS : 1;
+
+ for ( fun=0; fun<nfn; fun++ ) {
+
+ sig = PCIB_DEVSIG_MAKE(bus,dev,fun);
+ pcib_conf_read32(sig, PCI_VENDOR_ID, &d);
+ if ( -1 == d )
+ continue;
+
+ pcib_conf_read32(sig, PCI_CLASS_REVISION, &d);
+
+ if ( (d >> 16) == PCI_CLASS_BRIDGE_PCI ) {
+ pcib_conf_read8(sig, PCI_SUBORDINATE_BUS, &hd);
- if ( (d >> 16) == PCI_CLASS_BRIDGE_PCI ) {
- pcib_conf_read8(sig, PCI_SUBORDINATE_BUS, &hd);
+ if ( hd > ucBusCount )
+ ucBusCount = hd;
+ }
- if ( hd > ucBusCount )
- ucBusCount = hd;
- }
}
}
}