x86: Move DSDT table to a writer function
Move this table over to use a writer function, moving the code from the x86 implementation. Add a pointer to the DSDT in struct acpi_ctx so we can reference it later. Disable this table for sandbox since we don't actually compile real ASL code. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -10,5 +10,11 @@ obj-y += acpi_writer.o
|
||||
# With QEMU the ACPI tables come from there, not from U-Boot
|
||||
ifndef CONFIG_QEMU
|
||||
obj-y += base.o
|
||||
|
||||
# Sandbox does not build a .asl file
|
||||
ifndef CONFIG_SANDBOX
|
||||
obj-y += dsdt.o
|
||||
endif
|
||||
|
||||
obj-y += facs.o
|
||||
endif
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* Copyright 2021 Google LLC
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY LOGC_ACPI
|
||||
|
||||
#include <common.h>
|
||||
#include <acpi/acpi_table.h>
|
||||
#include <dm/acpi.h>
|
||||
|
||||
55
lib/acpi/dsdt.c
Normal file
55
lib/acpi/dsdt.c
Normal file
@@ -0,0 +1,55 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Write the ACPI Differentiated System Description Table (DSDT)
|
||||
*
|
||||
* Copyright 2021 Google LLC
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY LOGC_ACPI
|
||||
|
||||
#include <common.h>
|
||||
#include <acpi/acpi_table.h>
|
||||
#include <dm/acpi.h>
|
||||
#include <tables_csum.h>
|
||||
|
||||
/*
|
||||
* IASL compiles the dsdt entries and writes the hex values
|
||||
* to a C array AmlCode[] (see dsdt.c).
|
||||
*/
|
||||
extern const unsigned char AmlCode[];
|
||||
|
||||
int acpi_write_dsdt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
||||
{
|
||||
const int thl = sizeof(struct acpi_table_header);
|
||||
struct acpi_table_header *dsdt = ctx->current;
|
||||
int aml_len;
|
||||
|
||||
/* Put the table header first */
|
||||
memcpy(dsdt, &AmlCode, thl);
|
||||
acpi_inc(ctx, thl);
|
||||
log_debug("DSDT starts at %p, hdr ends at %p\n", dsdt, ctx->current);
|
||||
|
||||
/* If the table is not empty, allow devices to inject things */
|
||||
aml_len = dsdt->length - thl;
|
||||
if (aml_len) {
|
||||
void *base = ctx->current;
|
||||
int ret;
|
||||
|
||||
ret = acpi_inject_dsdt(ctx);
|
||||
if (ret)
|
||||
return log_msg_ret("inject", ret);
|
||||
log_debug("Added %lx bytes from inject_dsdt, now at %p\n",
|
||||
(ulong)(ctx->current - base), ctx->current);
|
||||
log_debug("Copy AML code size %x to %p\n", aml_len,
|
||||
ctx->current);
|
||||
memcpy(ctx->current, AmlCode + thl, aml_len);
|
||||
acpi_inc(ctx, aml_len);
|
||||
}
|
||||
|
||||
ctx->dsdt = dsdt;
|
||||
dsdt->length = ctx->current - (void *)dsdt;
|
||||
log_debug("Updated DSDT length to %x\n", dsdt->length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
ACPI_WRITER(3dsdt, "DSDT", acpi_write_dsdt, 0);
|
||||
@@ -5,6 +5,8 @@
|
||||
* Copyright 2021 Google LLC
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY LOGC_ACPI
|
||||
|
||||
#include <common.h>
|
||||
#include <acpi/acpi_table.h>
|
||||
#include <dm/acpi.h>
|
||||
|
||||
Reference in New Issue
Block a user