Message ID | 20200613205459.v3.32.I8b14735c2286701cc6be7d36b85bbad8ca58babd@changeid |
---|---|
State | Accepted |
Commit | 58a6ccd34e79acb7835699eab9c1ecb6cc8bbd47 |
Headers | show |
Series | dm: Add programmatic generation of ACPI tables (part B) | expand |
Hi Simon, -----"Simon Glass" <sjg at chromium.org> schrieb: ----- > Betreff: [PATCH v3 32/35] x86: Allow devices to write to DSDT > > 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 <sjg at chromium.org> > --- > > Changes in v3: > - Refactor the code to remove the extra memcpy() > - Recalculate the DSDT checksum only once > - Add a comment as to why the checksum byte is set to 0 > > arch/x86/lib/acpi_table.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
On Sun, Jun 14, 2020 at 10:55 AM Simon Glass <sjg at chromium.org> wrote: > > 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 <sjg at chromium.org> > --- > > Changes in v3: > - Refactor the code to remove the extra memcpy() > - Recalculate the DSDT checksum only once > - Add a comment as to why the checksum byte is set to 0 > > arch/x86/lib/acpi_table.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 4658d88351..eeacfe9b06 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -406,11 +406,20 @@ ulong write_acpi_tables(ulong start_addr) debug("ACPI: * DSDT\n"); dsdt = ctx->current; + + /* Put the table header first */ memcpy(dsdt, &AmlCode, sizeof(struct acpi_table_header)); acpi_inc(ctx, sizeof(struct acpi_table_header)); + + /* If the table is not empty, allow devices to inject things */ + if (dsdt->length >= sizeof(struct acpi_table_header)) + acpi_inject_dsdt(ctx); + + /* Copy in the AML code itself if any (after the header) */ 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)); /* Pack GNVS into the ACPI table area */ @@ -425,7 +434,12 @@ ulong write_acpi_tables(ulong start_addr) } } - /* Update DSDT checksum since we patched the GNVS address */ + /* + * Recalculate the length and update the DSDT checksum since we patched + * the GNVS address. Set the checksum to zero since it is part of the + * region being checksummed. + */ + dsdt->length = ctx->current - (void *)dsdt; dsdt->checksum = 0; dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length);
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 <sjg at chromium.org> --- Changes in v3: - Refactor the code to remove the extra memcpy() - Recalculate the DSDT checksum only once - Add a comment as to why the checksum byte is set to 0 arch/x86/lib/acpi_table.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)