From patchwork Sun Apr 26 15:26:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 238540 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Sun, 26 Apr 2020 09:26:15 -0600 Subject: [PATCH v8 32/35] x86: Allow devices to write to DSDT In-Reply-To: <20200426152618.125646-1-sjg@chromium.org> References: <20200426152618.125646-1-sjg@chromium.org> Message-ID: <20200426092529.v8.32.I8b14735c2286701cc6be7d36b85bbad8ca58babd@changeid> Call the new core function to inject ASL programmatically into the DSDT. This is made up of fragments generated by devices that have the inject_dsdt() method. The normal, compiled ASL file is added after this. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v3: None Changes in v2: None arch/x86/lib/acpi_table.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 0af9d47050..8587ed4344 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -431,7 +431,20 @@ ulong write_acpi_tables(ulong start_addr) memcpy(ctx->current, (char *)&AmlCode + sizeof(struct acpi_table_header), dsdt->length - sizeof(struct acpi_table_header)); - acpi_inc_align(ctx, dsdt->length - sizeof(struct acpi_table_header)); + + if (dsdt->length >= sizeof(struct acpi_table_header)) { + acpi_inject_dsdt(ctx); + memcpy(ctx->current, + (char *)AmlCode + sizeof(struct acpi_table_header), + dsdt->length - sizeof(struct acpi_table_header)); + acpi_inc(ctx, dsdt->length - sizeof(struct acpi_table_header)); + + /* (Re)calculate length and checksum. */ + dsdt->length = ctx->current - (void *)dsdt; + dsdt->checksum = 0; + dsdt->checksum = table_compute_checksum(dsdt, dsdt->length); + } + acpi_align(ctx); /* Pack GNVS into the ACPI table area */ for (i = 0; i < dsdt->length; i++) {