From: Miquel Raynal Date: Thu, 29 Mar 2018 09:43:49 +0200 Subject: [U-Boot] [PATCH v2 07/19] tpm: add possible traces to analyze buffers returned by the TPM In-Reply-To: <20180329074401.8691-1-miquel.raynal@bootlin.com> References: <20180329074401.8691-1-miquel.raynal@bootlin.com> Message-ID: <20180329074401.8691-8-miquel.raynal@bootlin.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de When debugging, it is welcome to get more information about what the TPM returns. Add the possibility to print the packets received to show their exact content. Signed-off-by: Miquel Raynal --- lib/tpm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/tpm.c b/lib/tpm.c index 2b329145be..aa46ec1693 100644 --- a/lib/tpm.c +++ b/lib/tpm.c @@ -249,6 +249,7 @@ static uint32_t tpm_sendrecv_command(const void *command, int err, ret; uint8_t response_buffer[COMMAND_BUFFER_SIZE]; size_t response_length; + int i; if (response) { response_length = *size_ptr; @@ -260,15 +261,24 @@ static uint32_t tpm_sendrecv_command(const void *command, ret = uclass_first_device_err(UCLASS_TPM, &dev); if (ret) return ret; + err = tpm_xfer(dev, command, tpm_command_size(command), response, &response_length); if (err < 0) return TPM_LIB_ERROR; + if (size_ptr) *size_ptr = response_length; - return tpm_return_code(response); + ret = tpm_return_code(response); + + debug("TPM response [ret:%d]: ", ret); + for (i = 0; i < response_length; i++) + debug("%02x ", ((u8 *)response)[i]); + debug("\n"); + + return ret; } int tpm_set_specification(int version) -- 2.14.1