mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-04-01 12:01:31 +00:00
sandbox: tpm: Correct handling of get-capability
This function current handles the kernel case incorrectly. Fix it, and use the shorter TPM_HDR_LEN while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
f9143c1200
commit
7f350a959c
1 changed files with 4 additions and 10 deletions
|
@ -140,16 +140,13 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
|
||||||
printf("Get flags index %#02x\n", index);
|
printf("Get flags index %#02x\n", index);
|
||||||
*recv_len = 22;
|
*recv_len = 22;
|
||||||
memset(recvbuf, '\0', *recv_len);
|
memset(recvbuf, '\0', *recv_len);
|
||||||
data = recvbuf + TPM_RESPONSE_HEADER_LENGTH +
|
data = recvbuf + TPM_HDR_LEN + sizeof(uint32_t);
|
||||||
sizeof(uint32_t);
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case FIRMWARE_NV_INDEX:
|
case FIRMWARE_NV_INDEX:
|
||||||
break;
|
break;
|
||||||
case KERNEL_NV_INDEX:
|
case KERNEL_NV_INDEX:
|
||||||
handle_cap_flag_space(&data, index);
|
handle_cap_flag_space(&data, index);
|
||||||
*recv_len = data - recvbuf -
|
*recv_len = data - recvbuf;
|
||||||
TPM_RESPONSE_HEADER_LENGTH -
|
|
||||||
sizeof(uint32_t);
|
|
||||||
break;
|
break;
|
||||||
case TPM_CAP_FLAG_PERMANENT: {
|
case TPM_CAP_FLAG_PERMANENT: {
|
||||||
struct tpm_permanent_flags *pflags;
|
struct tpm_permanent_flags *pflags;
|
||||||
|
@ -166,15 +163,12 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
|
||||||
printf(" ** Unknown flags index %x\n", index);
|
printf(" ** Unknown flags index %x\n", index);
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
put_unaligned_be32(*recv_len,
|
put_unaligned_be32(*recv_len, recvbuf + TPM_HDR_LEN);
|
||||||
recvbuf +
|
|
||||||
TPM_RESPONSE_HEADER_LENGTH);
|
|
||||||
break;
|
break;
|
||||||
case TPM_CAP_NV_INDEX:
|
case TPM_CAP_NV_INDEX:
|
||||||
index = get_unaligned_be32(sendbuf + 18);
|
index = get_unaligned_be32(sendbuf + 18);
|
||||||
printf("Get cap nv index %#02x\n", index);
|
printf("Get cap nv index %#02x\n", index);
|
||||||
put_unaligned_be32(22, recvbuf +
|
put_unaligned_be32(22, recvbuf + TPM_HDR_LEN);
|
||||||
TPM_RESPONSE_HEADER_LENGTH);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf(" ** Unknown 0x65 command type %#02x\n",
|
printf(" ** Unknown 0x65 command type %#02x\n",
|
||||||
|
|
Loading…
Add table
Reference in a new issue