From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1mGJ-0007Yc-01 for qemu-devel@nongnu.org; Sun, 07 Jun 2015 21:54:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z1mGF-0000Xl-Nw for qemu-devel@nongnu.org; Sun, 07 Jun 2015 21:54:02 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:10019) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1mGE-0000XF-Sc for qemu-devel@nongnu.org; Sun, 07 Jun 2015 21:53:59 -0400 Message-ID: <5574F556.2070606@huawei.com> Date: Mon, 8 Jun 2015 09:52:22 +0800 From: Shannon Zhao MIME-Version: 1.0 References: <1433434873-25200-1-git-send-email-mst@redhat.com> <1433434873-25200-5-git-send-email-mst@redhat.com> <55710DB4.4060001@huawei.com> <20150607114318-mutt-send-email-mst@redhat.com> In-Reply-To: <20150607114318-mutt-send-email-mst@redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/4] acpi: unify rsdp generation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Peter Maydell , Eduardo Habkost , ghammer@redhat.com, qemu-devel@nongnu.org, shannon.zhao@linaro.org, pbonzini@redhat.com, imammedo@redhat.com, lersek@redhat.com, Richard Henderson On 2015/6/7 17:45, Michael S. Tsirkin wrote: > On Fri, Jun 05, 2015 at 10:47:16AM +0800, Shannon Zhao wrote: >> >> >> On 2015/6/5 0:21, Michael S. Tsirkin wrote: >>> Now that both i386 and arm use v2 tables, >>> use common code for both. >>> >>> Warning: untested. >>> >>> Signed-off-by: Michael S. Tsirkin >>> --- >>> 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..d0bd953 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_le32(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); >>> >> >> So ARM virt can use xsdt as well. Maybe could do by another patch on top >> of this. > > In fact, there's probably no reason to have an rsdt at all. > > But how does one test ARM ACPI code? > Could you upload an image with instructions to the wiki? > http://wiki.qemu.org/System_Images > Ok, no problem. But I don't have an account of the wiki. > >>> /* 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 3551a08..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_le32(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). */ >>> >> >> -- >> Shannon > > . > -- Shannon