Skip to content
Snippets Groups Projects
Commit 32af3261 authored by Simon Glass's avatar Simon Glass
Browse files

x86: Move GNVS table to a writer function


Move this table over to use a writer function, for x86 only. Handle the
two cases

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent eacb6d0b
No related branches found
No related tags found
No related merge requests found
......@@ -479,66 +479,65 @@ static int acpi_create_ssdt(struct acpi_ctx *ctx,
return 0;
}
/*
* QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
*/
static int write_acpi_tables_x86(struct acpi_ctx *ctx,
const struct acpi_writer *entry)
int acpi_write_gnvs(struct acpi_ctx *ctx, const struct acpi_writer *entry)
{
struct acpi_fadt *fadt;
struct acpi_table_header *ssdt;
struct acpi_mcfg *mcfg;
struct acpi_tcpa *tcpa;
struct acpi_madt *madt;
struct acpi_csrt *csrt;
struct acpi_spcr *spcr;
ulong addr;
int ret;
int i;
if (!IS_ENABLED(CONFIG_ACPI_GNVS_EXTERNAL)) {
int i;
/* We need the DSDT to be done */
if (!ctx->dsdt)
return log_msg_ret("dsdt", -EAGAIN);
/* Pack GNVS into the ACPI table area */
for (i = 0; i < ctx->dsdt->length; i++) {
u32 *gnvs = (u32 *)((u32)ctx->dsdt + i);
if (*gnvs == ACPI_GNVS_ADDR) {
*gnvs = map_to_sysmem(ctx->current);
debug("Fix up global NVS in DSDT to %#08x\n",
*gnvs);
log_debug("Fix up global NVS in DSDT to %#08x\n",
*gnvs);
break;
}
}
/*
* Fill in platform-specific global NVS variables. If this fails
* we cannot return the error but this should only happen while
* debugging.
* 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.
*/
addr = acpi_create_gnvs(ctx->current);
if (IS_ERR_VALUE(addr))
printf("Error: Gailed to create GNVS\n");
acpi_inc_align(ctx, sizeof(struct acpi_global_nvs));
ctx->dsdt->checksum = 0;
ctx->dsdt->checksum = table_compute_checksum((void *)ctx->dsdt,
ctx->dsdt->length);
}
/*
* 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.
*/
ctx->dsdt->checksum = 0;
ctx->dsdt->checksum = table_compute_checksum((void *)ctx->dsdt,
ctx->dsdt->length);
/*
* Fill in platform-specific global NVS variables. If this fails we
* cannot return the error but this should only happen while debugging.
*/
/* Fill in platform-specific global NVS variables */
addr = acpi_create_gnvs(ctx->current);
if (IS_ERR_VALUE(addr))
printf("Error: Failed to create GNVS\n");
return log_msg_ret("gnvs", (int)addr);
acpi_inc_align(ctx, sizeof(struct acpi_global_nvs));
return 0;
}
ACPI_WRITER(4gnvs, "GNVS", acpi_write_gnvs, 0);
/*
* QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
*/
int write_acpi_tables_x86(struct acpi_ctx *ctx,
const struct acpi_writer *entry)
{
struct acpi_fadt *fadt;
struct acpi_table_header *ssdt;
struct acpi_mcfg *mcfg;
struct acpi_tcpa *tcpa;
struct acpi_madt *madt;
struct acpi_csrt *csrt;
struct acpi_spcr *spcr;
int ret;
debug("ACPI: * FADT\n");
fadt = ctx->current;
acpi_inc_align(ctx, sizeof(struct acpi_fadt));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment