]> git.sur5r.net Git - u-boot/commitdiff
Add a 'fake' go command to the bootm command
authorSimon Glass <sjg@chromium.org>
Tue, 11 Jun 2013 18:14:48 +0000 (11:14 -0700)
committerTom Rini <trini@ti.com>
Wed, 26 Jun 2013 14:18:56 +0000 (10:18 -0400)
For tracing it is useful to run as much of U-Boot as possible so as to get
a complete picture. Quite a bit of work happens in bootm, and we don't want
to have to stop tracing before bootm starts.

Add a way of doing a 'fake' boot of the OS - which does everything up to
the point where U-Boot is about to jump to the OS image. This allows
tracing to record right until the end.

This requires arch support to work.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/cmd_bootm.c
include/image.h

index ffca8e263bb30878af28947ad6afe522a0f7e4c1..bf14a0e35e111398ec321afd6322a05a2cfccf9d 100644 (file)
@@ -499,6 +499,7 @@ static cmd_tbl_t cmd_bootm_sub[] = {
        U_BOOT_CMD_MKENT(cmdline, 0, 1, (void *)BOOTM_STATE_OS_CMDLINE, "", ""),
        U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""),
        U_BOOT_CMD_MKENT(prep, 0, 1, (void *)BOOTM_STATE_OS_PREP, "", ""),
+       U_BOOT_CMD_MKENT(fake, 0, 1, (void *)BOOTM_STATE_OS_FAKE_GO, "", ""),
        U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""),
 };
 
@@ -539,6 +540,8 @@ static int boot_selected_os(int argc, char * const argv[], int state,
 #endif
        arch_preboot_os();
        boot_fn(state, argc, argv, images);
+       if (state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */
+               return 0;
        bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED);
 #ifdef DEBUG
        puts("\n## Control returned to monitor - resetting...\n");
@@ -645,6 +648,17 @@ static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
        if (!ret && (states & BOOTM_STATE_OS_PREP))
                ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images);
 
+#ifdef CONFIG_TRACE
+       /* Pretend to run the OS, then run a user command */
+       if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
+               char *cmd_list = getenv("fakegocmd");
+
+               ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_FAKE_GO,
+                               images, boot_fn, &iflag);
+               if (!ret && cmd_list)
+                       ret = run_command_list(cmd_list, -1, flag);
+       }
+#endif
        /* Now run the OS! We hope this doesn't return */
        if (!ret && (states & BOOTM_STATE_OS_GO))
                ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_GO,
@@ -754,7 +768,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START |
                BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER |
                BOOTM_STATE_LOADOS | BOOTM_STATE_OS_PREP |
-               BOOTM_STATE_OS_GO, &images, 1);
+               BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO, &images, 1);
 }
 
 int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
@@ -1731,7 +1745,8 @@ int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                return 1;
 
        ret = do_bootm_states(cmdtp, flag, argc, argv,
-                             BOOTM_STATE_OS_GO, &images, 1);
+                             BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO,
+                             &images, 1);
 
        return ret;
 }
index 8675a82854a7c0d231ffcc5eb6d4f5a0c972eae0..4415bcf279e530bb39068baeea762828cd983a14 100644 (file)
@@ -328,7 +328,8 @@ typedef struct bootm_headers {
 #define        BOOTM_STATE_OS_CMDLINE  (0x00000040)
 #define        BOOTM_STATE_OS_BD_T     (0x00000080)
 #define        BOOTM_STATE_OS_PREP     (0x00000100)
-#define        BOOTM_STATE_OS_GO       (0x00000200)
+#define        BOOTM_STATE_OS_FAKE_GO  (0x00000200)    /* 'Almost' run the OS */
+#define        BOOTM_STATE_OS_GO       (0x00000400)
        int             state;
 
 #ifdef CONFIG_LMB