On 12/29/2015 07:17 PM, Kevin O'Connor wrote:
Introduce helper function to call the TPM_ORD_GetCapability command.
Update all get capability callers to use this helper.
Signed-off-by: Kevin O'Connor
---
src/std/tcg.h | 17 +++---
src/tcgbios.c | 176 --
2 files changed, 57 insertions(+), 136 deletions(-)
diff --git a/src/std/tcg.h b/src/std/tcg.h
index 70daa41..9f7f021 100644
--- a/src/std/tcg.h
+++ b/src/std/tcg.h
@@ -254,13 +254,21 @@ struct tpm_rsp_extend {
} PACKED;
-struct tpm_req_getcap_perm_flags {
+struct tpm_req_getcap {
struct tpm_req_header hdr;
u32capArea;
u32subCapSize;
u32subCap;
} PACKED;
+#define TPM_CAP_FLAG 0x04
+#define TPM_CAP_PROPERTY 0x05
+#define TPM_CAP_FLAG_PERMANENT 0x108
+#define TPM_CAP_FLAG_VOLATILE0x109
+#define TPM_CAP_PROP_OWNER 0x111
+#define TPM_CAP_PROP_TIS_TIMEOUT 0x115
+#define TPM_CAP_PROP_DURATION0x120
+
struct tpm_permanent_flags {
u16tag;
@@ -286,13 +294,6 @@ struct tpm_res_getcap_perm_flags {
struct tpm_permanent_flags perm_flags;
} PACKED;
-struct tpm_req_getcap_stclear_flags {
-struct tpm_req_header hdr;
-u32capArea;
-u32subCapSize;
-u32subCap;
-} PACKED;
-
struct tpm_stclear_flags {
u16tag;
u8 flags[5];
diff --git a/src/tcgbios.c b/src/tcgbios.c
index 8f9f321..510d4b3 100644
--- a/src/tcgbios.c
+++ b/src/tcgbios.c
@@ -36,31 +36,6 @@ static const u8 PhysicalPresence_NOT_PRESENT_LOCK[] = {
0x00, 0x14 };
static const u8 CommandFlag_FALSE[1] = { 0x00 };
static const u8 CommandFlag_TRUE[1] = { 0x01 };
-static const u8 GetCapability_Permanent_Flags[] = {
-0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04,
-0x00, 0x00, 0x01, 0x08
-};
-
-static const u8 GetCapability_STClear_Flags[] = {
-0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04,
-0x00, 0x00, 0x01, 0x09
-};
-
-static const u8 GetCapability_OwnerAuth[] = {
-0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04,
-0x00, 0x00, 0x01, 0x11
-};
-
-static const u8 GetCapability_Timeouts[] = {
-0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04,
-0x00, 0x00, 0x01, 0x15
-};
-
-static const u8 GetCapability_Durations[] = {
-0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04,
-0x00, 0x00, 0x01, 0x20
-};
-
typedef u8 tpm_ppi_code;
@@ -257,39 +232,46 @@ tpm_set_failure(void)
TPM_working = 0;
}
+static int
+tpm_get_capability(u32 cap, u32 subcap, struct tpm_rsp_header *rsp, u32 rsize)
+{
+struct tpm_req_getcap trgc = {
+.hdr.tag = cpu_to_be16(TPM_TAG_RQU_CMD),
+.hdr.totlen = cpu_to_be32(sizeof(trgc)),
+.hdr.ordinal = cpu_to_be32(TPM_ORD_GetCapability),
+.capArea = cpu_to_be32(cap),
+.subCapSize = cpu_to_be32(sizeof(trgc.subCap)),
+.subCap = cpu_to_be32(subcap)
+};
+u32 resp_size = rsize;
+u32 rc = tpmhw_transmit(0, , , _size,
+TPM_DURATION_TYPE_SHORT);
Bug: -> rsp !
Otherwise it looks good.
Stefan
___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios