[U-Boot-Users] [PATCH 5/8] [new uImage] Move image verify flag to bootm_headers structure

Marian Balakowicz m8 at semihalf.com
Mon Feb 25 18:35:17 CET 2008


Do not pass image verification flag directly to related routines.
Simplify argument passing and move it to the bootm_header structure which
contains curently processed image specific data and is already being passed
on the argument list.

Signed-off-by: Marian Balakowicz <m8 at semihalf.com>
---

 common/cmd_bootm.c     |   47 +++++++++++++++++++++--------------------------
 common/image.c         |   13 ++++++++-----
 include/image.h        |    7 ++-----
 lib_arm/bootm.c        |    4 ++--
 lib_avr32/bootm.c      |    4 ++--
 lib_blackfin/bootm.c   |    2 +-
 lib_i386/bootm.c       |    4 ++--
 lib_m68k/bootm.c       |    4 ++--
 lib_microblaze/bootm.c |    2 +-
 lib_mips/bootm.c       |    4 ++--
 lib_nios/bootm.c       |    2 +-
 lib_nios2/bootm.c      |    2 +-
 lib_ppc/bootm.c        |    8 +++-----
 lib_sh/bootm.c         |    2 +-
 14 files changed, 49 insertions(+), 56 deletions(-)


diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 3f09988..ce2de2e 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -65,10 +65,8 @@ static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 static void fixup_silent_linux (void);
 #endif
 
-static void *get_kernel (cmd_tbl_t *cmdtp, int flag,
-		int argc, char *argv[], int verify,
-		bootm_headers_t *images,
-		ulong *os_data, ulong *os_len);
+static void *get_kernel (cmd_tbl_t *cmdtp, int flag,int argc, char *argv[],
+		bootm_headers_t *images, ulong *os_data, ulong *os_len);
 extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 /*
@@ -81,8 +79,7 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  */
 typedef void boot_os_fn (cmd_tbl_t *cmdtp, int flag,
 			int argc, char *argv[],
-			bootm_headers_t *images,/* pointers to os/initrd/fdt */
-			int verify);		/* getenv("verify")[0] != 'n' */
+			bootm_headers_t *images); /* pointers to os/initrd/fdt */
 
 extern boot_os_fn do_bootm_linux;
 static boot_os_fn do_bootm_netbsd;
@@ -114,7 +111,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	ulong		iflag;
 	const char	*type_name;
 	uint		unc_len = CFG_BOOTM_LEN;
-	int		verify = getenv_verify();
 	uint8_t		comp, type, os;
 
 	void		*os_hdr;
@@ -123,9 +119,10 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	ulong		load_start, load_end;
 
 	memset ((void *)&images, 0, sizeof (images));
+	images.verify = getenv_verify();
 
 	/* get kernel image header, start address and length */
-	os_hdr = get_kernel (cmdtp, flag, argc, argv, verify,
+	os_hdr = get_kernel (cmdtp, flag, argc, argv,
 			&images, &os_data, &os_len);
 	if (os_len == 0)
 		return 1;
@@ -246,36 +243,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, verify);
+	    do_bootm_linux (cmdtp, flag, argc, argv, &images);
 	    break;
 
 	case IH_OS_NETBSD:
-	    do_bootm_netbsd (cmdtp, flag, argc, argv, &images, verify);
+	    do_bootm_netbsd (cmdtp, flag, argc, argv, &images);
 	    break;
 
 #ifdef CONFIG_LYNXKDI
 	case IH_OS_LYNXOS:
-	    do_bootm_lynxkdi (cmdtp, flag, argc, argv, &images, verify);
+	    do_bootm_lynxkdi (cmdtp, flag, argc, argv, &images);
 	    break;
 #endif
 
 	case IH_OS_RTEMS:
-	    do_bootm_rtems (cmdtp, flag, argc, argv, &images, verify);
+	    do_bootm_rtems (cmdtp, flag, argc, argv, &images);
 	    break;
 
 #if defined(CONFIG_CMD_ELF)
 	case IH_OS_VXWORKS:
