summaryrefslogtreecommitdiff
path: root/board/cr50/tpm_nvmem_ops.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/cr50/tpm_nvmem_ops.c')
-rw-r--r--board/cr50/tpm_nvmem_ops.c20
1 files changed, 20 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;
+}