summaryrefslogtreecommitdiff
path: root/include/nvmem.h
diff options
context:
space:
mode:
authorScott <scollyer@chromium.org>2016-05-20 11:28:19 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-05-26 18:08:57 -0700
commit7184144012cdcfdede45efc3ad3b121ec16ddacf (patch)
treeae46cd084ce5270b68588c872b9fee379d267572 /include/nvmem.h
parentdf35737d63811cd7ad9e4ce62406448fd709b431 (diff)
downloadchrome-ec-7184144012cdcfdede45efc3ad3b121ec16ddacf.tar.gz
Cr50: NvMem: Connected function stubs in /board/tpm2/NVMem.c
Used #define CONFIG_FLASH_NVMEM to have functions in /board/tpm2/NVMem.c utlitize on chip Nvmem functions. On chip NV Memory availability is tied to an internal nvmem error state which itself only depends on finding at least one valid partition. Added nvmem_is_different and nvmem_move functions which were needed to complete the tpm2 platform interface. In addition, added unit tests to support these two new functions. BUG=chrome-os-partner:44745 BRANCH=none TEST=manual make runtests TEST_LIST_HOST=nvmem and verify that all tests pass. Tested with tcg_test utility to test reads/writes using the command "build/test-tpm2/install/bin/compliance --ntpm localhost:9883 --select CPCTPM_TC2_3_33_07_01". Change-Id: I475fdd1331e28ede00f9b674c7bee1536fa9ea48 Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/346236 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'include/nvmem.h')
-rw-r--r--include/nvmem.h37
1 files changed, 34 insertions, 3 deletions
diff --git a/include/nvmem.h b/include/nvmem.h
index 408e0002f4..2785cfdafc 100644
--- a/include/nvmem.h
+++ b/include/nvmem.h
@@ -79,6 +79,25 @@ struct nvmem_tag {
int nvmem_init(void);
/**
+ * Get Nvmem internal error state
+ *
+ * @return nvmem_error_state variable.
+ */
+int nvmem_get_error_state(void);
+
+/**
+ * Compare 'size' amount of bytes in NvMem
+ *
+ * @param offset: Offset (in bytes) into NVmem logical space
+ * @param size: Number of bytes to compare
+ * @param data: Pointer to data to be compared with
+ * @param user: Data section within NvMem space
+ * @return 0 if the data is same, non-zero if data is different
+ */
+int nvmem_is_different(uint32_t offset, uint32_t size,
+ void *data, enum nvmem_users user);
+
+/**
* Read 'size' amount of bytes from NvMem
*
* @param startOffset: Offset (in bytes) into NVmem logical space
@@ -88,7 +107,7 @@ int nvmem_init(void);
* @return EC_ERROR_OVERFLOW (non-zero) if the read operation would exceed the
* buffer length of the given user, otherwise EC_SUCCESS.
*/
-int nvmem_read(unsigned int startOffset, unsigned int size,
+int nvmem_read(uint32_t startOffset, uint32_t size,
void *data, enum nvmem_users user);
/**
@@ -102,10 +121,22 @@ int nvmem_read(unsigned int startOffset, unsigned int size,
* EC_ERROR_TIMEOUT if nvmem cache buffer is not available
* EC_SUCCESS if no errors.
*/
-int nvmem_write(unsigned int startOffset, unsigned int size,
+int nvmem_write(uint32_t startOffset, uint32_t size,
void *data, enum nvmem_users user);
-
+/**
+ * Move 'size' amount of bytes within NvMem
+ *
+ * @param src_offset: source offset within NvMem logical space
+ * @param dest_offset: destination offset within NvMem logical space
+ * @param size: Number of bytes to move
+ * @param user: Data section within NvMem space
+ * @return EC_ERROR_OVERFLOW if write exceeds buffer length
+ * EC_ERROR_TIMEOUT if nvmem cache buffer is not available
+ * EC_SUCCESS if no errors.
+ */
+int nvmem_move(uint32_t src_offset, uint32_t dest_offset, uint32_t size,
+ enum nvmem_users user);
/**
* Commit all previous NvMem writes to flash
*