diff options
author | Vic Yang <victoryang@chromium.org> | 2013-05-08 00:21:03 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-05-07 16:02:30 -0700 |
commit | 0d99eadd7783a8b0a76241f36e3b2911526a7c8c (patch) | |
tree | 261b79811c08d480f6d72509c1d116cb6dd0dacc /chip/host/system.c | |
parent | 0a45fa17086d4556b7cb4ea0a9f53894197bc897 (diff) | |
download | chrome-ec-0d99eadd7783a8b0a76241f36e3b2911526a7c8c.tar.gz |
Add persistent storage for emulator
This is needed for non-volatile register emulation. Also, this can be
used to implement system jump or reset flags.
BUG=chrome-os-partner:19235
TEST=Run utils test. Check persistent storage file exists.
BRANCH=None
Change-Id: I699f95718ef6f5de6c3bbb4e37619ee015fb6c4a
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50313
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/host/system.c')
-rw-r--r-- | chip/host/system.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/chip/host/system.c b/chip/host/system.c index 50da8db9c0..c290f9ef69 100644 --- a/chip/host/system.c +++ b/chip/host/system.c @@ -9,6 +9,7 @@ #include "host_test.h" #include "system.h" +#include "persistence.h" #define SHARED_MEM_SIZE 512 /* bytes */ char __shared_mem_buf[SHARED_MEM_SIZE]; @@ -63,6 +64,34 @@ int system_set_vbnvcontext(const uint8_t *block) return EC_ERROR_UNIMPLEMENTED; } +int system_set_scratchpad(uint32_t value) +{ + FILE *f = get_persistent_storage("scratchpad", "w"); + + fprintf(f, "%lu", value); + release_persistent_storage(f); + + return EC_SUCCESS; +} + +uint32_t system_get_scratchpad(void) +{ + FILE *f = get_persistent_storage("scratchpad", "r"); + uint32_t value; + int success; + + if (f == NULL) + return 0; + + success = fscanf(f, "%lu", &value); + release_persistent_storage(f); + + if (success) + return value; + else + return 0; +} + int system_usable_ram_end(void) { return (int)(__shared_mem_buf + SHARED_MEM_SIZE); |