summaryrefslogtreecommitdiff
path: root/include/nvmem_vars.h
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-02-28 20:11:28 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-04-05 09:21:44 -0700
commit171578b67f40355528cbb5f34b78e8e8ed83e335 (patch)
tree2303b74da9487ca2d046b93ad04212feff6164ac /include/nvmem_vars.h
parent1d6c7bb9773f76aa70ce65822fa001ff72892cd2 (diff)
downloadchrome-ec-171578b67f40355528cbb5f34b78e8e8ed83e335.tar.gz
cr50: complete support of the new NVMEM structure
This patch eliminates unnecessary legacy nvmem.c and nvmem_vars.c code and brings the code base to the state where the new NVMEM layout is fully functional. BRANCH=cr50, cr50-mp BUG=b:69907320, b:129710256 CQ-DEPEND=CL:1450278 TEST=the following tests pass: - test cases in ./test/nvmem.c - TCG suite (passes on par with the existing Cr50 code with the reduced code footprint TPM2 library) - Chrome OS device migrates from legacy to new implementation with user account maintained. - Chrome OS user account is maintained over AP and H1 reboots and deep sleep cycles. Change-Id: If4bc2dd125873a79dbe0e268eb32100a8b8b352d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1496607 Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'include/nvmem_vars.h')
-rw-r--r--include/nvmem_vars.h35
1 files changed, 32 insertions, 3 deletions
diff --git a/include/nvmem_vars.h b/include/nvmem_vars.h
index add14345e7..eec1e757a2 100644
--- a/include/nvmem_vars.h
+++ b/include/nvmem_vars.h
@@ -65,12 +65,32 @@ struct tuple {
int initvars(void);
/*
- * Look up a key, return a pointer to the tuple. If the key is not found,
- * return NULL. WARNING: The returned pointer is only valid until the next call
- * to setvar() or writevars(). Use it or lose it.
+ * Look up the key passed in the input tuple and fill the value, if found.
+ *
+ * The val_len field in the passed in tuple indicates how much room is
+ * available, the actual value size could be smaller.
+ *
+ * Return:
+ *
+ * EC_SUCCESS - if the key was found and there was enough room in the passed
+ * in tuple for the value.
+ * EC_ERROR_INVAL - if the key was not found.
+ *
+ * EC_ERROR_MEMORY_ALLOCATION - if the value would not fit into the supplied
+ * tuple.
*/
const struct tuple *getvar(const uint8_t *key, uint8_t key_len);
+/*
+ * Free memory held by the previously read tuple.
+ *
+ * Note that tuple address is not the address to be returned to the heap, so
+ * the user must use this function to free this memory. If var is NULL this
+ * function is a no-op.
+ *
+ */
+void freevar(const struct tuple *var);
+
/* Use these to access the data components of a valid struct tuple pointer */
const uint8_t *tuple_key(const struct tuple *);
const uint8_t *tuple_val(const struct tuple *);
@@ -88,6 +108,15 @@ int setvar(const uint8_t *key, uint8_t key_len,
*/
int writevars(void);
+/*
+ * A fully contained function which does not use any available nvmem_vars
+ * methods, as it is used solely for retrieving vars from legacy storage
+ * format. Runs only during migration.
+ */
+const struct tuple *legacy_getnextvar(const struct tuple *prev_var);
+
+int set_local_copy(void);
+
#ifdef __cplusplus
}
#endif