/* * Scan all PCI buses, devices and device functions until * required device is found. Return base address of a first entry. */ u_int16_t pci_bus_locate(struct pci_dev_t *card) { struct pci_entry_t e; u_int32_t data; for (e.bus = 0; e.bus <= PCI_MAX_BUS; e.bus++) { for (e.dev = 0; e.dev <= PCI_MAX_DEV; e.dev++) { for (e.fun = 0; e.fun <= PCI_MAX_FUN; e.fun++) { if (pci_device_match(&e, card)) { data = pci_base_addr(&e); /* We don't need mem address */ if (PCI_BASEADDR_IO_TYPE & data) return PCI_BASEADDR(data); } } } } return 0u; }
struct acpi_drhd_u * matched_drhd_u(u8 bus, u8 devfn) { struct acpi_drhd_u *drhd; struct acpi_drhd_u *include_pci_all_drhd; include_pci_all_drhd = NULL; LIST_FOREACH(drhd_list, drhd) { if (drhd->include_pci_all) { include_pci_all_drhd = drhd; continue; } if (pci_device_match(drhd->devices, drhd->devices_cnt, bus, devfn)) { return drhd; } } if (include_pci_all_drhd) { return include_pci_all_drhd; } return NULL; }