mirror of
https://github.com/86Box/probing-tools.git
synced 2026-02-24 20:35:34 -07:00
clib: Generate dummy PCI bus numbers for 9x
This commit is contained in:
@@ -34,6 +34,7 @@ struct pci_access *pacc;
|
||||
static struct pci_dev *pdev = NULL;
|
||||
# if defined(_WIN32) && (PCI_LIB_VERSION >= 0x030800)
|
||||
# define DUMMY_CONFIG_SPACE
|
||||
static struct pci_dev *dummy_buses[256] = {0};
|
||||
static const char win_notice[] = "NOTICE: These are dummy configuration registers generated by libpci, as it cannot access the real ones under Windows. It does not reflect the device's actual configuration.";
|
||||
# endif
|
||||
#endif
|
||||
@@ -139,6 +140,7 @@ static void
|
||||
pci_init_dev(uint8_t bus, uint8_t dev, uint8_t func)
|
||||
{
|
||||
struct pci_dev *other;
|
||||
int i;
|
||||
if (!pdev || (pdev->bus != bus) || (pdev->dev != dev) || (pdev->func != func)) {
|
||||
if (!pacc->devices) {
|
||||
libpci_scan_bus(pacc);
|
||||
@@ -170,6 +172,24 @@ pci_init_dev(uint8_t bus, uint8_t dev, uint8_t func)
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate dummy bus numbers for 9x where the actual number cannot be obtained from cfgmgr32. */
|
||||
if (pdev->parent) {
|
||||
if (!pdev->bus) {
|
||||
for (i = 1; i < (sizeof(dummy_buses) / sizeof(dummy_buses[0])); i++) {
|
||||
if (dummy_buses[i] == pdev->parent) /* found bus */
|
||||
break;
|
||||
if (!dummy_buses[i]) { /* create new bus here */
|
||||
dummy_buses[i] = pdev->parent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pdev->bus = i;
|
||||
} else {
|
||||
/* Flag this bus as taken, in the unlikely case that not all bus number lookups fail. */
|
||||
dummy_buses[i] = pdev->parent;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set secondary bus number and cascade subordinate bus number to parents. */
|
||||
other = pdev;
|
||||
while (other->parent) {
|
||||
|
||||
Reference in New Issue
Block a user