qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/4] acpi: unify rsdp generation


From: Shannon Zhao
Subject: Re: [Qemu-devel] [PATCH 4/4] acpi: unify rsdp generation
Date: Fri, 5 Jun 2015 10:47:16 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0


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 <address@hidden>
> ---
>  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.

>      /* 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]