-	    do_bootm_vxworks (cmdtp, flag, argc, argv, &images, verify);
+	    do_bootm_vxworks (cmdtp, flag, argc, argv, &images);
 	    break;
 
 	case IH_OS_QNX:
-	    do_bootm_qnxelf (cmdtp, flag, argc, argv, &images, verify);
+	    do_bootm_qnxelf (cmdtp, flag, argc, argv, &images);
 	    break;
 #endif
 
 #ifdef CONFIG_ARTOS
 	case IH_OS_ARTOS:
-	    do_bootm_artos (cmdtp, flag, argc, argv, &images, verify);
+	    do_bootm_artos (cmdtp, flag, argc, argv, &images);
 	    break;
 #endif
 	}
@@ -300,10 +297,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  *     pointer to image header if valid image was found, plus kernel start
  *     address and length, otherwise NULL
  */
-static void *get_kernel (cmd_tbl_t *cmdtp, int flag,
-		int argc, char *argv[], int verify,
-		bootm_headers_t *images,
-		ulong *os_data, ulong *os_len)
+static void *get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		bootm_headers_t *images, ulong *os_data, ulong *os_len)
 {
 	image_header_t	*hdr;
 	ulong		img_addr;
@@ -362,7 +357,7 @@ static void *get_kernel (cmd_tbl_t *cmdtp, int flag,
 		show_boot_progress (3);
 		image_print_contents (hdr);
 
-		if (verify) {
+		if (images->verify) {
 			puts ("   Verifying Checksum ... ");
 			if (!image_check_dcrc (hdr)) {
 				printf ("Bad Data CRC\n");
@@ -648,7 +643,7 @@ static void fixup_silent_linux ()
 
 static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
 			    int argc, char *argv[],
-			    bootm_headers_t *images, int verify)
+			    bootm_headers_t *images)
 {
 	void (*loader)(bd_t *, image_header_t *, char *, char *);
 	image_header_t *os_hdr, *hdr;
@@ -731,7 +726,7 @@ static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
 #ifdef CONFIG_LYNXKDI
 static void do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag,
 			     int argc, char *argv[],
-			     bootm_headers_t *images, int verify)
+			     bootm_headers_t *images)
 {
 	image_header_t *hdr = images->legacy_hdr_os;
 
@@ -748,7 +743,7 @@ static void do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag,
 
 static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
 			   int argc, char *argv[],
-			   bootm_headers_t *images, int verify)
+			   bootm_headers_t *images)
 {
 	image_header_t *hdr = images->legacy_hdr_os;
 	void (*entry_point)(bd_t *);
@@ -777,7 +772,7 @@ static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
 #if defined(CONFIG_CMD_ELF)
 static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag,
 			     int argc, char *argv[],
-			     bootm_headers_t *images, int verify)
+			     bootm_headers_t *images)
 {
 	char str[80];
 	image_header_t *hdr = images->legacy_hdr_os;
@@ -796,7 +791,7 @@ static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag,
 
 static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag,
 			    int argc, char *argv[],
-			    bootm_headers_t *images, int verify)
+			    bootm_headers_t *images)
 {
 	char *local_args[2];
 	char str[16];
@@ -819,7 +814,7 @@ static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag,
 #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
 static void do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
 			   int argc, char *argv[],
-			   bootm_headers_t *images, int verify)
+			   bootm_headers_t *images)
 {
 	ulong top;
 	char *s, *cmdline;
diff --git a/common/image.c b/common/image.c
index dd55264..5ca77b9 100644
--- a/common/image.c
+++ b/common/image.c
@@ -58,6 +58,10 @@ extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 #endif
 
 DECLARE_GLOBAL_DATA_PTR;
+
+static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
+		int argc, char *argv[],
+		ulong rd_addr, uint8_t arch, int verify);
 #else
 #include "mkimage.h"
 #endif /* USE_HOSTCC*/
@@ -485,7 +489,7 @@ ulong gen_get_image (ulong img_addr)
  *     pointer to a ramdisk image header, if image was found and valid
  *     otherwise, board is reset
  */
