diff options
author | Simon Glass <sjg@chromium.org> | 2022-08-30 21:05:37 -0600 |
---|---|---|
committer | Ilias Apalodimas <ilias.apalodimas@linaro.org> | 2022-09-03 16:59:05 +0300 |
commit | 4c57ec76b7254cf1743748b70239bddf6100237a (patch) | |
tree | d4df65873b337c030d24b8478d21b469cfca596d /lib | |
parent | 3bb4db4c3883c66ee0bbf152e9ba1d2504fa8c9f (diff) | |
download | u-boot-4c57ec76b7254cf1743748b70239bddf6100237a.zip u-boot-4c57ec76b7254cf1743748b70239bddf6100237a.tar.gz u-boot-4c57ec76b7254cf1743748b70239bddf6100237a.tar.bz2 |
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')
-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 3e240bb..edee985 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; +} |