Now that both i386 and arm use v2 tables, use common code for both. Tested-by: Shannon Zhao <zhaoshengl...@huawei.com> Signed-off-by: Michael S. Tsirkin <m...@redhat.com> --- include/hw/acpi/aml-build.h | 2 ++ hw/acpi/aml-build.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 31 +------------------------------ hw/i386/acpi-build.c | 41 ----------------------------------------- 4 files changed, 48 insertions(+), 71 deletions(-)
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 0a00402..ae169fa 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -289,5 +289,7 @@ void build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets); void build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets); +GArray * +build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt, unsigned xsdt); #endif diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index d0e52c4..9449875 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1237,3 +1237,48 @@ build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets) { build_sdt(table_data, linker, table_offsets, "XSDT", sizeof(uint64_t)); } + +GArray * +build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt, unsigned xsdt) +{ + AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp); + + bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16, + true /* fseg memory */); + + memcpy(&rsdp->signature, "RSD PTR ", 8); + memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, 6); + + rsdp->revision = 0x02; + rsdp->length = cpu_to_le32(sizeof *rsdp); + + if (rsdt) { + rsdp->rsdt_physical_address = cpu_to_le32(rsdt); + /* Address to be filled by Guest linker */ + bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE, + ACPI_BUILD_TABLE_FILE, + rsdp_table, &rsdp->rsdt_physical_address, + sizeof rsdp->rsdt_physical_address); + } + + if (xsdt) { + rsdp->xsdt_physical_address = cpu_to_le64(xsdt); + bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE, + ACPI_BUILD_TABLE_FILE, + rsdp_table, &rsdp->xsdt_physical_address, + sizeof rsdp->xsdt_physical_address); + } + rsdp->checksum = 0; + /* Checksum to be filled by Guest linker */ + bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, + rsdp, rsdp, offsetof(AcpiRsdpDescriptor, length), + &rsdp->checksum); + + rsdp->extended_checksum = 0; + /* Checksum to be filled by Guest linker */ + bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, + rsdp, rsdp, sizeof *rsdp, + &rsdp->extended_checksum); + + return rsdp_table; +} diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 42c8dd9..c164f65 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -304,35 +304,6 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq) aml_append(scope, dev); } -/* RSDP */ -static GArray * -build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt) -{ - AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp); - - bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16, - true /* fseg memory */); - - memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature)); - memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, sizeof(rsdp->oem_id)); - rsdp->length = cpu_to_le32(sizeof(*rsdp)); - rsdp->revision = 0x02; - - /* Point to RSDT */ - rsdp->rsdt_physical_address = cpu_to_le32(rsdt); - /* Address to be filled by Guest linker */ - bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE, - ACPI_BUILD_TABLE_FILE, - rsdp_table, &rsdp->rsdt_physical_address, - sizeof rsdp->rsdt_physical_address); - rsdp->checksum = 0; - /* Checksum to be filled by Guest linker */ - bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, - rsdp, rsdp, sizeof *rsdp, &rsdp->checksum); - - return rsdp_table; -} - static void build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) { @@ -532,7 +503,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) build_rsdt(tables_blob, tables->linker, table_offsets); /* RSDP is in FSEG memory, so allocate it separately */ - build_rsdp(tables->rsdp, tables->linker, rsdt); + build_rsdp(tables->rsdp, tables->linker, rsdt, 0); /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 3579d18..8c6d7f5 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1592,47 +1592,6 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc) misc->dsdt_size, 1); } -static GArray * -build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt, unsigned xsdt) -{ - AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp); - - bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16, - true /* fseg memory */); - - memcpy(&rsdp->signature, "RSD PTR ", 8); - memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, 6); - - rsdp->revision = 0x02; - rsdp->length = cpu_to_le32(sizeof *rsdp); - - rsdp->rsdt_physical_address = cpu_to_le32(rsdt); - /* Address to be filled by Guest linker */ - bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE, - ACPI_BUILD_TABLE_FILE, - rsdp_table, &rsdp->rsdt_physical_address, - sizeof rsdp->rsdt_physical_address); - - rsdp->xsdt_physical_address = cpu_to_le64(xsdt); - bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE, - ACPI_BUILD_TABLE_FILE, - rsdp_table, &rsdp->xsdt_physical_address, - sizeof rsdp->xsdt_physical_address); - rsdp->checksum = 0; - /* Checksum to be filled by Guest linker */ - bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, - rsdp, rsdp, offsetof(AcpiRsdpDescriptor, length), - &rsdp->checksum); - - rsdp->extended_checksum = 0; - /* Checksum to be filled by Guest linker */ - bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, - rsdp, rsdp, sizeof *rsdp, - &rsdp->extended_checksum); - - return rsdp_table; -} - typedef struct AcpiBuildState { /* Copy of table in RAM (for patching). */ -- MST