summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-11-04 09:57:31 -0700
committerBin Meng <bmeng.cn@gmail.com>2020-11-06 09:51:30 +0800
commit2de4744dae572b6ba9c1c3e3a40b377e53994630 (patch)
treeb788817b435e0669e7902f725dfeea249fa5ee75 /arch
parentbe1cee11b26880c385d9ce1d84792403a59f8855 (diff)
downloadu-boot-2de4744dae572b6ba9c1c3e3a40b377e53994630.tar.gz
x86: acpi: Allow the SSDT to be empty
If there is nothing in the SSDT we should not include it in the tables. Update the implementation to check this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/lib/acpi_table.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index f0f342d893..c5c5c6e679 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -470,8 +470,9 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
header->checksum = table_compute_checksum((void *)spcr, header->length);
}
-void acpi_create_ssdt(struct acpi_ctx *ctx, struct acpi_table_header *ssdt,
- const char *oem_table_id)
+static int acpi_create_ssdt(struct acpi_ctx *ctx,
+ struct acpi_table_header *ssdt,
+ const char *oem_table_id)
{
memset((void *)ssdt, '\0', sizeof(struct acpi_table_header));
@@ -484,9 +485,19 @@ void acpi_create_ssdt(struct acpi_ctx *ctx, struct acpi_table_header *ssdt,
acpi_fill_ssdt(ctx);
- /* (Re)calculate length and checksum. */
+ /* (Re)calculate length and checksum */
ssdt->length = ctx->current - (void *)ssdt;
ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length);
+ log_debug("SSDT at %p, length %x\n", ssdt, ssdt->length);
+
+ /* Drop the table if it is empty */
+ if (ssdt->length == sizeof(struct acpi_table_header)) {
+ ctx->current = ssdt;
+ return -ENOENT;
+ }
+ acpi_align(ctx);
+
+ return 0;
}
/*
@@ -596,11 +607,8 @@ ulong write_acpi_tables(ulong start_addr)
debug("ACPI: * SSDT\n");
ssdt = (struct acpi_table_header *)ctx->current;
- acpi_create_ssdt(ctx, ssdt, OEM_TABLE_ID);
- if (ssdt->length > sizeof(struct acpi_table_header)) {
- acpi_inc_align(ctx, ssdt->length);
+ if (!acpi_create_ssdt(ctx, ssdt, OEM_TABLE_ID))
acpi_add_table(ctx, ssdt);
- }
debug("ACPI: * MCFG\n");
mcfg = ctx->current;