summaryrefslogtreecommitdiff
path: root/common/cmd_bootm.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2008-08-15 08:24:45 -0500
committerWolfgang Denk <wd@denx.de>2008-08-26 23:48:01 +0200
commit40d7e99d374ba0a0a29cd1a8ba40d3b7c2c175c7 (patch)
treeaedac5a8fffc541a91f1948428c242291f9c7053 /common/cmd_bootm.c
parent40afac22a9c602e55c501c800f1c064324711b56 (diff)
downloadu-boot-imx-40d7e99d374ba0a0a29cd1a8ba40d3b7c2c175c7.zip
u-boot-imx-40d7e99d374ba0a0a29cd1a8ba40d3b7c2c175c7.tar.gz
u-boot-imx-40d7e99d374ba0a0a29cd1a8ba40d3b7c2c175c7.tar.bz2
bootm: refactor do_reset and os boot function args
There is no need for each OS specific function to call do_reset() we can just do it once in bootm. This means its feasible on an error for the OS boot function to return. Also, remove passing in cmd_tbl_t as its not needed by the OS boot functions. flag isn't currently used but might be in the future so we left it alone. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'common/cmd_bootm.c')
-rw-r--r--common/cmd_bootm.c67
1 files changed, 35 insertions, 32 deletions
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 5f7458b..0db7b75 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -92,8 +92,7 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
* - loaded (first part of) image to header load address,
* - disabled interrupts.
*/
-typedef void boot_os_fn (cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
+typedef int boot_os_fn (int flag, int argc, char *argv[],
bootm_headers_t *images); /* pointers to os/initrd/fdt */
extern boot_os_fn do_bootm_linux;
@@ -428,36 +427,36 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#ifdef CONFIG_SILENT_CONSOLE
fixup_silent_linux();
#endif
- do_bootm_linux (cmdtp, flag, argc, argv, &images);
+ do_bootm_linux (0, argc, argv, &images);
break;
case IH_OS_NETBSD:
- do_bootm_netbsd (cmdtp, flag, argc, argv, &images);
+ do_bootm_netbsd (0, argc, argv, &images);
break;
#ifdef CONFIG_LYNXKDI
case IH_OS_LYNXOS:
- do_bootm_lynxkdi (cmdtp, flag, argc, argv, &images);
+ do_bootm_lynxkdi (0, argc, argv, &images);
break;
#endif
case IH_OS_RTEMS:
- do_bootm_rtems (cmdtp, flag, argc, argv, &images);
+ do_bootm_rtems (0, argc, argv, &images);
break;
#if defined(CONFIG_CMD_ELF)
case IH_OS_VXWORKS:
- do_bootm_vxworks (cmdtp, flag, argc, argv, &images);
+ do_bootm_vxworks (0, argc, argv, &images);
break;
case IH_OS_QNX:
- do_bootm_qnxelf (cmdtp, flag, argc, argv, &images);
+ do_bootm_qnxelf (0, argc, argv, &images);
break;
#endif
#ifdef CONFIG_ARTOS
case IH_OS_ARTOS:
- do_bootm_artos (cmdtp, flag, argc, argv, &images);
+ do_bootm_artos (0, argc, argv, &images);
break;
#endif
}
@@ -465,10 +464,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
show_boot_progress (-9);
#ifdef DEBUG
puts ("\n## Control returned to monitor - resetting...\n");
- do_reset (cmdtp, flag, argc, argv);
#endif
- if (iflag)
- enable_interrupts();
+ do_reset (cmdtp, flag, argc, argv);
return 1;
}
@@ -983,8 +980,7 @@ static void fixup_silent_linux ()
/* OS booting routines */
/*******************************************************************/
-static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
+static int do_bootm_netbsd (int flag, int argc, char *argv[],
bootm_headers_t *images)
{
void (*loader)(bd_t *, image_header_t *, char *, char *);
@@ -996,7 +992,7 @@ static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
#if defined(CONFIG_FIT)
if (!images->legacy_hdr_valid) {
fit_unsupported_reset ("NetBSD");
- do_reset (cmdtp, flag, argc, argv);
+ return 1;
}
#endif
hdr = images->legacy_hdr_os;
@@ -1063,11 +1059,12 @@ static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
* r6: boot args string
*/
(*loader) (gd->bd, os_hdr, consdev, cmdline);
+
+ return 1;
}
#ifdef CONFIG_LYNXKDI
-static void do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
+static int do_bootm_lynxkdi (int flag, int argc, char *argv[],
bootm_headers_t *images)
{
image_header_t *hdr = &images->legacy_hdr_os_copy;
@@ -1075,16 +1072,17 @@ static void do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag,
#if defined(CONFIG_FIT)
if (!images->legacy_hdr_valid) {
fit_unsupported_reset ("Lynx");
- do_reset (cmdtp, flag, argc, argv);
+ return 1;
}
#endif
lynxkdi_boot ((image_header_t *)hdr);
+
+ return 1;
}
#endif /* CONFIG_LYNXKDI */
-static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
+static int do_bootm_rtems (int flag, int argc, char *argv[],
bootm_headers_t *images)
{
void (*entry_point)(bd_t *);
@@ -1092,7 +1090,7 @@ static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
#if defined(CONFIG_FIT)
if (!images->legacy_hdr_valid) {
fit_unsupported_reset ("RTEMS");
- do_reset (cmdtp, flag, argc, argv);
+ return 1;
}
#endif
@@ -1108,11 +1106,12 @@ static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
* r3: ptr to board info data
*/
(*entry_point)(gd->bd);
+
+ return 1;
}
#if defined(CONFIG_CMD_ELF)
-static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
+static int do_bootm_vxworks (int flag, int argc, char *argv[],
bootm_headers_t *images)
{
char str[80];
@@ -1120,17 +1119,18 @@ static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag,
#if defined(CONFIG_FIT)
if (!images->legacy_hdr_valid) {
fit_unsupported_reset ("VxWorks");
- do_reset (cmdtp, flag, argc, argv);
+ return 1;
}
#endif
sprintf(str, "%lx", images->ep); /* write entry-point into string */
setenv("loadaddr", str);
- do_bootvx(cmdtp, 0, 0, NULL);
+ do_bootvx(NULL, 0, 0, NULL);
+
+ return 1;
}
-static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
+static int do_bootm_qnxelf(int flag, int argc, char *argv[],
bootm_headers_t *images)
{
char *local_args[2];
@@ -1139,20 +1139,21 @@ static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag,
#if defined(CONFIG_FIT)
if (!images->legacy_hdr_valid) {
fit_unsupported_reset ("QNX");
- do_reset (cmdtp, flag, argc, argv);
+ return 1;
}
#endif
sprintf(str, "%lx", images->ep); /* write entry-point into string */
local_args[0] = argv[0];
local_args[1] = str; /* and provide it via the arguments */
- do_bootelf(cmdtp, 0, 2, local_args);
+ do_bootelf(NULL, 0, 2, local_args);
+
+ return 1;
}
#endif
#if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
-static void do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
+static int do_bootm_artos (int flag, int argc, char *argv[],
bootm_headers_t *images)
{
ulong top;
@@ -1165,7 +1166,7 @@ static void do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
#if defined(CONFIG_FIT)
if (!images->legacy_hdr_valid) {
fit_unsupported_reset ("ARTOS");
- do_reset (cmdtp, flag, argc, argv);
+ return 1;
}
#endif
@@ -1237,5 +1238,7 @@ static void do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
entry = (void (*)(bd_t *, char *, char **, ulong))images->ep;
(*entry) (kbd, cmdline, fwenv, top);
+
+ return 1;
}
#endif