summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-12-01 19:02:59 +0300
committerSimon Glass <sjg@chromium.org>2022-01-25 21:44:36 +0300
commitef55f48788100212db7cd19eb9c8a347e630ffe8 (patch)
treeaaa757b896ce61132cb13d8a825cb2871aa63ab5
parentc797f98bcd4c936adca7984f838095583057bfd7 (diff)
downloadu-boot-ef55f48788100212db7cd19eb9c8a347e630ffe8.tar.xz
x86: Move TCPA table to a writer function
Move this table over to use a writer function, for x86 only. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--arch/x86/lib/acpi_table.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index 4ae917176e..f5045cde3e 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -189,22 +189,26 @@ __weak u32 acpi_fill_mcfg(u32 current)
/**
* acpi_create_tcpa() - Create a TCPA table
*
- * @tcpa: Pointer to place to put table
- *
* Trusted Computing Platform Alliance Capabilities Table
* TCPA PC Specific Implementation SpecificationTCPA is defined in the PCI
* Firmware Specification 3.0
*/
-static int acpi_create_tcpa(struct acpi_tcpa *tcpa)
+int acpi_write_tcpa(struct acpi_ctx *ctx, const struct acpi_writer *entry)
{
- struct acpi_table_header *header = &tcpa->header;
- u32 current = (u32)tcpa + sizeof(struct acpi_tcpa);
+ struct acpi_table_header *header;
+ struct acpi_tcpa *tcpa;
+ u32 current;
int size = 0x10000; /* Use this as the default size */
void *log;
int ret;
+ if (!IS_ENABLED(CONFIG_TPM_V1))
+ return -ENOENT;
if (!CONFIG_IS_ENABLED(BLOBLIST))
return -ENXIO;
+
+ tcpa = ctx->current;
+ header = &tcpa->header;
memset(tcpa, '\0', sizeof(struct acpi_tcpa));
/* Fill out header fields */
@@ -218,14 +222,19 @@ static int acpi_create_tcpa(struct acpi_tcpa *tcpa)
tcpa->platform_class = 0;
tcpa->laml = size;
- tcpa->lasa = (ulong)log;
+ tcpa->lasa = map_to_sysmem(log);
/* (Re)calculate length and checksum */
+ current = (u32)tcpa + sizeof(struct acpi_tcpa);
header->length = current - (u32)tcpa;
- header->checksum = table_compute_checksum((void *)tcpa, header->length);
+ header->checksum = table_compute_checksum(tcpa, header->length);
+
+ acpi_inc(ctx, tcpa->header.length);
+ acpi_add_table(ctx, tcpa);
return 0;
}
+ACPI_WRITER(5tcpa, "TCPA", acpi_write_tcpa, 0);
static int get_tpm2_log(void **ptrp, int *sizep)
{
@@ -530,23 +539,8 @@ ACPI_WRITER(5mcfg, "MCFG", acpi_write_mcfg, 0);
int write_acpi_tables_x86(struct acpi_ctx *ctx,
const struct acpi_writer *entry)
{
- struct acpi_tcpa *tcpa;
struct acpi_csrt *csrt;
struct acpi_spcr *spcr;
- int ret;
-
- if (IS_ENABLED(CONFIG_TPM_V1)) {
- debug("ACPI: * TCPA\n");
- tcpa = (struct acpi_tcpa *)ctx->current;
- ret = acpi_create_tcpa(tcpa);
- if (ret) {
- log_warning("Failed to create TCPA table (err=%d)\n",
- ret);
- } else {
- acpi_inc_align(ctx, tcpa->header.length);
- acpi_add_table(ctx, tcpa);
- }
- }
debug("ACPI: * CSRT\n");
csrt = ctx->current;