summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2018-11-10 06:48:42 -0500
committerDamien Zammit <damien@zamaudio.com>2018-11-10 06:59:47 -0500
commit7e63d79813e0318f0a31c7523568fdedf121ff2c (patch)
treef649806b014b4f6b835c98f11f7520544a4adad3
parent7359070eaab6af1de77a919ca50a93a5f25b3854 (diff)
Use recursive scan bushurd-upstream-bak
Switch over to the new recursive scan bus routine for x86
-rw-r--r--src/x86_pci.c53
1 files changed, 9 insertions, 44 deletions
diff --git a/src/x86_pci.c b/src/x86_pci.c
index 447ca5c..786ee3c 100644
--- a/src/x86_pci.c
+++ b/src/x86_pci.c
@@ -1131,11 +1131,6 @@ static int pci_probe(void)
_pci_hidden int
pci_system_x86_create(void)
{
- uint8_t nfuncs = 0;
- uint8_t bus, dev, func;
- uint32_t reg = 0;
- struct pci_device tmpdev = { 0 };
- struct pci_device_private *device;
error_t err;
int confx;
@@ -1163,45 +1158,15 @@ pci_system_x86_create(void)
else
pci_sys->methods = &x86_pci_method_conf2;
- device = pci_sys->devices;
- for (bus = 0; bus < 256; bus++) {
- tmpdev.bus = bus;
- for (dev = 0; dev < 32; dev++) {
- tmpdev.dev = dev;
- err = pci_nfuncs(&tmpdev, &nfuncs);
- if (err) {
- x86_disable_io ();
- free (pci_sys);
- pci_sys = NULL;
- return ENODEV;
- }
- for (func = 0; func < nfuncs; func++) {
- tmpdev.func = func;
- if (pci_device_cfg_read_u32(&tmpdev, &reg, PCI_VENDOR_ID))
- continue;
- if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID ||
- PCI_VENDOR(reg) == 0)
- continue;
- device->base.domain = device->base.domain_16 = 0;
- device->base.bus = bus;
- device->base.dev = dev;
- device->base.func = func;
- device->base.vendor_id = PCI_VENDOR(reg);
- device->base.device_id = PCI_DEVICE(reg);
-
- if (pci_device_cfg_read_u32(&tmpdev, &reg, PCI_CLASS))
- continue;
- device->base.device_class = (reg >> 8) & 0xFF;
- device->base.revision = reg & 0xFF;
-
- if (pci_device_cfg_read_u32(&tmpdev, &reg, PCI_SUB_VENDOR_ID))
- continue;
- device->base.subvendor_id = PCI_VENDOR(reg);
- device->base.subdevice_id = PCI_DEVICE(reg);
-
- device++;
- }
- }
+ /* Recursive scan */
+ pci_sys->num_devices = 0;
+ err = pci_system_x86_scan_bus (0);
+ if (err)
+ {
+ x86_disable_io ();
+ free (pci_sys);
+ pci_sys = NULL;
+ return err;
}
return 0;