Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/acpi.c | 24 +++++++++++++----------- src/paravirt.c | 52 +++++++++++++++++++++++++--------------------------- src/paravirt.h | 3 --- 3 files changed, 38 insertions(+), 41 deletions(-)
diff --git a/src/acpi.c b/src/acpi.c index c4479d9..5396ae2 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -828,23 +828,25 @@ acpi_setup(void) if (pci->device == PCI_DEVICE_ID_INTEL_ICH9_LPC) ACPI_INIT_TABLE(build_mcfg_q35());
- u16 i, external_tables = qemu_cfg_acpi_additional_tables(); - - for (i = 0; i < external_tables; i++) { - u16 len = qemu_cfg_next_acpi_table_len(); - void *addr = malloc_high(len); - if (!addr) { + struct romfile_s *file = NULL; + for (;;) { + file = romfile_findprefix("acpi/", file); + if (!file) + break; + struct acpi_table_header *table = malloc_high(file->size); + if (!table) { warn_noalloc(); continue; } - struct acpi_table_header *header = - qemu_cfg_next_acpi_table_load(addr, len); - if (header->signature == DSDT_SIGNATURE) { + int ret = file->copy(file, table, file->size); + if (ret <= sizeof(*table)) + continue; + if (table->signature == DSDT_SIGNATURE) { if (fadt) { - fill_dsdt(fadt, addr); + fill_dsdt(fadt, table); } } else { - ACPI_INIT_TABLE(header); + ACPI_INIT_TABLE(table); } if (tbl_idx == MAX_ACPI_TABLES) { warn_noalloc(); diff --git a/src/paravirt.c b/src/paravirt.c index 0d1fb35..f17930f 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -203,33 +203,6 @@ int qemu_cfg_irq0_override(void) return v; }
-u16 qemu_cfg_acpi_additional_tables(void) -{ - u16 cnt; - - if (!qemu_cfg_present) - return 0; - - qemu_cfg_read_entry(&cnt, QEMU_CFG_ACPI_TABLES, sizeof(cnt)); - - return cnt; -} - -u16 qemu_cfg_next_acpi_table_len(void) -{ - u16 len; - - qemu_cfg_read((u8*)&len, sizeof(len)); - - return len; -} - -void* qemu_cfg_next_acpi_table_load(void *addr, u16 len) -{ - qemu_cfg_read(addr, len); - return addr; -} - u16 qemu_cfg_smbios_entries(void) { u16 cnt; @@ -444,6 +417,27 @@ qemu_romfile_add(char *name, int select, int skip, int size) romfile_add(file); }
+// Populate romfile entries for legacy fw_cfg ports (that predate the +// "file" interface). +static void +qemu_cfg_legacy(void) +{ + // ACPI tables + char name[128]; + u16 cnt; + qemu_cfg_read_entry(&cnt, QEMU_CFG_ACPI_TABLES, sizeof(cnt)); + int i, offset = sizeof(cnt); + for (i = 0; i < cnt; i++) { + u16 len; + qemu_cfg_read(&len, sizeof(len)); + offset += sizeof(len); + snprintf(name, sizeof(name), "acpi/table%d", i); + qemu_romfile_add(name, QEMU_CFG_ACPI_TABLES, offset, len); + qemu_cfg_skip(len); + offset += len; + } +} + struct QemuCfgFile { u32 size; /* file size */ u16 select; /* write this to 0x510 to read it */ @@ -456,6 +450,10 @@ void qemu_romfile_init(void) if (!CONFIG_QEMU || !qemu_cfg_present) return;
+ // Populate romfiles for legacy fw_cfg entries + qemu_cfg_legacy(); + + // Load files found in the fw_cfg file directory u32 count; qemu_cfg_read_entry(&count, QEMU_CFG_FILE_DIR, sizeof(count)); count = be32_to_cpu(count); diff --git a/src/paravirt.h b/src/paravirt.h index a3da04d..6836290 100644 --- a/src/paravirt.h +++ b/src/paravirt.h @@ -29,9 +29,6 @@ void qemu_cfg_preinit(void); int qemu_cfg_show_boot_menu(void); void qemu_cfg_get_uuid(u8 *uuid); int qemu_cfg_irq0_override(void); -u16 qemu_cfg_acpi_additional_tables(void); -u16 qemu_cfg_next_acpi_table_len(void); -void *qemu_cfg_next_acpi_table_load(void *addr, u16 len); u16 qemu_cfg_smbios_entries(void); size_t qemu_cfg_smbios_load_field(int type, size_t offset, void *addr); int qemu_cfg_smbios_load_external(int type, char **p, unsigned *nr_structs,