mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
x86: Move SSDT table to a writer function
Move this table over to use a writer function, moving the code from the x86 implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
379d3c1fd6
commit
d953137526
3 changed files with 80 additions and 63 deletions
|
@ -176,26 +176,6 @@ __weak u32 acpi_fill_mcfg(u32 current)
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MCFG is defined in the PCI Firmware Specification 3.0 */
|
|
||||||
static void acpi_create_mcfg(struct acpi_mcfg *mcfg)
|
|
||||||
{
|
|
||||||
struct acpi_table_header *header = &(mcfg->header);
|
|
||||||
u32 current = (u32)mcfg + sizeof(struct acpi_mcfg);
|
|
||||||
|
|
||||||
memset((void *)mcfg, 0, sizeof(struct acpi_mcfg));
|
|
||||||
|
|
||||||
/* Fill out header fields */
|
|
||||||
acpi_fill_header(header, "MCFG");
|
|
||||||
header->length = sizeof(struct acpi_mcfg);
|
|
||||||
header->revision = 1;
|
|
||||||
|
|
||||||
current = acpi_fill_mcfg(current);
|
|
||||||
|
|
||||||
/* (Re)calculate length and checksum */
|
|
||||||
header->length = current - (u32)mcfg;
|
|
||||||
header->checksum = table_compute_checksum((void *)mcfg, header->length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acpi_create_tcpa() - Create a TCPA table
|
* acpi_create_tcpa() - Create a TCPA table
|
||||||
*
|
*
|
||||||
|
@ -449,36 +429,6 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
|
||||||
header->checksum = table_compute_checksum((void *)spcr, header->length);
|
header->checksum = table_compute_checksum((void *)spcr, header->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int 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);
|
|
||||||
log_debug("SSDT at %p, length %x\n", ssdt, ssdt->length);
|
|
||||||
|
|
||||||
/* Drop the table if it is empty */
|
|
||||||
if (ssdt->length == sizeof(struct acpi_table_header)) {
|
|
||||||
ctx->current = ssdt;
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
|
||||||
acpi_align(ctx);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int acpi_write_gnvs(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
int acpi_write_gnvs(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
||||||
{
|
{
|
||||||
ulong addr;
|
ulong addr;
|
||||||
|
@ -523,31 +473,48 @@ int acpi_write_gnvs(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
||||||
}
|
}
|
||||||
ACPI_WRITER(4gnvs, "GNVS", acpi_write_gnvs, 0);
|
ACPI_WRITER(4gnvs, "GNVS", acpi_write_gnvs, 0);
|
||||||
|
|
||||||
|
/* MCFG is defined in the PCI Firmware Specification 3.0 */
|
||||||
|
int acpi_write_mcfg(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
||||||
|
{
|
||||||
|
struct acpi_table_header *header;
|
||||||
|
struct acpi_mcfg *mcfg;
|
||||||
|
u32 current;
|
||||||
|
|
||||||
|
mcfg = ctx->current;
|
||||||
|
header = &mcfg->header;
|
||||||
|
|
||||||
|
current = (u32)mcfg + sizeof(struct acpi_mcfg);
|
||||||
|
|
||||||
|
memset(mcfg, '\0', sizeof(struct acpi_mcfg));
|
||||||
|
|
||||||
|
/* Fill out header fields */
|
||||||
|
acpi_fill_header(header, "MCFG");
|
||||||
|
header->length = sizeof(struct acpi_mcfg);
|
||||||
|
header->revision = 1;
|
||||||
|
|
||||||
|
/* (Re)calculate length and checksum */
|
||||||
|
header->length = current - (u32)mcfg;
|
||||||
|
header->checksum = table_compute_checksum(mcfg, header->length);
|
||||||
|
|
||||||
|
acpi_inc(ctx, mcfg->header.length);
|
||||||
|
acpi_add_table(ctx, mcfg);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ACPI_WRITER(5mcfg, "MCFG", acpi_write_mcfg, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
|
* QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
|
||||||
*/
|
*/
|
||||||
int write_acpi_tables_x86(struct acpi_ctx *ctx,
|
int write_acpi_tables_x86(struct acpi_ctx *ctx,
|
||||||
const struct acpi_writer *entry)
|
const struct acpi_writer *entry)
|
||||||
{
|
{
|
||||||
struct acpi_table_header *ssdt;
|
|
||||||
struct acpi_mcfg *mcfg;
|
|
||||||
struct acpi_tcpa *tcpa;
|
struct acpi_tcpa *tcpa;
|
||||||
struct acpi_madt *madt;
|
struct acpi_madt *madt;
|
||||||
struct acpi_csrt *csrt;
|
struct acpi_csrt *csrt;
|
||||||
struct acpi_spcr *spcr;
|
struct acpi_spcr *spcr;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
debug("ACPI: * SSDT\n");
|
|
||||||
ssdt = (struct acpi_table_header *)ctx->current;
|
|
||||||
if (!acpi_create_ssdt(ctx, ssdt, OEM_TABLE_ID))
|
|
||||||
acpi_add_table(ctx, ssdt);
|
|
||||||
|
|
||||||
debug("ACPI: * MCFG\n");
|
|
||||||
mcfg = ctx->current;
|
|
||||||
acpi_create_mcfg(mcfg);
|
|
||||||
acpi_inc_align(ctx, mcfg->header.length);
|
|
||||||
acpi_add_table(ctx, mcfg);
|
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_TPM_V2)) {
|
if (IS_ENABLED(CONFIG_TPM_V2)) {
|
||||||
struct acpi_tpm2 *tpm2;
|
struct acpi_tpm2 *tpm2;
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,5 @@ obj-y += dsdt.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
obj-y += facs.o
|
obj-y += facs.o
|
||||||
|
obj-y += ssdt.o
|
||||||
endif
|
endif
|
||||||
|
|
49
lib/acpi/ssdt.c
Normal file
49
lib/acpi/ssdt.c
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
/*
|
||||||
|
* Write an ACPI Secondary System Descriptor Table (SSDT) table
|
||||||
|
*
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
int acpi_write_ssdt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
|
||||||
|
{
|
||||||
|
struct acpi_table_header *ssdt;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ssdt = ctx->current;
|
||||||
|
memset((void *)ssdt, '\0', sizeof(struct acpi_table_header));
|
||||||
|
|
||||||
|
acpi_fill_header(ssdt, "SSDT");
|
||||||
|
memcpy(ssdt->oem_table_id, OEM_TABLE_ID, sizeof(ssdt->oem_table_id));
|
||||||
|
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));
|
||||||
|
|
||||||
|
ret = acpi_fill_ssdt(ctx);
|
||||||
|
if (ret) {
|
||||||
|
ctx->current = ssdt;
|
||||||
|
return log_msg_ret("fill", ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (Re)calculate length and checksum */
|
||||||
|
ssdt->length = ctx->current - (void *)ssdt;
|
||||||
|
ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length);
|
||||||
|
log_debug("SSDT at %p, length %x\n", ssdt, ssdt->length);
|
||||||
|
|
||||||
|
/* Drop the table if it is empty */
|
||||||
|
if (ssdt->length == sizeof(struct acpi_table_header))
|
||||||
|
return log_msg_ret("fill", -ENOENT);
|
||||||
|
acpi_add_table(ctx, ssdt);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ACPI_WRITER(6ssdt, "SSDT", acpi_write_ssdt, 0);
|
Loading…
Reference in a new issue