diff options
author | Simon Glass | 2022-08-30 21:05:37 -0600 |
---|---|---|
committer | Ilias Apalodimas | 2022-09-03 16:59:05 +0300 |
commit | 4c57ec76b7254cf1743748b70239bddf6100237a (patch) | |
tree | d4df65873b337c030d24b8478d21b469cfca596d /lib/tpm-v2.c | |
parent | 3bb4db4c3883c66ee0bbf152e9ba1d2504fa8c9f (diff) |
tpm: Implement state command for Cr50
Add a vendor-specific TPM2 command for this and implement it for Cr50.
Note: This is not part of the TPM spec, but is a Cr50 extension.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'lib/tpm-v2.c')
-rw-r--r-- | lib/tpm-v2.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index 3e240bb4c67..edee9854a7c 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -679,3 +679,28 @@ u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf, { return tpm_sendrecv_command(dev, sendbuf, recvbuf, recv_size); } + +u32 tpm2_report_state(struct udevice *dev, uint vendor_cmd, uint vendor_subcmd, + u8 *recvbuf, size_t *recv_size) +{ + u8 command_v2[COMMAND_BUFFER_SIZE] = { + /* header 10 bytes */ + tpm_u16(TPM2_ST_NO_SESSIONS), /* TAG */ + tpm_u32(10 + 2), /* Length */ + tpm_u32(vendor_cmd), /* Command code */ + + tpm_u16(vendor_subcmd), + }; + int ret; + + ret = tpm_sendrecv_command(dev, command_v2, recvbuf, recv_size); + log_debug("ret=%s, %x\n", dev->name, ret); + if (ret) + return ret; + if (*recv_size < 12) + return -ENODATA; + *recv_size -= 12; + memcpy(recvbuf, recvbuf + 12, *recv_size); + + return 0; +} |