diff options
author | Lee Leahy <leroy.p.leahy@intel.com> | 2017-01-08 11:38:14 -0800 |
---|---|---|
committer | Lee Leahy <leroy.p.leahy@intel.com> | 2017-03-16 00:04:31 +0100 |
commit | e0668e4e1f3b2f47e474f870bb5d72a488e43504 (patch) | |
tree | e4d16752f2b30310caaf55e57575e6870a1035bd /src/drivers/i2c/tpm/tis.c | |
parent | 52ab30b13b867c1f3cd5aa5d9eb3e24d430c49d5 (diff) | |
download | coreboot-e0668e4e1f3b2f47e474f870bb5d72a488e43504.tar.xz |
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@intel.com>
Reviewed-on: https://review.coreboot.org/18799
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/drivers/i2c/tpm/tis.c')
-rw-r--r-- | src/drivers/i2c/tpm/tis.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c index a0d05409ef..6bb0e969e9 100644 --- a/src/drivers/i2c/tpm/tis.c +++ b/src/drivers/i2c/tpm/tis.c @@ -17,9 +17,11 @@ #include <stdint.h> #include <string.h> #include <assert.h> +#include <commonlib/endian.h> #include <delay.h> #include <device/i2c.h> #include <endian.h> +#include <lib.h> #include <tpm.h> #include "tpm.h" #include <timer.h> @@ -144,11 +146,19 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, { uint8_t buf[TPM_BUFSIZE]; + ASSERT(sbuf_size >= 10); 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)) { + printk(BIOS_DEBUG, "TPM Command: 0x%08x\n", + read_at_be32(sendbuf, sizeof(uint16_t) + + sizeof(uint32_t))); + hexdump(sendbuf, sbuf_size); + } + memcpy(buf, sendbuf, sbuf_size); int len = tpm_transmit(buf, sbuf_size); if (len < 10) { @@ -164,5 +174,13 @@ 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%08x\n", + read_at_be32(recvbuf, sizeof(uint16_t) + + sizeof(uint32_t))); + hexdump(recvbuf, *rbuf_len); + } + return 0; } |