diff options
Diffstat (limited to 'src/security/tpm/tss.h')
-rw-r--r-- | src/security/tpm/tss.h | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/security/tpm/tss.h b/src/security/tpm/tss.h index 3a019ead32..c9aec08262 100644 --- a/src/security/tpm/tss.h +++ b/src/security/tpm/tss.h @@ -33,16 +33,31 @@ */ tpm_result_t tlcl_lib_init(void); -/* Commands */ +/** + * Query active TPM family. Returns TPM_UNKNOWN if uninitialized and TPM_1 or TPM_2 otherwise. + */ +static inline enum tpm_family tlcl_get_family(void) +{ + /* Defined in tss/tss.c */ + extern enum tpm_family tlcl_tpm_family; + + if (CONFIG(TPM1) && CONFIG(TPM2)) + return tlcl_tpm_family; + if (CONFIG(TPM1)) + return TPM_1; + if (CONFIG(TPM2)) + return TPM_2; + return TPM_UNKNOWN; +} -extern enum tpm_family tlcl_tpm_family; +/* Commands */ -#define TLCL_CALL(name, ...) do { \ - if (CONFIG(TPM1) && (!CONFIG(TPM2) || tlcl_tpm_family == TPM_1)) \ - return tlcl1_##name(__VA_ARGS__); \ - if (CONFIG(TPM2) && (!CONFIG(TPM1) || tlcl_tpm_family == TPM_2)) \ - return tlcl2_##name(__VA_ARGS__); \ - return TPM_CB_INTERNAL_INCONSISTENCY; \ +#define TLCL_CALL(name, ...) do { \ + if (tlcl_get_family() == TPM_1) \ + return tlcl1_##name(__VA_ARGS__); \ + if (tlcl_get_family() == TPM_2) \ + return tlcl2_##name(__VA_ARGS__); \ + return TPM_CB_INTERNAL_INCONSISTENCY; \ } while (0) /** |