diff options
-rw-r--r-- | board/cr50/tpm_nvmem_ops.c | 20 | ||||
-rw-r--r-- | board/cr50/tpm_nvmem_ops.h | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/board/cr50/tpm_nvmem_ops.c b/board/cr50/tpm_nvmem_ops.c index 23a8ead1cf..ed5d438204 100644 --- a/board/cr50/tpm_nvmem_ops.c +++ b/board/cr50/tpm_nvmem_ops.c @@ -4,6 +4,8 @@ * found in the LICENSE file. */ +#include <stddef.h> + #include "common.h" #include "console.h" #include "tpm_nvmem_ops.h" @@ -95,3 +97,21 @@ enum tpm_write_rv write_tpm_nvmem_hidden(uint16_t object_index, return ret; } + +size_t read_tpm_nvmem_size(uint16_t obj_index) +{ + TPM_HANDLE object_handle; + NV_INDEX nvIndex; + uint32_t handle_addr; + + object_handle = HR_NV_INDEX | obj_index; + + handle_addr = NvEarlyStageFindHandle(object_handle); + if (!handle_addr) + return 0; + + /* Get properties of this index as stored in nvmem. */ + NvReadIndexInfo(object_handle, handle_addr, &nvIndex); + + return nvIndex.publicArea.dataSize; +} diff --git a/board/cr50/tpm_nvmem_ops.h b/board/cr50/tpm_nvmem_ops.h index 2476b62b0f..ef1c5a07fc 100644 --- a/board/cr50/tpm_nvmem_ops.h +++ b/board/cr50/tpm_nvmem_ops.h @@ -43,4 +43,7 @@ enum tpm_write_rv write_tpm_nvmem_hidden(uint16_t object_index, void *obj_value, int commit); +/* return size of hidden nvmem object, 0 if not found */ +size_t read_tpm_nvmem_size(uint16_t obj_index); + #endif /* ! __EC_BOARD_CR50_TPM_NVMEM_OPS_H */ |