[coreboot-gerrit] Change in coreboot[master]: arch/x86/acpi: Add TPM2 table support

Philipp Deppenwiese (Code Review) gerrit at coreboot.org
Thu Oct 18 15:41:08 CEST 2018


Philipp Deppenwiese has uploaded this change for review. ( https://review.coreboot.org/29181


Change subject: arch/x86/acpi: Add TPM2 table support
......................................................................

arch/x86/acpi: Add TPM2 table support

* Distinguish between TPM 1.2 and 2.0
  ACPI table support
* Add TPM2 table support for TIS interface only

Change-Id: I030c7ea744bcfe61ebef8d66d1295273b5dccda5
Signed-off-by: Philipp Deppenwiese <zaolin at das-labor.org>
---
M src/arch/x86/acpi.c
M src/arch/x86/include/arch/acpi.h
2 files changed, 55 insertions(+), 7 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/81/29181/1

diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c
index 1b43004..286b56a 100644
--- a/src/arch/x86/acpi.c
+++ b/src/arch/x86/acpi.c
@@ -308,6 +308,30 @@
 	header->checksum = acpi_checksum((void *)tcpa, header->length);
 }
 
+static void acpi_create_tpm2(acpi_tpm2_t *tpm2)
+{
+	acpi_header_t *header = &(tpm2->header);
+
+	memset((void *)tpm2, 0, sizeof(acpi_tpm2_t));
+
+	/* Fill out header fields. */
+	memcpy(header->signature, "TPM2", 4);
+	memcpy(header->oem_id, OEM_ID, 6);
+	memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
+	memcpy(header->asl_compiler_id, ASLC, 4);
+
+	header->length = sizeof(acpi_tpm2_t);
+	header->revision = get_acpi_table_revision(TPM2);
+
+	tpm2->platform_class = 0; // Always pc platform..
+	tpm2->control_area = 0; // no CRB interface support
+	tpm2->start_method = 6; // no CRB interface support
+	tpm2->psp = 0;
+
+	/* Calculate checksum. */
+	header->checksum = acpi_checksum((void *)tpm2, header->length);
+}
+
 static void acpi_ssdt_write_cbtable(void)
 {
 	const struct cbmem_entry *cbtable;
@@ -1163,13 +1187,26 @@
 		acpi_add_table(rsdp, mcfg);
 	}
 
-	printk(BIOS_DEBUG, "ACPI:    * TCPA\n");
-	tcpa = (acpi_tcpa_t *) current;
-	acpi_create_tcpa(tcpa);
-	if (tcpa->header.length >= sizeof(acpi_tcpa_t)) {
-		current += tcpa->header.length;
-		current = acpi_align_current(current);
-		acpi_add_table(rsdp, tcpa);
+	if (IS_DEFINED(CONFIG_TPM1)) {
+		printk(BIOS_DEBUG, "ACPI:    * TCPA\n");
+		tcpa = (acpi_tcpa_t *) current;
+		acpi_create_tcpa(tcpa);
+		if (tcpa->header.length >= sizeof(acpi_tcpa_t)) {
+			current += tcpa->header.length;
+			current = acpi_align_current(current);
+			acpi_add_table(rsdp, tcpa);
+		}
+	}
+
+	if (IS_DEFINED(CONFIG_TPM2)) {
+		printk(BIOS_DEBUG, "ACPI:    * TPM2\n");
+		tpm2 = (acpi_tpm2_t *) current;
+		acpi_create_tpm2(tpm2);
+		if (tpm2->header.length >= sizeof(acpi_tpm2_t)) {
+			current += tpm2->header.length;
+			current = acpi_align_current(current);
+			acpi_add_table(rsdp, tpm2);
+		}
 	}
 
 	printk(BIOS_DEBUG, "ACPI:    * MADT\n");
@@ -1288,6 +1325,8 @@
 		return 1;
 	case TCPA:
 		return 2;
+	case TPM2:
+		return 4;
 	case SSDT: /* ACPI 1.0/2.0: ?, ACPI 3.0/4.0: 2 */
 		return 2;
 	case SRAT:  /* ACPI 1.0: N/A, 2.0: 1, 3.0: 2, 4.0: 3 */
diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h
index 54be1f4..5cf89da 100644
--- a/src/arch/x86/include/arch/acpi.h
+++ b/src/arch/x86/include/arch/acpi.h
@@ -191,6 +191,15 @@
 	u64 lasa;
 } __packed acpi_tcpa_t;
 
+typedef struct acpi_tpm2 {
+	struct acpi_table_header header;
+	u16 platform_class;
+	u8  reserved[2];
+	u64 control_area;
+	u32 start_method
+	u64 psp;
+} __packed acpi_tpm2_t;
+
 typedef struct acpi_mcfg_mmconfig {
 	u32 base_address;
 	u32 base_reserved;

-- 
To view, visit https://review.coreboot.org/29181
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I030c7ea744bcfe61ebef8d66d1295273b5dccda5
Gerrit-Change-Number: 29181
Gerrit-PatchSet: 1
Gerrit-Owner: Philipp Deppenwiese <zaolin.daisuki at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181018/3d3f36f9/attachment.html>


More information about the coreboot-gerrit mailing list