summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2008-08-15 08:24:36 -0500
committerWolfgang Denk <wd@denx.de>2008-08-26 23:31:33 +0200
commitc160a9544743e80e8889edb2275538e7764ce334 (patch)
tree484a54af158348313ed5f3b4890a6bbb56e7e468
parent20220d22b9f41446288588cd2e457e0077a18bed (diff)
downloadtalos-obmc-uboot-c160a9544743e80e8889edb2275538e7764ce334.tar.gz
talos-obmc-uboot-c160a9544743e80e8889edb2275538e7764ce334.zip
bootm: refactor entry point code
Move entry point code out of each arch and into common code. Keep the entry point in the bootm_headers_t images struct. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
-rw-r--r--common/cmd_bootm.c31
-rw-r--r--include/image.h2
-rw-r--r--lib_arm/bootm.c19
-rw-r--r--lib_avr32/bootm.c19
-rw-r--r--lib_blackfin/bootm.c19
-rw-r--r--lib_m68k/bootm.c19
-rw-r--r--lib_microblaze/bootm.c19
-rw-r--r--lib_mips/bootm.c18
-rw-r--r--lib_nios2/bootm.c20
-rw-r--r--lib_ppc/bootm.c22
-rw-r--r--lib_sh/bootm.c19
-rw-r--r--lib_sparc/bootm.c12
12 files changed, 37 insertions, 182 deletions
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 0b14b066f5..3f63b847f0 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -205,6 +205,23 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1;
}
+ /* find kernel entry point */
+ if (images.legacy_hdr_valid) {
+ images.ep = image_get_ep (&images.legacy_hdr_os_copy);
+#if defined(CONFIG_FIT)
+ } else if (images.fit_uname_os) {
+ ret = fit_image_get_entry (images.fit_hdr_os,
+ images.fit_noffset_os, &images.ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ return 1;
+ }
+#endif
+ } else {
+ puts ("Could not find kernel entry point!\n");
+ return 1;
+ }
+
image_start = (ulong)os_hdr;
load_end = 0;
type_name = genimg_get_type_name (type);
@@ -942,7 +959,7 @@ static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
cmdline = "";
}
- loader = (void (*)(bd_t *, image_header_t *, char *, char *))image_get_ep (hdr);
+ loader = (void (*)(bd_t *, image_header_t *, char *, char *))images->ep;
printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
(ulong)loader);
@@ -981,7 +998,6 @@ static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
int argc, char *argv[],
bootm_headers_t *images)
{
- image_header_t *hdr = &images->legacy_hdr_os_copy;
void (*entry_point)(bd_t *);
#if defined(CONFIG_FIT)
@@ -991,7 +1007,7 @@ static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
}
#endif
- entry_point = (void (*)(bd_t *))image_get_ep (hdr);
+ entry_point = (void (*)(bd_t *))images->ep;
printf ("## Transferring control to RTEMS (at address %08lx) ...\n",
(ulong)entry_point);
@@ -1011,7 +1027,6 @@ static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag,
bootm_headers_t *images)
{
char str[80];
- image_header_t *hdr = &images->legacy_hdr_os_copy;
#if defined(CONFIG_FIT)
if (!images->legacy_hdr_valid) {
@@ -1020,7 +1035,7 @@ static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag,
}
#endif
- sprintf(str, "%x", image_get_ep (hdr)); /* write entry-point into string */
+ sprintf(str, "%lx", images->ep); /* write entry-point into string */
setenv("loadaddr", str);
do_bootvx(cmdtp, 0, 0, NULL);
}
@@ -1031,7 +1046,6 @@ static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag,
{
char *local_args[2];
char str[16];
- image_header_t *hdr = &images->legacy_hdr_os_copy;
#if defined(CONFIG_FIT)
if (!images->legacy_hdr_valid) {
@@ -1040,7 +1054,7 @@ static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag,
}
#endif
- sprintf(str, "%x", image_get_ep (hdr)); /* write entry-point into string */
+ 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);
@@ -1058,7 +1072,6 @@ static void do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
int i, j, nxt, len, envno, envsz;
bd_t *kbd;
void (*entry)(bd_t *bd, char *cmdline, char **fwenv, ulong top);
- image_header_t *hdr = &images->legacy_hdr_os_copy;
#if defined(CONFIG_FIT)
if (!images->legacy_hdr_valid) {
@@ -1133,7 +1146,7 @@ static void do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
}
*ss++ = NULL; /* terminate */
- entry = (void (*)(bd_t *, char *, char **, ulong))image_get_ep (hdr);
+ entry = (void (*)(bd_t *, char *, char **, ulong))images->ep;
(*entry) (kbd, cmdline, fwenv, top);
}
#endif
diff --git a/include/image.h b/include/image.h
index 4b9c582718..e16c253405 100644
--- a/include/image.h
+++ b/include/image.h
@@ -219,6 +219,8 @@ typedef struct bootm_headers {
#endif
#endif
+ ulong ep; /* entry point of OS */
+
int verify; /* getenv("verify")[0] != 'n' */
struct lmb *lmb; /* for memory mgmt */
} bootm_headers_t;
diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c
index 955a1ae3a2..5660a503dc 100644
--- a/lib_arm/bootm.c
+++ b/lib_arm/bootm.c
@@ -62,7 +62,6 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images)
{
ulong initrd_start, initrd_end;
- ulong ep = 0;
bd_t *bd = gd->bd;
char *s;
int machid = bd->bi_arch_number;
@@ -73,23 +72,7 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
char *commandline = getenv ("bootargs");
#endif
- /* find kernel entry point */
- if (images->legacy_hdr_valid) {
- ep = image_get_ep (&images->legacy_hdr_os_copy);
-#if defined(CONFIG_FIT)
- } else if (images->fit_uname_os) {
- ret = fit_image_get_entry (images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts ("Can't get entry point property!\n");
- goto error;
- }
-#endif
- } else {
- puts ("Could not find kernel entry point!\n");
- goto error;
- }
- theKernel = (void (*)(int, int, uint))ep;
+ theKernel = (void (*)(int, int, uint))images->ep;
s = getenv ("machid");
if (s) {
diff --git a/lib_avr32/bootm.c b/lib_avr32/bootm.c
index 60e6b36369..7beab99868 100644
--- a/lib_avr32/bootm.c
+++ b/lib_avr32/bootm.c
@@ -177,29 +177,12 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images)
{
ulong initrd_start, initrd_end;
- ulong ep = 0;
void (*theKernel)(int magic, void *tagtable);
struct tag *params, *params_start;
char *commandline = getenv("bootargs");
int ret;
- /* find kernel entry point */
- if (images->legacy_hdr_valid) {
- ep = image_get_ep (&images->legacy_hdr_os_copy);
-#if defined(CONFIG_FIT)
- } else if (images->fit_uname_os) {
- ret = fit_image_get_entry (images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts ("Can't get entry point property!\n");
- goto error;
- }
-#endif
- } else {
- puts ("Could not find kernel entry point!\n");
- goto error;
- }
- theKernel = (void *)ep;
+ theKernel = (void *)images->ep;
ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_AVR32,
&initrd_start, &initrd_end);
diff --git a/lib_blackfin/bootm.c b/lib_blackfin/bootm.c
index 54f69a92c7..f789e24edb 100644
--- a/lib_blackfin/bootm.c
+++ b/lib_blackfin/bootm.c
@@ -38,29 +38,12 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
{
int (*appl) (char *cmdline);
char *cmdline;
- ulong ep = 0;
#ifdef SHARED_RESOURCES
swap_to(FLASH);
#endif
- /* find kernel entry point */
- if (images->legacy_hdr_valid) {
- ep = image_get_ep (&images->legacy_hdr_os_copy);
-#if defined(CONFIG_FIT)
- } else if (images->fit_uname_os) {
- int ret = fit_image_get_entry (images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts ("Can't get entry point property!\n");
- goto error;
- }
-#endif
- } else {
- puts ("Could not find kernel entry point!\n");
- goto error;
- }
- appl = (int (*)(char *))ep;
+ appl = (int (*)(char *))images->ep;
printf("Starting Kernel at = %x\n", appl);
cmdline = make_command_line();
diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c
index b45203d170..fe658fea0c 100644
--- a/lib_m68k/bootm.c
+++ b/lib_m68k/bootm.c
@@ -57,7 +57,6 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
ulong cmd_start, cmd_end;
ulong bootmap_base;
bd_t *kbd;
- ulong ep = 0;
void (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
struct lmb *lmb = images->lmb;
@@ -94,23 +93,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
}
set_clocks_in_mhz(kbd);
- /* find kernel entry point */
- if (images->legacy_hdr_valid) {
- ep = image_get_ep (&images->legacy_hdr_os_copy);
-#if defined(CONFIG_FIT)
- } else if (images->fit_uname_os) {
- ret = fit_image_get_entry (images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts ("Can't get entry point property!\n");
- goto error;
- }
-#endif
- } else {
- puts ("Could not find kernel entry point!\n");
- goto error;
- }
- kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
+ kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))images->ep;
/* find ramdisk */
ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_M68K,
diff --git a/lib_microblaze/bootm.c b/lib_microblaze/bootm.c
index 68edcdba1d..baf6d773f6 100644
--- a/lib_microblaze/bootm.c
+++ b/lib_microblaze/bootm.c
@@ -40,25 +40,8 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
/* First parameter is mapped to $r5 for kernel boot args */
void (*theKernel) (char *);
char *commandline = getenv ("bootargs");
- ulong ep = 0;
- /* find kernel entry point */
- if (images->legacy_hdr_valid) {
- ep = image_get_ep (&images->legacy_hdr_os_copy);
-#if defined(CONFIG_FIT)
- } else if (images->fit_uname_os) {
- int ret = fit_image_get_entry (images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts ("Can't get entry point property!\n");
- goto error;
- }
-#endif
- } else {
- puts ("Could not find kernel entry point!\n");
- goto error;
- }
- theKernel = (void (*)(char *))ep;
+ theKernel = (void (*)(char *))images->ep;
show_boot_progress (15);
diff --git a/lib_mips/bootm.c b/lib_mips/bootm.c
index 53e8e19c94..7df6ce66a5 100644
--- a/lib_mips/bootm.c
+++ b/lib_mips/bootm.c
@@ -49,7 +49,6 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images)
{
ulong initrd_start, initrd_end;
- ulong ep = 0;
void (*theKernel) (int, char **, char **, int *);
char *commandline = getenv ("bootargs");
char env_buf[12];
@@ -57,22 +56,7 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
char *cp;
/* find kernel entry point */
- if (images->legacy_hdr_valid) {
- ep = image_get_ep (&images->legacy_hdr_os_copy);
-#if defined(CONFIG_FIT)
- } else if (images->fit_uname_os) {
- ret = fit_image_get_entry (images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts ("Can't get entry point property!\n");
- goto error;
- }
-#endif
- } else {
- puts ("Could not find kernel entry point!\n");
- goto error;
- }
- theKernel = (void (*)(int, char **, char **, int *))ep;
+ theKernel = (void (*)(int, char **, char **, int *))images->ep;
ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_MIPS,
&initrd_start, &initrd_end);
diff --git a/lib_nios2/bootm.c b/lib_nios2/bootm.c
index 18cf7736ef..c74b5d67fe 100644
--- a/lib_nios2/bootm.c
+++ b/lib_nios2/bootm.c
@@ -30,25 +30,7 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images)
{
- ulong ep = 0;
-
- /* find kernel entry point */
- if (images->legacy_hdr_valid) {
- ep = image_get_ep (&images->legacy_hdr_os_copy);
-#if defined(CONFIG_FIT)
- } else if (images->fit_uname_os) {
- int ret = fit_image_get_entry (images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts ("Can't get entry point property!\n");
- goto error;
- }
-#endif
- } else {
- puts ("Could not find kernel entry point!\n");
- goto error;
- }
- void (*kernel)(void) = (void (*)(void))ep;
+ void (*kernel)(void) = (void (*)(void))images->ep;
/* For now we assume the Microtronix linux ... which only
* needs to be called ;-)
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index e83c860822..b08ee0dc4d 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -79,7 +79,6 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ulong cmd_start, cmd_end, bootmap_base;
bd_t *kbd;
- ulong ep = 0;
void (*kernel)(bd_t *, ulong r4, ulong r5, ulong r6,
ulong r7, ulong r8, ulong r9);
int ret;
@@ -90,6 +89,9 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
char *of_flat_tree = NULL;
#endif
+ kernel = (void (*)(bd_t *, ulong, ulong, ulong,
+ ulong, ulong, ulong))images->ep;
+
bootmap_base = getenv_bootm_low();
bootm_size = getenv_bootm_size();
@@ -151,24 +153,6 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
set_clocks_in_mhz(kbd);
}
- /* find kernel entry point */
- if (images->legacy_hdr_valid) {
- ep = image_get_ep (&images->legacy_hdr_os_copy);
-#if defined(CONFIG_FIT)
- } else if (images->fit_uname_os) {
- ret = fit_image_get_entry (images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts ("Can't get entry point property!\n");
- goto error;
- }
-#endif
- } else {
- puts ("Could not find kernel entry point!\n");
- goto error;
- }
- kernel = (void (*)(bd_t *, ulong, ulong, ulong,
- ulong, ulong, ulong))ep;
/* find ramdisk */
ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_PPC,
&rd_data_start, &rd_data_end);
diff --git a/lib_sh/bootm.c b/lib_sh/bootm.c
index 4ee7ff3fd7..9d2c908a54 100644
--- a/lib_sh/bootm.c
+++ b/lib_sh/bootm.c
@@ -62,26 +62,9 @@ static void hexdump (unsigned char *buf, int len)
void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images)
{
- ulong ep = 0;
char *bootargs = getenv("bootargs");
- /* find kernel entry point */
- if (images->legacy_hdr_valid) {
- ep = image_get_ep (&images->legacy_hdr_os_copy);
-#if defined(CONFIG_FIT)
- } else if (images->fit_uname_os) {
- int ret = fit_image_get_entry (images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts ("Can't get entry point property!\n");
- goto error;
- }
-#endif
- } else {
- puts ("Could not find kernel entry point!\n");
- goto error;
- }
- void (*kernel) (void) = (void (*)(void))ep;
+ void (*kernel) (void) = (void (*)(void))images->ep;
/* Setup parameters */
memset(PARAM, 0, 0x1000); /* Clear zero page */
diff --git a/lib_sparc/bootm.c b/lib_sparc/bootm.c
index b1a3d98c15..ac15396f69 100644
--- a/lib_sparc/bootm.c
+++ b/lib_sparc/bootm.c
@@ -87,7 +87,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
bootm_headers_t * images)
{
char *bootargs;
- ulong ep, load;
+ ulong load;
ulong initrd_start, initrd_end;
ulong rd_data_start, rd_data_end, rd_len;
unsigned int data, len, checksum;
@@ -97,17 +97,9 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
int ret;
if (images->legacy_hdr_valid) {
- ep = image_get_ep(images->legacy_hdr_os);
load = image_get_load(images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- int ret = fit_image_get_entry(images->fit_hdr_os,
- images->fit_noffset_os, &ep);
- if (ret) {
- puts("Can't get entry point property!\n");
- goto error;
- }
-
ret = fit_image_get_load(images->fit_hdr_os,
images->fit_noffset_os, &load);
if (ret) {
@@ -124,7 +116,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
linux_hdr = (void *)load;
/* */
- kernel = (void (*)(struct linux_romvec *, void *))ep;
+ kernel = (void (*)(struct linux_romvec *, void *))images->ep;
/* check for a SPARC kernel */
if ((linux_hdr->hdr[0] != 'H') ||
OpenPOWER on IntegriCloud