summaryrefslogtreecommitdiff
path: root/arch/sandbox
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-05-18 20:09:13 -0600
committerSimon Glass <sjg@chromium.org>2017-06-01 07:03:09 -0600
commit34b744beb866c9ae660f2851f9776f80e165d421 (patch)
tree33aef867d123887f4171a8fd2baa3432a7b1a1dd /arch/sandbox
parenta40cc8e12352ee35d095d29125fedd2eb2821228 (diff)
downloadu-boot-34b744beb866c9ae660f2851f9776f80e165d421.tar.gz
sandbox: Add a way to reset sandbox state for tests
Running a new test should reset the sandbox state to avoid tests interferring with each other. Move the existing state-reset code into a function so it can be used from tests. Also update the code to reset the SPI devices and adjust the test code to call it. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/cpu/state.c15
-rw-r--r--arch/sandbox/include/asm/state.h7
2 files changed, 18 insertions, 4 deletions
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index 2b4dbd341f..07584486db 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -351,6 +351,16 @@ bool state_get_skip_delays(void)
return state->skip_delays;
}
+void state_reset_for_test(struct sandbox_state *state)
+{
+ /* No reset yet, so mark it as such. Always allow power reset */
+ state->last_sysreset = SYSRESET_COUNT;
+ state->sysreset_allowed[SYSRESET_POWER] = true;
+
+ memset(&state->wdt, '\0', sizeof(state->wdt));
+ memset(state->spi, '\0', sizeof(state->spi));
+}
+
int state_init(void)
{
state = &main_state;
@@ -359,10 +369,7 @@ int state_init(void)
state->ram_buf = os_malloc(state->ram_size);
assert(state->ram_buf);
- /* No reset yet, so mark it as such. Always allow power reset */
- state->last_sysreset = SYSRESET_COUNT;
- state->sysreset_allowed[SYSRESET_POWER] = true;
-
+ state_reset_for_test(state);
/*
* Example of how to use GPIOs:
*
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 987cc7b49d..617f95291a 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -214,6 +214,13 @@ void state_set_skip_delays(bool skip_delays);
bool state_get_skip_delays(void);
/**
+ * state_reset_for_test() - Reset ready to re-run tests
+ *
+ * This clears out any test state ready for another test run.
+ */
+void state_reset_for_test(struct sandbox_state *state);
+
+/**
* Initialize the test system state
*/
int state_init(void);