sandbox: tpm: Tidy up enums and return values
Use an enum for command values instead of open-coding them. This removes
the need for comments. Also make sure the driver returns proper error
numbers instead of -1.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/include/tpm-v1.h b/include/tpm-v1.h
index 6b4941e..29788b5 100644
--- a/include/tpm-v1.h
+++ b/include/tpm-v1.h
@@ -81,6 +81,12 @@
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)
@@ -93,6 +99,14 @@
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)
diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index 780e061..c77b416 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -83,6 +83,7 @@
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,