[coreboot-gerrit] Patch set updated for coreboot: drivers/i2c/tpm: Add TPM (TIS) debugging support

Lee Leahy (leroy.p.leahy@intel.com) gerrit at coreboot.org
Wed Mar 15 01:35:43 CET 2017


Lee Leahy (leroy.p.leahy at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18799

-gerrit

commit 6c927ca6c123b0743d7cc263852a7521e463d1c1
Author: Lee Leahy <leroy.p.leahy at intel.com>
Date:   Sun Jan 8 11:38:14 2017 -0800

    drivers/i2c/tpm: Add TPM (TIS) debugging support
    
    Add debugging support for the TIS transactions for the I2C TPM chips.
    
    TEST=Build and run on reef
    
    Change-Id: Ibc7e26fca781316d625f4da080f34749f18e4f9b
    Signed-off-by: Lee Leahy <leroy.p.leahy at intel.com>
---
 src/drivers/i2c/tpm/Kconfig |  5 +++++
 src/drivers/i2c/tpm/tis.c   | 18 +++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/drivers/i2c/tpm/Kconfig b/src/drivers/i2c/tpm/Kconfig
index 89e4621..d35eb75 100644
--- a/src/drivers/i2c/tpm/Kconfig
+++ b/src/drivers/i2c/tpm/Kconfig
@@ -39,3 +39,8 @@ config DRIVER_I2C_TPM_ACPI
 	bool "Generate I2C TPM ACPI device"
 	default y if ARCH_X86 && I2C_TPM
 	default n
+
+config DRIVER_TPM_DISPLAY_TIS_BYTES
+	bool "TPM: Display the TIS transactions to I2C TPM chip"
+	default n
+	depends on I2C_TPM
diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c
index fea5145..0f4666f 100644
--- a/src/drivers/i2c/tpm/tis.c
+++ b/src/drivers/i2c/tpm/tis.c
@@ -20,6 +20,7 @@
 #include <delay.h>
 #include <device/i2c.h>
 #include <endian.h>
+#include <lib.h>
 #include <tpm.h>
 #include "tpm.h"
 #include <timer.h>
@@ -147,8 +148,16 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
 	if (sizeof(buf) < sbuf_size)
 		return -1;
 
-	memcpy(buf, sendbuf, sbuf_size);
+	/* Display the TPM command */
+	if (IS_ENABLED(CONFIG_DRIVER_TPM_DISPLAY_TIS_BYTES)) {
+		ASSERT(sbuf_size >= 10);
+		if (sbuf_size >= 10)
+			printk(BIOS_DEBUG, "TPM Command: 0x%02x%02x%02x%02x\n",
+				sendbuf[6], sendbuf[7], sendbuf[8], sendbuf[9]);
+		hexdump(sendbuf, sbuf_size);
+	}
 
+	memcpy(buf, sendbuf, sbuf_size);
 	int len = tpm_transmit(buf, sbuf_size);
 
 	if (len < 10) {
@@ -164,5 +173,12 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
 	memcpy(recvbuf, buf, len);
 	*rbuf_len = len;
 
+	/* Display the TPM response */
+	if (IS_ENABLED(CONFIG_DRIVER_TPM_DISPLAY_TIS_BYTES)) {
+		printk(BIOS_DEBUG, "TPM Response: 0x%02x%02x%02x%02x\n",
+			recvbuf[6], recvbuf[7], recvbuf[8], recvbuf[9]);
+		hexdump(recvbuf, *rbuf_len);
+	}
+
 	return 0;
 }



More information about the coreboot-gerrit mailing list