-image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
+static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
 		int argc, char *argv[],
 		ulong rd_addr, uint8_t arch, int verify)
 {
@@ -539,8 +543,7 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
  * @flag: command flag
  * @argc: command argument count
  * @argv: command argument list
- * @images: pointer to the bootm images strcture
- * @verify: checksum verification flag
+ * @images: pointer to the bootm images structure
  * @arch: expected ramdisk architecture
  * @rd_start: pointer to a ulong variable, will hold ramdisk start address
  * @rd_end: pointer to a ulong variable, will hold ramdisk end
@@ -557,7 +560,7 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
  *     board is reset if ramdisk image is found but corrupted
  */
 void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		bootm_headers_t *images, int verify, uint8_t arch,
+		bootm_headers_t *images, uint8_t arch,
 		ulong *rd_start, ulong *rd_end)
 {
 	ulong rd_addr, rd_load;
@@ -621,7 +624,7 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 			debug ("*  ramdisk: legacy format image\n");
 
 			rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
-						rd_addr, arch, verify);
+						rd_addr, arch, images->verify);
 
 			rd_data = image_get_data (rd_hdr);
 			rd_len = image_get_data_size (rd_hdr);
diff --git a/include/image.h b/include/image.h
index 2f4b67d..1bc090a 100644
--- a/include/image.h
+++ b/include/image.h
@@ -202,6 +202,7 @@ typedef struct bootm_headers {
 	void		*fit_hdr_fdt;	/* FDT blob FIT image header */
 	char		*fit_uname_fdt;	/* FDT blob node unit name */
 #endif
+	int		verify;		/* getenv("verify")[0] != 'n' */
 #endif
 } bootm_headers_t;
 
@@ -380,12 +381,8 @@ void image_print_contents (image_header_t *hdr);
 int gen_image_get_format (void *img_addr);
 ulong gen_get_image (ulong img_addr);
 
-image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
-		int argc, char *argv[],
-		ulong rd_addr, uint8_t arch, int verify);
-
 void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		bootm_headers_t *images, int verify, uint8_t arch,
+		bootm_headers_t *images, uint8_t arch,
 		ulong *rd_start, ulong *rd_end);
 
 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c
index 4849c8a..e1a9ee2 100644
--- a/lib_arm/bootm.c
+++ b/lib_arm/bootm.c
@@ -62,7 +62,7 @@ static struct tag *params;
 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, int verify)
+		     bootm_headers_t *images)
 {
 	ulong	initrd_start, initrd_end;
 	ulong	ep = 0;
@@ -95,7 +95,7 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		printf ("Using machid 0x%x from environment\n", machid);
 	}
 
-	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images,
 			IH_ARCH_ARM, &initrd_start, &initrd_end);
 
 	show_boot_progress (15);
diff --git a/lib_avr32/bootm.c b/lib_avr32/bootm.c
index c449394..69a69df 100644
--- a/lib_avr32/bootm.c
+++ b/lib_avr32/bootm.c
@@ -174,7 +174,7 @@ static void setup_end_tag(struct tag *params)
 }
 
 void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		    bootm_headers_t *images, int verify)
+		    bootm_headers_t *images)
 {
 	ulong	initrd_start, initrd_end;
 	ulong	ep = 0;
@@ -196,7 +196,7 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	}
 	theKernel = (void *)ep;
 
-	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images,
 			IH_ARCH_AVR32, &initrd_start, &initrd_end);
 
 	show_boot_progress (15);
diff --git a/lib_blackfin/bootm.c b/lib_blackfin/bootm.c
index 8010e5d..26ac88b 100644
--- a/lib_blackfin/bootm.c
+++ b/lib_blackfin/bootm.c
@@ -47,7 +47,7 @@ extern void flush_data_cache(void);
 static char *make_command_line(void);
 
 void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
