[U-Boot] [PATCH 3/4] x86: acpi: Pack global NVS into ACPI table

Simon Glass sjg at chromium.org
Fri Jun 17 05:52:23 CEST 2016


Hi Bin,

On 15 June 2016 at 02:33, Bin Meng <bmeng.cn at gmail.com> wrote:
> Now that platform-specific ACPI global NVS is added, pack it into
> ACPI table and get its address fixed up.
>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> ---
>
>  arch/x86/include/asm/acpi_table.h                   |  4 ++++
>  .../x86/include/asm/arch-baytrail/acpi/platform.asl |  3 +++
>  arch/x86/include/asm/arch-quark/acpi/platform.asl   |  3 +++
>  arch/x86/lib/acpi_table.c                           | 21 +++++++++++++++++++++
>  doc/README.x86                                      |  2 --
>  5 files changed, 31 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>

Comments/questions below

>
> diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h
> index 56aa282..caff4d8 100644
> --- a/arch/x86/include/asm/acpi_table.h
> +++ b/arch/x86/include/asm/acpi_table.h
> @@ -299,6 +299,9 @@ struct acpi_mcfg_mmconfig {
>  /* PM1_CNT bit defines */
>  #define PM1_CNT_SCI_EN         (1 << 0)
>
> +/* ACPI global NVS structure */
> +struct acpi_global_nvs;
> +
>  /* These can be used by the target port */
>
>  void acpi_fill_header(struct acpi_table_header *header, char *signature);
> @@ -312,4 +315,5 @@ int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride,
>  int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi,
>                                u8 cpu, u16 flags, u8 lint);
>  u32 acpi_fill_madt(u32 current);
> +void acpi_create_gnvs(struct acpi_global_nvs *gnvs);
>  u32 write_acpi_tables(u32 start);
> diff --git a/arch/x86/include/asm/arch-baytrail/acpi/platform.asl b/arch/x86/include/asm/arch-baytrail/acpi/platform.asl
> index 6bc82ec..a80d2c0 100644
> --- a/arch/x86/include/asm/arch-baytrail/acpi/platform.asl
> +++ b/arch/x86/include/asm/arch-baytrail/acpi/platform.asl
> @@ -22,6 +22,9 @@ Method(_WAK, 1)
>         Return (Package() {0, 0})
>  }
>
> +/* ACPI global NVS */
> +#include "global_nvs.asl"
> +
>  /* TODO: add CPU ASL support */
>
>  Scope (\_SB)
> diff --git a/arch/x86/include/asm/arch-quark/acpi/platform.asl b/arch/x86/include/asm/arch-quark/acpi/platform.asl
> index bd72842..1ecf153 100644
> --- a/arch/x86/include/asm/arch-quark/acpi/platform.asl
> +++ b/arch/x86/include/asm/arch-quark/acpi/platform.asl
> @@ -22,6 +22,9 @@ Method(_WAK, 1)
>         Return (Package() {0, 0})
>  }
>
> +/* ACPI global NVS */
> +#include "global_nvs.asl"
> +
>  /* TODO: add CPU ASL support */
>
>  Scope (\_SB)
> diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
> index bb71286..2e4f3ab 100644
> --- a/arch/x86/lib/acpi_table.c
> +++ b/arch/x86/lib/acpi_table.c
> @@ -15,6 +15,7 @@
>  #include <asm/io.h>
>  #include <asm/lapic.h>
>  #include <asm/tables.h>
> +#include <asm/arch/global_nvs.h>
>
>  /*
>   * IASL compiles the dsdt entries and writes the hex values
> @@ -336,6 +337,7 @@ u32 write_acpi_tables(u32 start)
>         struct acpi_fadt *fadt;
>         struct acpi_mcfg *mcfg;
>         struct acpi_madt *madt;
> +       int i;
>
>         current = start;
>
> @@ -383,6 +385,25 @@ u32 write_acpi_tables(u32 start)
>         current += dsdt->length - sizeof(struct acpi_table_header);
>         current = ALIGN(current, 16);
>
> +       /* Pack GNVS into the ACPI table area */
> +       for (i = 0; i < dsdt->length; i++) {
> +               u32 gnvs = (u32)dsdt + i;

How about:

u32 *gnvs = (u32 *)(dsdt + i)

> +               if (*(u32 *)gnvs == 0xdeadbeef) {

The deadbeef comes from the .asl file, right? Can you use a #define
shared by both files?

> +                       debug("Fix up global NVS in DSDT to 0x%08x\n", current);
> +                       *(u32 *)gnvs = current;
> +                       break;
> +               }
> +       }
> +
> +       /* Update DSDT checksum since we patched the GNVS address */
> +       dsdt->checksum = 0;
> +       dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length);
> +
> +       /* Fill in platform-specific global NVS variables */
> +       acpi_create_gnvs((struct acpi_global_nvs *)current);
> +       current += sizeof(struct acpi_global_nvs);
> +       current = ALIGN(current, 16);
> +
>         debug("ACPI:    * FADT\n");
>         fadt = (struct acpi_fadt *)current;
>         current += sizeof(struct acpi_fadt);
> diff --git a/doc/README.x86 b/doc/README.x86
> index a548b54..7d694b1 100644
> --- a/doc/README.x86
> +++ b/doc/README.x86
> @@ -1020,8 +1020,6 @@ Features not supported so far (to make it a complete ACPI solution):
>   * S3 (Suspend to RAM), S4 (Suspend to Disk).
>
>  Features that are optional:
> - * ACPI global NVS support. We may need it to simplify ASL code logic if
> -   utilizing NVS variables. Most likely we will need this sooner or later.
>   * Dynamic AML bytecodes insertion at run-time. We may need this to support
>     SSDT table generation and DSDT fix up.
>   * SMI support. Since U-Boot is a modern bootloader, we don't want to bring
> --
> 2.7.4
>
Regards,
Simon


More information about the U-Boot mailing list