From 957bb78e8e2dcc40be4fe28e09dc75ae1f684f14 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 16 Jun 2015 11:48:29 +0200 Subject: [PATCH 067/217] hw/arm/virt-acpi-build: Generate RSDP table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-id: <1434455325-23399-18-git-send-email-drjones@redhat.com> Patchwork-id: 66249 O-Subject: [AArch64 RHEL-7.2 qemu-kvm-rhev PATCH 17/33] hw/arm/virt-acpi-build: Generate RSDP table Bugzilla: 1231719 RH-Acked-by: Miroslav Rezanina RH-Acked-by: Wei Huang RH-Acked-by: Igor Mammedov RH-Acked-by: Laszlo Ersek Author: Shannon Zhao RSDP points to RSDT which in turn points to other tables. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Alex Bennée Message-id: 1432522520-8068-13-git-send-email-zhaoshenglong@huawei.com Signed-off-by: Peter Maydell (cherry picked from commit d4bec5d876b694f7f13ad3fcfe510ff46e9748d0) Signed-off-by: Andrew Jones Signed-off-by: Miroslav Rezanina --- hw/arm/virt-acpi-build.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 95c84d6..f8c1dd8 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -151,6 +151,35 @@ static void acpi_dsdt_add_virtio(Aml *scope, } } +/* 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; +} + /* GTDT */ static void build_gtdt(GArray *table_data, GArray *linker) @@ -285,7 +314,7 @@ static void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) { GArray *table_offsets; - unsigned dsdt; + unsigned dsdt, rsdt; VirtAcpiCpuInfo cpuinfo; GArray *tables_blob = tables->table_data; @@ -322,8 +351,12 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) build_gtdt(tables_blob, tables->linker); /* RSDT is pointed to by RSDP */ + rsdt = tables_blob->len; build_rsdt(tables_blob, tables->linker, table_offsets); + /* RSDP is in FSEG memory, so allocate it separately */ + build_rsdp(tables->rsdp, tables->linker, rsdt); + /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); } -- 1.8.3.1