diff mbox series

[v3,30/35] x86: Allow devices to write an SSDT

Message ID 20200613205459.v3.30.Id6fc7367886ec2e2d9f2ddf423ad32720e14e5e5@changeid
State Accepted
Commit 351fef5c579b4cabbd2976e61d1f8a9ef7c06b53
Headers show
Series dm: Add programmatic generation of ACPI tables (part B) | expand

Commit Message

Simon Glass June 14, 2020, 2:55 a.m. UTC
Call the new core function to write the SSDT. This is made up of fragments
generated by devices that have the fill_ssdt() method.

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

Changes in v3:
Drop coreboot_acpi_ids enum

Changes in v1:
- Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR
- Update ACPI_DSTATUS enum
- Drop writing of coreboot tables

 arch/x86/lib/acpi_table.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Wolfgang Wallner June 16, 2020, 11:31 a.m. UTC | #1
Hi Simon,

-----"Simon Glass" <sjg at chromium.org> schrieb: -----
> Betreff: [PATCH v3 30/35] x86: Allow devices to write an SSDT
> 
> Call the new core function to write the SSDT. This is made up of fragments
> generated by devices that have the fill_ssdt() method.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
> Changes in v3:
> Drop coreboot_acpi_ids enum
> 
> Changes in v1:
> - Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR
> - Update ACPI_DSTATUS enum
> - Drop writing of coreboot tables
> 
>  arch/x86/lib/acpi_table.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)

Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
Bin Meng June 29, 2020, 3:36 a.m. UTC | #2
On Sun, Jun 14, 2020 at 10:55 AM Simon Glass <sjg at chromium.org> wrote:
>
> Call the new core function to write the SSDT. This is made up of fragments
> generated by devices that have the fill_ssdt() method.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v3:
> Drop coreboot_acpi_ids enum
>
> Changes in v1:
> - Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR
> - Update ACPI_DSTATUS enum
> - Drop writing of coreboot tables
>
>  arch/x86/lib/acpi_table.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
diff mbox series

Patch

diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index e96acf08d4..4658d88351 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -14,6 +14,7 @@ 
 #include <mapmem.h>
 #include <serial.h>
 #include <version.h>
+#include <acpi/acpigen.h>
 #include <acpi/acpi_table.h>
 #include <asm/acpi/global_nvs.h>
 #include <asm/ioapic.h>
@@ -354,6 +355,25 @@  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)
+{
+	memset((void *)ssdt, '\0', sizeof(struct acpi_table_header));
+
+	acpi_fill_header(ssdt, "SSDT");
+	ssdt->revision = acpi_get_table_revision(ACPITAB_SSDT);
+	ssdt->aslc_revision = 1;
+	ssdt->length = sizeof(struct acpi_table_header);
+
+	acpi_inc(ctx, sizeof(struct acpi_table_header));
+
+	acpi_fill_ssdt(ctx);
+
+	/* (Re)calculate length and checksum. */
+	ssdt->length = ctx->current - (void *)ssdt;
+	ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length);
+}
+
 /*
  * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
  */
@@ -363,6 +383,7 @@  ulong write_acpi_tables(ulong start_addr)
 	struct acpi_facs *facs;
 	struct acpi_table_header *dsdt;
 	struct acpi_fadt *fadt;
+	struct acpi_table_header *ssdt;
 	struct acpi_mcfg *mcfg;
 	struct acpi_madt *madt;
 	struct acpi_csrt *csrt;
@@ -418,6 +439,14 @@  ulong write_acpi_tables(ulong start_addr)
 	acpi_create_fadt(fadt, facs, dsdt);
 	acpi_add_table(ctx, fadt);
 
+	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);
+		acpi_add_table(ctx, ssdt);
+	}
+
 	debug("ACPI:    * MCFG\n");
 	mcfg = ctx->current;
 	acpi_create_mcfg(mcfg);