summaryrefslogtreecommitdiff
path: root/arch/sandbox/cpu/start.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-11-10 10:27:03 -0700
committerSimon Glass <sjg@chromium.org>2014-01-08 17:25:03 -0700
commit5c2859cdc30287b3593d9df88f48c31eecb0bbed (patch)
tree3d6552f961488657bf74869027e7ad4daf66dd73 /arch/sandbox/cpu/start.c
parentc5a62d4a7b4a971a1fb17d595f7c1e98a936a974 (diff)
downloadu-boot-imx-5c2859cdc30287b3593d9df88f48c31eecb0bbed.zip
u-boot-imx-5c2859cdc30287b3593d9df88f48c31eecb0bbed.tar.gz
u-boot-imx-5c2859cdc30287b3593d9df88f48c31eecb0bbed.tar.bz2
sandbox: Allow reading/writing of RAM buffer
It is useful to be able to save and restore the RAM contents of sandbox U-Boot either for setting up tests, for later analysys, or for chaining together multiple tests which need to keep the same memory contents. Add a function to provide a memory file for U-Boot. This is read on start-up and written when shutting down. If the file does not exist on start-up, it will be created when shutting down. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/sandbox/cpu/start.c')
-rw-r--r--arch/sandbox/cpu/start.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 579ece4..452f2a9 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -4,12 +4,11 @@
*/
#include <common.h>
+#include <os.h>
#include <asm/getopt.h>
#include <asm/sections.h>
#include <asm/state.h>
-#include <os.h>
-
DECLARE_GLOBAL_DATA_PTR;
int sandbox_early_getopt_check(void)
@@ -108,6 +107,25 @@ static int sandbox_cmdline_cb_interactive(struct sandbox_state *state,
SANDBOX_CMDLINE_OPT_SHORT(interactive, 'i', 0, "Enter interactive mode");
+static int sandbox_cmdline_cb_memory(struct sandbox_state *state,
+ const char *arg)
+{
+ int err;
+
+ /* For now assume we always want to write it */
+ state->write_ram_buf = true;
+ state->ram_buf_fname = arg;
+
+ if (os_read_ram_buf(arg)) {
+ printf("Failed to read RAM buffer\n");
+ return err;
+ }
+
+ return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(memory, 'm', 1,
+ "Read/write ram_buf memory contents from file");
+
int main(int argc, char *argv[])
{
struct sandbox_state *state;