Just set a global variable in the first chipset detection function (pci_bios_init_platform) and use them later on.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/acpi.c | 39 ++++++++++----------------------------- src/pci.h | 2 ++ src/pciinit.c | 7 +++++++ 3 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/src/acpi.c b/src/acpi.c index 72c8fe8..350b55b 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -236,10 +236,8 @@ build_header(struct acpi_table_header *h, u32 sig, int len, u8 rev)
#define PIIX4_PM_INTRRUPT 9 // irq 9
-static void piix4_fadt_init(struct pci_device *pci, void *arg) +static void piix4_fadt_init(struct fadt_descriptor_rev1 *fadt) { - struct fadt_descriptor_rev1 *fadt = arg; - fadt->model = 1; fadt->reserved1 = 0; fadt->sci_int = cpu_to_le16(PIIX4_PM_INTRRUPT); @@ -262,10 +260,8 @@ static void piix4_fadt_init(struct pci_device *pci, void *arg) }
/* PCI_VENDOR_ID_INTEL && PCI_DEVICE_ID_INTEL_ICH9_LPC */ -void ich9_lpc_fadt_init(struct pci_device *dev, void *arg) +void ich9_lpc_fadt_init(struct fadt_descriptor_rev1 *fadt) { - struct fadt_descriptor_rev1 *fadt = arg; - fadt->model = 1; fadt->reserved1 = 0; fadt->sci_int = cpu_to_le16(9); @@ -287,15 +283,6 @@ void ich9_lpc_fadt_init(struct pci_device *dev, void *arg) (1 << 7)); }
-static const struct pci_device_id fadt_init_tbl[] = { - /* PIIX4 Power Management device (for ACPI) */ - PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, - piix4_fadt_init), - PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_LPC, - ich9_lpc_fadt_init), - PCI_DEVICE_END -}; - static void fill_dsdt(struct fadt_descriptor_rev1 *fadt, void *dsdt) { if (fadt->dsdt) { @@ -307,7 +294,7 @@ static void fill_dsdt(struct fadt_descriptor_rev1 *fadt, void *dsdt) }
static void * -build_fadt(struct pci_device *pci) +build_fadt(void) { struct fadt_descriptor_rev1 *fadt = malloc_high(sizeof(*fadt)); struct facs_descriptor_rev1 *facs = memalign_high(64, sizeof(*facs)); @@ -327,7 +314,10 @@ build_fadt(struct pci_device *pci) fadt->firmware_ctrl = cpu_to_le32((u32)facs); fadt->dsdt = 0; /* dsdt will be filled later in acpi_bios_init() by fill_dsdt() */ - pci_init_device(fadt_init_tbl, pci, fadt); + if (have_piix4) + piix4_fadt_init(fadt); + if (have_ich9) + ich9_lpc_fadt_init(fadt);
build_header((void*)fadt, FACP_SIGNATURE, sizeof(*fadt), 1);
@@ -764,13 +754,6 @@ build_srat(void) return srat; }
-static const struct pci_device_id acpi_find_tbl[] = { - /* PIIX4 Power Management device. */ - PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL), - PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_LPC, NULL), - PCI_DEVICE_END, -}; - struct rsdp_descriptor *RsdpAddr;
#define MAX_ACPI_TABLES 20 @@ -782,10 +765,8 @@ acpi_bios_init(void)
dprintf(3, "init ACPI tables\n");
- // This code is hardcoded for PIIX4 Power Management device. - struct pci_device *pci = pci_find_init_device(acpi_find_tbl, NULL); - if (!pci) - // Device not found + // This code is hardcoded for PIIX4/ICH9 Power Management device. + if (!have_piix4 && !have_ich9) return;
// Build ACPI tables @@ -798,7 +779,7 @@ acpi_bios_init(void) tbl_idx++; \ } while(0)
- struct fadt_descriptor_rev1 *fadt = build_fadt(pci); + struct fadt_descriptor_rev1 *fadt = build_fadt(); ACPI_INIT_TABLE(fadt); ACPI_INIT_TABLE(build_ssdt()); ACPI_INIT_TABLE(build_madt()); diff --git a/src/pci.h b/src/pci.h index 104638d..1ffd7f1 100644 --- a/src/pci.h +++ b/src/pci.h @@ -56,6 +56,8 @@ struct pci_device { // Local information on device. int have_driver; }; +extern u32 have_piix4; +extern u32 have_ich9; extern u64 mtrr_base; extern u64 pcimem_start, pcimem_end; extern u64 pcimem64_start, pcimem64_end; diff --git a/src/pciinit.c b/src/pciinit.c index 5bec062..3ab369f 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -42,6 +42,9 @@ u64 pcimem_end = BUILD_PCIMEM_END; u64 pcimem64_start = BUILD_PCIMEM64_START; u64 pcimem64_end = BUILD_PCIMEM64_END;
+u32 have_piix4 = 0; +u32 have_ich9 = 0; + struct pci_region_entry { struct pci_device *dev; int bar; @@ -292,6 +295,8 @@ static void pci_bios_init_devices(void)
void i440fx_mem_addr_init(struct pci_device *dev, void *arg) { + have_piix4 = 1; + if (RamSize <= 0x80000000) pcimem_start = 0x80000000; else if (RamSize <= 0xc0000000) @@ -300,6 +305,8 @@ void i440fx_mem_addr_init(struct pci_device *dev, void *arg)
void mch_mem_addr_init(struct pci_device *dev, void *arg) { + have_ich9 = 1; + u64 addr = Q35_HOST_BRIDGE_PCIEXBAR_ADDR; u32 size = Q35_HOST_BRIDGE_PCIEXBAR_SIZE;