]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: Move reading the RAM buffer into a better place
authorSimon Glass <sjg@chromium.org>
Tue, 26 Sep 2023 14:14:47 +0000 (08:14 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 6 Oct 2023 18:38:13 +0000 (14:38 -0400)
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>
arch/sandbox/cpu/start.c
arch/sandbox/cpu/state.c

index bbd9e77afed90673b4879d72f20c4505c71be4fa..8582f05162fa47cab328e1d7d73c72741403905b 100644 (file)
@@ -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);
index d67834988fd4127aff47c20d682210ebaaa7c24c..fcc0028ff4a2813f26121a1dbffbf22fc76f8fa0 100644 (file)
@@ -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) {