- if (images.legacy_hdr_valid) {
- if (image_get_type (&images.legacy_hdr_os_copy) == IH_TYPE_MULTI)
- puts ("WARNING: legacy format multi component "
- "image overwritten\n");
- } else {
- puts ("ERROR: new format image overwritten - "
- "must RESET the board to recover\n");
- show_boot_progress (-113);
- do_reset (cmdtp, flag, argc, argv);
+ return BOOTM_ERR_OVERLAP;
+ }
+
+ return 0;
+}
+
+static int bootm_start_standalone(ulong iflag, int argc, char *argv[])
+{
+ char *s;
+ int (*appl)(int, char *[]);
+
+ /* Don't start if "autostart" is set to "no" */
+ if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) {
+ char buf[32];
+ sprintf(buf, "%lX", images.os.image_len);
+ setenv("filesize", buf);
+ return 0;
+ }
+ appl = (int (*)(int, char *[]))ntohl(images.ep);
+ (*appl)(argc-1, &argv[1]);
+
+ return 0;
+}
+
+/* we overload the cmd field with our state machine info instead of a
+ * function pointer */
+cmd_tbl_t cmd_bootm_sub[] = {
+ U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""),
+ U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""),
+#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC)
+ U_BOOT_CMD_MKENT(ramdisk, 0, 1, (void *)BOOTM_STATE_RAMDISK, "", ""),
+#endif
+#ifdef CONFIG_OF_LIBFDT
+ U_BOOT_CMD_MKENT(fdt, 0, 1, (void *)BOOTM_STATE_FDT, "", ""),
+#endif
+ U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""),
+ U_BOOT_CMD_MKENT(cmdline, 0, 1, (void *)BOOTM_STATE_OS_CMDLINE, "", ""),
+ U_BOOT_CMD_MKENT(prep, 0, 1, (void *)BOOTM_STATE_OS_PREP, "", ""),
+ U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""),
+};
+
+int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ int ret = 0;
+ int state;
+ cmd_tbl_t *c;
+ boot_os_fn *boot_fn;
+
+ c = find_cmd_tbl(argv[1], &cmd_bootm_sub[0], ARRAY_SIZE(cmd_bootm_sub));
+
+ if (c) {
+ state = (int)c->cmd;
+
+ /* treat start special since it resets the state machine */
+ if (state == BOOTM_STATE_START) {
+ argc--;
+ argv++;
+ return bootm_start(cmdtp, flag, argc, argv);