*recv_len, code);
print_buffer(0, sendbuf, 1, send_size, 0);
switch (code) {
- case 0x65: /* get flags */
+ case TPM_CMD_GET_CAPABILITY:
type = get_unaligned_be32(sendbuf + 14);
switch (type) {
- case 4:
+ case TPM_CAP_FLAG:
index = get_unaligned_be32(sendbuf + 18);
printf("Get flags index %#02x\n", index);
*recv_len = 22;
break;
}
break;
- case 0x11: /* TPM_CAP_NV_INDEX */
+ case TPM_CAP_NV_INDEX:
index = get_unaligned_be32(sendbuf + 18);
printf("Get cap nv index %#02x\n", index);
put_unaligned_be32(22, recvbuf +
default:
printf(" ** Unknown 0x65 command type %#02x\n",
type);
- return -1;
+ return -ENOSYS;
}
break;
- case 0xcd: /* nvwrite */
+ case TPM_CMD_NV_WRITE_VALUE:
index = get_unaligned_be32(sendbuf + 10);
length = get_unaligned_be32(sendbuf + 18);
seq = index_to_seq(index);
if (seq < 0)
- return -1;
+ return -EINVAL;
printf("tpm: nvwrite index=%#02x, len=%#02x\n", index, length);
memcpy(&tpm->nvdata[seq], sendbuf + 22, length);
*recv_len = 12;
memset(recvbuf, '\0', *recv_len);
break;
- case 0xcf: /* nvread */
+ case TPM_CMD_NV_READ_VALUE: /* nvread */
index = get_unaligned_be32(sendbuf + 10);
length = get_unaligned_be32(sendbuf + 18);
seq = index_to_seq(index);
if (seq < 0)
- return -1;
+ return -EINVAL;
printf("tpm: nvread index=%#02x, len=%#02x\n", index, length);
*recv_len = TPM_RESPONSE_HEADER_LENGTH + sizeof(uint32_t) +
length;
sizeof(uint32_t), &tpm->nvdata[seq], length);
}
break;
- case 0x14: /* tpm extend */
+ case TPM_CMD_EXTEND: /* tpm extend */
case 0x15: /* pcr read */
case 0x5d: /* force clear */
case 0x6f: /* physical enable */
break;
default:
printf("Unknown tpm command %02x\n", code);
- return -1;
+ return -ENOSYS;
}
return 0;
TPM_CAP_VERSION_VAL = 0x0000001A,
};
+enum tmp_cap_flag {
+ TPM_CAP_FLAG_PERMANENT = 0x108,
+};
+
+#define TPM_TAG_PERMANENT_FLAGS 0x001f
+
#define TPM_NV_PER_GLOBALLOCK BIT(15)
#define TPM_NV_PER_PPREAD BIT(16)
#define TPM_NV_PER_PPWRITE BIT(0)
TPM_PUBEK_SIZE = 256,
};
+enum {
+ TPM_CMD_EXTEND = 0x14,
+ TPM_CMD_GET_CAPABILITY = 0x65,
+ TPM_CMD_NV_DEFINE_SPACE = 0xcc,
+ TPM_CMD_NV_WRITE_VALUE = 0xcd,
+ TPM_CMD_NV_READ_VALUE = 0xcf,
+};
+
/**
* TPM return codes as defined in the TCG Main specification
* (TPM Main Part 2 Structures; Specification version 1.2)
TPM2_CC_PCR_SETAUTHPOL = 0x012C,
TPM2_CC_DAM_RESET = 0x0139,
TPM2_CC_DAM_PARAMETERS = 0x013A,
+ TPM2_CC_NV_READ = 0x014E,
TPM2_CC_GET_CAPABILITY = 0x017A,
TPM2_CC_PCR_READ = 0x017E,
TPM2_CC_PCR_EXTEND = 0x0182,