From: Kumar Gala <galak@kernel.crashing.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [WIP][PATCH 04/11] bootm: refactor entry point code
Date: Tue, 12 Aug 2008 08:44:29 -0500 [thread overview]
Message-ID: <1218548676-25159-5-git-send-email-galak@kernel.crashing.org> (raw)
In-Reply-To: <1218548676-25159-4-git-send-email-galak@kernel.crashing.org>
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>
---
common/cmd_bootm.c | 31 ++++++++++++++++++++++---------
include/image.h | 2 ++
lib_arm/bootm.c | 19 +------------------
lib_avr32/bootm.c | 19 +------------------
lib_blackfin/bootm.c | 19 +------------------
lib_m68k/bootm.c | 19 +------------------
lib_microblaze/bootm.c | 19 +------------------
lib_mips/bootm.c | 18 +-----------------
lib_nios2/bootm.c | 20 +-------------------
lib_ppc/bootm.c | 22 +++-------------------
lib_sh/bootm.c | 19 +------------------
lib_sparc/bootm.c | 12 ++----------
12 files changed, 37 insertions(+), 182 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 0b14b06..3f63b84 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 4b9c582..e16c253 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 955a1ae..5660a50 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 60e6b36..7beab99 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 54f69a9..f789e24 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 b45203d..fe658fe 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 68edcdb..baf6d77 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 53e8e19..7df6ce6 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 18cf773..c74b5d6 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 3cb17bf..b481c2a 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 4ee7ff3..9d2c908 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 b1a3d98..ac15396 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') ||
--
1.5.5.1
next prev parent reply other threads:[~2008-08-12 13:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-12 13:44 [U-Boot] [WIP][PATCH 00/11] bootm refactoring Kumar Gala
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 01/11] Update linux bootm to support ePAPR client interface Kumar Gala
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 02/11] add ability to disable ft_board_setup as part of bootm Kumar Gala
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 03/11] Clean up usage of icache_disable/dcache_disable Kumar Gala
2008-08-12 13:44 ` Kumar Gala [this message]
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 05/11] bootm: refactor ramdisk locating code Kumar Gala
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 06/11] bootm: refactor fdt locating and relocation code Kumar Gala
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 07/11] bootm: Set working fdt address as part of the bootm flow Kumar Gala
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 08/11] bootm: move lmb into the bootm_headers_t structure Kumar Gala
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 09/11] bootm: refactor image detection and os load steps Kumar Gala
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 10/11] fdt: refactor fdt resize code Kumar Gala
2008-08-12 13:44 ` [U-Boot] [WIP][PATCH 11/11] fdt: refactor initrd related code Kumar Gala
2008-08-13 5:12 ` [U-Boot] [WIP][PATCH 09/11] bootm: refactor image detection and os load steps Jerry Van Baren
2008-08-12 20:12 ` [U-Boot] [WIP][PATCH 00/11] bootm refactoring Wolfgang Denk
2008-08-12 20:17 ` Kumar Gala
2008-08-12 23:15 ` Wolfgang Denk
2008-08-13 1:01 ` Kumar Gala
2008-08-13 5:12 ` Jerry Van Baren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1218548676-25159-5-git-send-email-galak@kernel.crashing.org \
--to=galak@kernel.crashing.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.