summaryrefslogtreecommitdiff
path: root/arch/sandbox/cpu/start.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-11-10 10:27:04 -0700
committerSimon Glass <sjg@chromium.org>2014-01-08 17:25:08 -0700
commit1209e2727c60d052ce875aa39bb8b9ba2edbfbdf (patch)
tree73c3077b54985be1e4424b64fbb8659aac47ed23 /arch/sandbox/cpu/start.c
parent5c2859cdc30287b3593d9df88f48c31eecb0bbed (diff)
downloadu-boot-imx-1209e2727c60d052ce875aa39bb8b9ba2edbfbdf.zip
u-boot-imx-1209e2727c60d052ce875aa39bb8b9ba2edbfbdf.tar.gz
u-boot-imx-1209e2727c60d052ce875aa39bb8b9ba2edbfbdf.tar.bz2
sandbox: Add facility to save/restore sandbox state
It is often useful to be able to save out the state from a sandbox test run, for analysis or to restore it later to continue a test. Add generic infrastructure for doing this using a device tree binary file. This is a flexible tagged file format which is already supported by U-Boot, and it supports hierarchy if needed. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Hung-ying Tyan <tyanh@chromium.org>
Diffstat (limited to 'arch/sandbox/cpu/start.c')
-rw-r--r--arch/sandbox/cpu/start.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 452f2a9..1df21d4 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -126,19 +126,56 @@ static int sandbox_cmdline_cb_memory(struct sandbox_state *state,
SANDBOX_CMDLINE_OPT_SHORT(memory, 'm', 1,
"Read/write ram_buf memory contents from file");
+static int sandbox_cmdline_cb_state(struct sandbox_state *state,
+ const char *arg)
+{
+ state->state_fname = arg;
+ return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(state, 's', 1, "Specify the sandbox state FDT");
+
+static int sandbox_cmdline_cb_read(struct sandbox_state *state,
+ const char *arg)
+{
+ state->read_state = true;
+ return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(read, 'r', 0, "Read the state FDT on startup");
+
+static int sandbox_cmdline_cb_write(struct sandbox_state *state,
+ const char *arg)
+{
+ state->write_state = true;
+ return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(write, 'w', 0, "Write state FDT on exit");
+
+static int sandbox_cmdline_cb_ignore_missing(struct sandbox_state *state,
+ const char *arg)
+{
+ state->ignore_missing_state_on_read = true;
+ return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(ignore_missing, 'n', 0,
+ "Ignore missing state on read");
+
int main(int argc, char *argv[])
{
struct sandbox_state *state;
- int err;
+ int ret;
- err = state_init();
- if (err)
- return err;
+ ret = state_init();
+ if (ret)
+ goto err;
state = state_get_current();
if (os_parse_args(state, argc, argv))
return 1;
+ ret = sandbox_read_state(state, state->state_fname);
+ if (ret)
+ goto err;
+
/* Do pre- and post-relocation init */
board_init_f(0);
@@ -146,4 +183,8 @@ int main(int argc, char *argv[])
/* NOTREACHED - board_init_r() does not return */
return 0;
+
+err:
+ printf("Error %d\n", ret);
+ return 1;
}