aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-09-26 08:14:47 -0600
committerTom Rini <trini@konsulko.com>2023-09-26 11:25:25 -0400
commit33940ab7be025f85c652595db6abf9de98fd0eb7 (patch)
tree353de3fe4b4112c3f25dfe825ac824c20272e157
parent15b0353327d66e54196127d03a8112890f448848 (diff)
downloadu-boot-33940ab7be025f85c652595db6abf9de98fd0eb7.zip
u-boot-33940ab7be025f85c652595db6abf9de98fd0eb7.tar.gz
u-boot-33940ab7be025f85c652595db6abf9de98fd0eb7.tar.bz2
sandbox: Move reading the RAM buffer into a better place
This should not happen in the argument-parsing function. Move it to the main program. Add some debugging for reading/writing. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--arch/sandbox/cpu/start.c19
-rw-r--r--arch/sandbox/cpu/state.c1
2 files changed, 12 insertions, 8 deletions
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index bbd9e77..8582f05 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -272,17 +272,9 @@ SANDBOX_CMDLINE_OPT_SHORT(program, 'p', 1, "U-Boot program name");
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;
-
- err = os_read_ram_buf(arg);
- if (err) {
- printf("Failed to read RAM buffer '%s': %d\n", arg, err);
- return err;
- }
state->ram_buf_read = true;
return 0;
@@ -512,6 +504,17 @@ int sandbox_main(int argc, char *argv[])
if (os_parse_args(state, argc, argv))
return 1;
+ if (state->ram_buf_fname) {
+ ret = os_read_ram_buf(state->ram_buf_fname);
+ if (ret) {
+ printf("Failed to read RAM buffer '%s': %d\n",
+ state->ram_buf_fname, ret);
+ } else {
+ state->ram_buf_read = true;
+ log_debug("Read RAM buffer from '%s'\n", state->ram_buf_fname);
+ }
+ }
+
/* Remove old memory file if required */
if (state->ram_buf_rm && state->ram_buf_fname) {
os_unlink(state->ram_buf_fname);
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index d678349..fcc0028 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -513,6 +513,7 @@ int state_uninit(void)
printf("Failed to write RAM buffer\n");
return err;
}
+ log_debug("Wrote RAM to file '%s'\n", state->ram_buf_fname);
}
if (state->write_state) {