-		    bootm_headers_t *images, int verify)
+		    bootm_headers_t *images)
 {
 	int	(*appl) (char *cmdline);
 	char	*cmdline;
diff --git a/lib_i386/bootm.c b/lib_i386/bootm.c
index 3a6497c..aea58d1 100644
--- a/lib_i386/bootm.c
+++ b/lib_i386/bootm.c
@@ -32,7 +32,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, int verify)
+		bootm_headers_t *images)
 {
 	void		*base_ptr;
 	ulong		os_data, os_len;
@@ -40,7 +40,7 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	ulong		ep;
 	image_header_t	*hdr;
 
-	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images,
 			IH_ARCH_I386, &initrd_start, &initrd_end);
 
 	if (images->legacy_hdr_valid) {
diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c
index ce8be05..c611497 100644
--- a/lib_m68k/bootm.c
+++ b/lib_m68k/bootm.c
@@ -46,7 +46,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, int verify)
+		    bootm_headers_t *images)
 {
 	ulong sp, sp_limit, alloc_current;
 
@@ -95,7 +95,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 	kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
 
 	/* find ramdisk */
-	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images,
 			IH_ARCH_M68K, &rd_data_start, &rd_data_end);
 
 	rd_len = rd_data_end - rd_data_start;
diff --git a/lib_microblaze/bootm.c b/lib_microblaze/bootm.c
index 1455211..5881df6 100644
--- a/lib_microblaze/bootm.c
+++ b/lib_microblaze/bootm.c
@@ -35,7 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 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, int verify)
+		     bootm_headers_t *images)
 {
 	/* First parameter is mapped to $r5 for kernel boot args */
 	void	(*theKernel) (char *);
diff --git a/lib_mips/bootm.c b/lib_mips/bootm.c
index 5c2f28e..998aa22 100644
--- a/lib_mips/bootm.c
+++ b/lib_mips/bootm.c
@@ -46,7 +46,7 @@ static void linux_env_set (char * env_name, char * env_val);
 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, int verify)
+		     bootm_headers_t *images)
 {
 	ulong	initrd_start, initrd_end;
 	ulong	ep = 0;
@@ -68,7 +68,7 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 	}
 	theKernel = (void (*)(int, char **, char **, int *))ep;
 
-	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images,
 			IH_ARCH_MIPS, &initrd_start, &initrd_end);
 
 	show_boot_progress (15);
diff --git a/lib_nios/bootm.c b/lib_nios/bootm.c
index 92a58f2..fb2e9b5 100644
--- a/lib_nios/bootm.c
+++ b/lib_nios/bootm.c
@@ -29,6 +29,6 @@
  *
  */
 void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		bootm_headers_t *images, int verify)
+		bootm_headers_t *images)
 {
 }
diff --git a/lib_nios2/bootm.c b/lib_nios2/bootm.c
index 56d1d19..70d2bb0 100644
--- a/lib_nios2/bootm.c
+++ b/lib_nios2/bootm.c
@@ -28,7 +28,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, int verify)
+		bootm_headers_t *images)
 {
 	ulong	ep = 0;
 
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index d5e019e..319d4ba 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -59,10 +59,8 @@ static ulong get_sp (void);
 static void set_clocks_in_mhz (bd_t *kbd);
 
 void  __attribute__((noinline))
-do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
-		int	argc, char *argv[],
-		bootm_headers_t *images,
-		int	verify)
+do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		bootm_headers_t *images)
 {
 	ulong	sp, sp_limit, alloc_current;
 
@@ -116,7 +114,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
 
 	/* find ramdisk */
-	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images,
 			IH_ARCH_PPC, &rd_data_start, &rd_data_end);
 
 	rd_len = rd_data_end - rd_data_start;
diff --git a/lib_sh/bootm.c b/lib_sh/bootm.c
index 55e64f5..de5c9ea 100644
--- a/lib_sh/bootm.c
+++ b/lib_sh/bootm.c
@@ -60,7 +60,7 @@ static void hexdump (unsigned char *buf, int len)
 #endif
 
 void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-                     bootm_headers_t *images, int verify)
+                     bootm_headers_t *images)
 {
 	ulong	ep = 0;
 	char	*bootargs = getenv("bootargs");





More information about the U-Boot mailing list