summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-01-08 16:13:08 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-01-09 23:47:07 -0800
commit618b127c4903a171731730b4b53472f8c645e543 (patch)
tree2fb79e89acc095d2460c215d2a562d0f00e749f6 /test
parent8734b70ff56e48900e4aaa68c1c56e84d60ce2ac (diff)
downloadchrome-ec-618b127c4903a171731730b4b53472f8c645e543.tar.gz
nvmem_vars: use dynamic memory allocation
To avoid SRAM footprint, let's use dynamic memory allocation in nvram_vars. No one is using this module yet, but the cr50 use case is coming up. BRANCH=none BUG=chrome-os-partner:61107 TEST=make buildall -j passes Change-Id: I21534430217ad387a3787fcc127da596a1b48e03 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/426088 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/nvmem_vars.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/test/nvmem_vars.c b/test/nvmem_vars.c
index 1ea2a312c6..56b96ef054 100644
--- a/test/nvmem_vars.c
+++ b/test/nvmem_vars.c
@@ -21,15 +21,29 @@ uint32_t nvmem_user_sizes[] = {
};
BUILD_ASSERT(ARRAY_SIZE(nvmem_user_sizes) == NVMEM_NUM_USERS);
-/* Internal functions exported for test */
-void release_local_copy(void);
-
/****************************************************************************/
/* Mock the flash storage */
static uint8_t ram_buffer[CONFIG_FLASH_NVMEM_VARS_USER_SIZE];
static uint8_t flash_buffer[CONFIG_FLASH_NVMEM_VARS_USER_SIZE];
+extern char *rbuf;
+
+/* Internal functions exported for test */
+void release_local_copy(void)
+{
+ rbuf = NULL;
+}
+
+int get_local_copy(void)
+{
+ if (!rbuf) {
+ memcpy(ram_buffer, flash_buffer, sizeof(ram_buffer));
+ rbuf = (char *)ram_buffer;
+ }
+ return EC_SUCCESS;
+}
+
int nvmem_read(uint32_t startOffset, uint32_t size,
void *data_, enum nvmem_users user)
{