diff options
author | Caveh Jalali <caveh@chromium.org> | 2019-10-10 19:26:23 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-31 03:16:47 +0000 |
commit | 0038f1e0dfd6738d71e07de60a0240e449d3f787 (patch) | |
tree | 357a4fbc1a0b1342488e950988f0fde0a885df30 | |
parent | b64ff5df1f93d5233cc257d08e451d71c5522d11 (diff) | |
download | chrome-ec-0038f1e0dfd6738d71e07de60a0240e449d3f787.tar.gz |
system.c: reset statics for testing
this adds a function to reset the state information generated by
system_common_pre_init() for testing scenarios that need to call it
multiple times. on the EC, main memory (.data + .bss) is
reinitialized across sysjumps, so this happens automatically, but we
can't really do that from unit tests. so, add a function to reset the
relevant static variables to emulate main memory getting
reinitialized.
BRANCH=none
BUG=b:142031466
TEST=make buildall passes
Change-Id: I1f65902c21ab6fc17c32388795cfef19c84d8cc8
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1855644
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r-- | common/system.c | 7 | ||||
-rw-r--r-- | include/system.h | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/common/system.c b/common/system.c index e1b8d0b396..5ae642a560 100644 --- a/common/system.c +++ b/common/system.c @@ -1568,3 +1568,10 @@ void clock_enable_module(enum module_id module, int enable) * function. */ } + +__test_only void system_common_reset_state(void) +{ + jdata = 0; + reset_flags = 0; + jumped_to_image = 0; +} diff --git a/include/system.h b/include/system.h index 9b6bf0ff48..0d785c6899 100644 --- a/include/system.h +++ b/include/system.h @@ -49,6 +49,13 @@ void system_pre_init(void); void system_common_pre_init(void); /** + * System common re-initialization; called to reset persistent state + * left by system_common_pre_init(). This is useful for testing + * scenarios calling system_common_pre_init() multiple times. + */ +__test_only void system_common_reset_state(void); + +/** * Set up flags that should be saved to battery backed RAM. * * @param reset_flags - flags passed into system_reset |