Skip to contentSkip to conversation

patchset5: Dual format uImage handling framework

PATCH New Marian Balakowicz 4 participants 21 messages Feb 25, 2008 – Feb 27, 2008

lore
Share & tools
lore
#0 lore raw

cover patchset5: Dual format uImage handling framework

This patch series adds initial framework for dual format uImage support to U-boot. Booting control flow is reworked and is now able to recognize both
formats: legacy format based on a binary image_header stucture and new FIT uImage format based on a libfdt. Legacy specific code is adapted a bit and enterd only for legacy format images. Proper new uImage format handling is not implement in this patch series, appropriate cases are stubed and will be updated with the new uImage format low level code in the comming patchsets.

To sum up:
Legacy format image handling shall continue to work, FIT format image handling will produce debug messages and return with error.

Three other patches refactor legacy format specific code to a helper routines image_get_kernel(), image_get_fdt() and move PPC FDT blob relocattion code to a dedicated routine fdt_relocate().

Included are also fixes: reworked gen_get_image() and correced raw FDT blob handling when CONFIG_FIT is disabled.

Please review and comment.

Marian Balakowicz (8):
[new uImage] Correct raw FDT blob handlig when CONFIG_FIT is disabled [new uImage] POWERPC: Add image_get_fdt() routine
[new uImage] Add image_get_kernel() routine
[new uImage] Move image verify flag to bootm_headers structure [Makefile] Sort COBJS in lib_<arch> Makefiles
[new uImage] Optimize gen_get_image() flow control
[new uImage] POWERPC: Split get_fdt() into get and relocate routines [new uImage] Add dual format uImage support framework

Cheers,
m.

#1 lore raw

PATCH 1/8 Add dual format uImage support framework

This patch adds framework for dual format images. Format detection is added and the bootm controll flow is updated to include cases for new FIT format uImages.

When the legacy (image_header based) format is detected appropriate legacy specific handling is invoked. For the new (FIT based) format uImages dual boot framework has a minial support, that will only print out a corresponding debug messages. Implementation of the FIT specific handling will be added in following patches.

---

 board/cray/L1/L1.c             |    7 +
 board/esd/common/auto_update.c |   19 ++
 board/mcc200/auto_update.c     |   19 ++
 board/mpl/common/common_util.c |    7 +
 board/siemens/common/fpga.c    |   14 ++
 board/trab/auto_update.c       |   26 +++
 common/cmd_autoscript.c        |   56 ++++--
 common/cmd_bootm.c             |  361 ++++++++++++++++++++++++++++------------
 common/cmd_doc.c               |   28 ++-
 common/cmd_fdc.c               |   44 +++--
 common/cmd_fpga.c              |   36 +++-
 common/cmd_ide.c               |   41 +++--
 common/cmd_nand.c              |   59 +++++--
 common/cmd_scsi.c              |   31 ++-
 common/cmd_usb.c               |   33 +++-
 common/cmd_ximg.c              |  103 ++++++-----
 common/image.c                 |  117 +++++++++----
 include/image.h                |   53 +++++-
 lib_arm/bootm.c                |   32 +++-
 lib_avr32/bootm.c              |   32 +++-
 lib_blackfin/bootm.c           |   22 ++
 lib_i386/bootm.c               |   35 +++-
 lib_m68k/bootm.c               |   26 ++-
 lib_microblaze/bootm.c         |   23 ++-
 lib_mips/bootm.c               |   32 ++--
 lib_nios/bootm.c               |    2 
 lib_nios2/bootm.c              |   20 ++
 lib_ppc/bootm.c                |  178 +++++++++++++++-----
 lib_sh/bootm.c                 |   22 ++
 29 files changed, 1074 insertions(+), 404 deletions(-)
board/cray/L1/L1.c +7 -0
index 8e6d74e..c00acc8 100644
@@ -140,6 +140,13 @@ int misc_init_r (void)
 	char bootcmd[32];
 
 	hdr = (image_header_t *) (CFG_MONITOR_BASE - image_get_header_size ());
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	timestamp = (time_t)image_get_time (hdr);
 	to_tm (timestamp, &tm);
 	printf ("Welcome to U-Boot on Cray L1. Compiled %4d-%02d-%02d  %2d:%02d:%02d (UTC)\n", tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
board/esd/common/auto_update.c +19 -0
index cb8087b..976707d 100644
@@ -91,6 +91,12 @@ int au_check_cksum_valid(int i, long nbytes)
 	image_header_t *hdr;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	if ((au_image[i].type == AU_FIRMWARE) &&
 	    (au_image[i].size != image_get_data_size (hdr))) {
@@ -118,6 +124,13 @@ int au_check_header_valid(int i, long nbytes)
 	unsigned long checksum;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	/* check the easy ones first */
 #undef CHECK_VALID_DEBUG
 #ifdef CHECK_VALID_DEBUG
@@ -183,6 +196,12 @@ int au_do_update(int i, long sz)
 #endif
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	switch (au_image[i].type) {
 	case AU_SCRIPT:
board/mcc200/auto_update.c +19 -0
index 8b520c8..fcae35a 100644
@@ -143,6 +143,12 @@ int au_check_cksum_valid(int idx, long nbytes)
 	image_header_t *hdr;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	if (nbytes != image_get_image_size (hdr)) {
 		printf ("Image %s bad total SIZE\n", aufile[idx]);
@@ -162,6 +168,13 @@ int au_check_header_valid(int idx, long nbytes)
 	unsigned long checksum, fsize;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	/* check the easy ones first */
 #undef CHECK_VALID_DEBUG
 #ifdef CHECK_VALID_DEBUG
@@ -233,6 +246,12 @@ int au_do_update(int idx, long sz)
 	uint nbytes;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	/* execute a script */
 	if (image_check_type (hdr, IH_TYPE_SCRIPT)) {
board/mpl/common/common_util.c +7 -0
index b171ca5..fffd25c 100644
@@ -181,6 +181,13 @@ mpl_prg_image(uchar *ld_addr)
 	image_header_t *hdr = (image_header_t *)ld_addr;
 	int rc;
 
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	if (!image_check_magic (hdr)) {
 		puts("Bad Magic Number\n");
 		return 1;
board/siemens/common/fpga.c +14 -0
index 9d71946..a9a6dfe 100644
@@ -137,6 +137,13 @@ static int fpga_load (fpga_t* fpga, ulong addr, int checkall)
     char msg[32];
     int verify, i;
 
+#if defined(CONFIG_FIT)
+    if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+	puts ("Non legacy image format not supported\n");
+	return -1;
+    }
+#endif
+
     /*
      * Check the image header and data of the net-list
      */
@@ -333,6 +340,13 @@ int fpga_init (void)
 	}
 
 	hdr = (image_header_t *)addr;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+	   puts ("Non legacy image format not supported\n");
+	   return -1;
+	}
+#endif
+
 	if ((new_id = fpga_get_version(fpga, image_get_name (hdr))) == -1)
 	    return 1;
 
board/trab/auto_update.c +26 -0
index bd9ee0c..8f67535 100644
@@ -211,6 +211,12 @@ au_check_cksum_valid(int idx, long nbytes)
 	image_header_t *hdr;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	if (nbytes != image_get_image_size (hdr))
 	{
@@ -234,6 +240,13 @@ au_check_header_valid(int idx, long nbytes)
 	unsigned char buf[4];
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	/* check the easy ones first */
 #undef CHECK_VALID_DEBUG
 #ifdef CHECK_VALID_DEBUG
@@ -327,6 +340,12 @@ au_do_update(int idx, long sz)
 	uint nbytes;
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
 
 	/* disable the power switch */
 	*CPLD_VFD_BK |= POWER_OFF;
@@ -417,6 +436,13 @@ au_update_eeprom(int idx)
 	}
 
 	hdr = (image_header_t *)LOAD_ADDR;
+#if defined(CONFIG_FIT)
+	if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+		puts ("Non legacy image format not supported\n");
+		return -1;
+	}
+#endif
+
 	/* write the time field into EEPROM */
 	off = auee_off[idx].time;
 	val = image_get_time (hdr);
common/cmd_autoscript.c +35 -21

75 lines not on this page · raw message

common/cmd_bootm.c +251 -110

595 lines not on this page · raw message

common/cmd_doc.c +20 -8
index 70bbd31..3358b04 100644
@@ -261,17 +261,29 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	}
 	show_boot_progress (38);
 
-	hdr = (image_header_t *)addr;
+	switch (gen_image_get_format ((void *)addr)) {
+	case IMAGE_FORMAT_LEGACY:
+		hdr = (image_header_t *)addr;
 
-	if (image_check_magic (hdr)) {
+		if (image_check_magic (hdr)) {
 
-		image_print_contents (hdr);
+			image_print_contents (hdr);
 
-		cnt = image_get_image_size (hdr);
-		cnt -= SECTORSIZE;
-	} else {
-		puts ("\n** Bad Magic Number **\n");
-		show_boot_progress (-39);
+			cnt = image_get_image_size (hdr);
+			cnt -= SECTORSIZE;
+		} else {
+			puts ("\n** Bad Magic Number **\n");
+			show_boot_progress (-39);
+			return 1;
+		}
+		break;
+#if defined(CONFIG_FIT)
+	case IMAGE_FORMAT_FIT:
+		fit_unsupported ("docboot");
+		return 1;
+#endif
+	default:
+		puts ("** Unknown image type\n");
 		return 1;
 	}
 	show_boot_progress (39);
common/cmd_fdc.c +28 -16

62 lines not on this page · raw message

common/cmd_fpga.c +24 -12
index 4030d04..10199f5 100644
@@ -216,19 +216,31 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 		break;
 
 	case FPGA_LOADMK:
-		{
-			image_header_t header;
-			image_header_t *hdr = &header;
-			ulong	data;
-
-			memmove (&header, (char *)fpga_data, image_get_header_size ());
-			if (!image_check_magic (hdr)) {
-				puts ("Bad Magic Number\n");
-				return 1;
+		switch (gen_image_get_format (fpga_data)) {
+		case IMAGE_FORMAT_LEGACY:
+			{
+				image_header_t *hdr = (image_header_t *)fpga_data;
+				ulong	data;
+
+				if (!image_check_magic (hdr)) {
+					puts ("Bad Magic Number\n");
+					return 1;
+				}
+				data = (ulong)image_get_data (hdr);
+				data_size = image_get_data_size (hdr);
+				rc = fpga_load (dev, (void *)data, data_size);
 			}
-			data = ((ulong)fpga_data + image_get_header_size ());
-			data_size = image_get_data_size (hdr);
-			rc = fpga_load (dev, (void *)data, data_size);
+			break;
+#if defined(CONFIG_FIT)
+		case IMAGE_FORMAT_FIT:
+			fit_unsupported ("fpga");
+			rc = FPGA_FAIL;
+			break;
+#endif
+		default:
+			puts ("** Unknown image type\n");
+			rc = FPGA_FAIL;
+			break;
 		}
 		break;
 
common/cmd_ide.c +27 -14

52 lines not on this page · raw message

common/cmd_nand.c +43 -16

78 lines not on this page · raw message

common/cmd_scsi.c +22 -9
index 5aae7ec..42b3072 100644
@@ -273,20 +273,33 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 
-	hdr = (image_header_t *)addr;
+	switch (gen_image_get_format ((void *)addr)) {
+	case IMAGE_FORMAT_LEGACY:
+		hdr = (image_header_t *)addr;
 
-	if (!image_check_magic (hdr)) {
-		printf("\n** Bad Magic Number **\n");
-		return 1;
-	}
+		if (!image_check_magic (hdr)) {
+			printf("\n** Bad Magic Number **\n");
+			return 1;
+		}
 
-	if (!image_check_hcrc (hdr)) {
-		puts ("\n** Bad Header Checksum **\n");
+		if (!image_check_hcrc (hdr)) {
+			puts ("\n** Bad Header Checksum **\n");
+			return 1;
+		}
+
+		image_print_contents (hdr);
+		cnt = image_get_image_size (hdr);
+		break;
+#if defined(CONFIG_FIT)
+	case IMAGE_FORMAT_FIT:
+		fit_unsupported ("scsi");
+		return 1;
+#endif
+	default:
+		puts ("** Unknown image type\n");
 		return 1;
 	}
 
-	image_print_contents (hdr);
-	cnt = image_get_image_size (hdr);
 	cnt += info.blksz - 1;
 	cnt /= info.blksz;
 	cnt -= 1;
common/cmd_usb.c +23 -10
index 3f1aa7d..ad3873c 100644
@@ -386,21 +386,34 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 
-	hdr = (image_header_t *)addr;
+	switch (gen_image_get_format ((void *)addr)) {
+	case IMAGE_FORMAT_LEGACY:
+		hdr = (image_header_t *)addr;
 
-	if (!image_check_magic (hdr)) {
-		printf("\n** Bad Magic Number **\n");
-		return 1;
-	}
+		if (!image_check_magic (hdr)) {
+			printf("\n** Bad Magic Number **\n");
+			return 1;
+		}
+
+		if (!image_check_hcrc (hdr)) {
+			puts ("\n** Bad Header Checksum **\n");
+			return 1;
+		}
 
-	if (!image_check_hcrc (hdr)) {
-		puts ("\n** Bad Header Checksum **\n");
+		image_print_contents (hdr);
+
+		cnt = image_get_image_size (hdr);
+		break;
+#if defined(CONFIG_FIT)
+	case IMAGE_FORMAT_FIT:
+		fit_unsupported ("usbboot");
+		return 1;
+#endif
+	default:
+		puts ("** Unknown image type\n");
 		return 1;
 	}
 
-	image_print_contents (hdr);
-
-	cnt = image_get_image_size (hdr);
 	cnt += info.blksz - 1;
 	cnt /= info.blksz;
 	cnt -= 1;
common/cmd_ximg.c +58 -45

121 lines not on this page · raw message

common/image.c +85 -32

163 lines not on this page · raw message

include/image.h +49 -4

82 lines not on this page · raw message

lib_arm/bootm.c +23 -9
index 31c2d67..4849c8a 100644
@@ -56,24 +56,38 @@ static void setup_end_tag (bd_t *bd);
 static void setup_videolfb_tag (gd_t *gd);
 # endif
 
-
 static struct tag *params;
 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
 
+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[],
-		     image_header_t *hdr, int verify)
+		     bootm_headers_t *images, int verify)
 {
-	ulong initrd_start, initrd_end;
-	void (*theKernel)(int zero, int arch, uint params);
-	bd_t *bd = gd->bd;
-	int machid = bd->bi_arch_number;
-	char *s;
+	ulong	initrd_start, initrd_end;
+	ulong	ep = 0;
+	bd_t	*bd = gd->bd;
+	char	*s;
+	int	machid = bd->bi_arch_number;
+	void	(*theKernel)(int zero, int arch, uint params);
 
 #ifdef CONFIG_CMDLINE_TAG
 	char *commandline = getenv ("bootargs");
 #endif
 
-	theKernel = (void (*)(int, int, uint))image_get_ep (hdr);
+	/* find kernel entry point */
+	if (images->legacy_hdr_valid) {
+		ep = image_get_ep (images->legacy_hdr_os);
+#if defined(CONFIG_FIT)
+	} else if (images->fit_uname_os) {
+		fit_unsupported_reset ("ARM linux bootm");
+		do_reset (cmdtp, flag, argc, argv);
+#endif
+	} else {
+		puts ("Could not find kernel entry point!\n");
+		do_reset (cmdtp, flag, argc, argv);
+	}
+	theKernel = (void (*)(int, int, uint))ep;
 
 	s = getenv ("machid");
 	if (s) {
@@ -81,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, hdr, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
 			IH_ARCH_ARM, &initrd_start, &initrd_end);
 
 	show_boot_progress (15);
lib_avr32/bootm.c +23 -9
index a934cae..c449394 100644
@@ -34,6 +34,8 @@ DECLARE_GLOBAL_DATA_PTR;
 /* CPU-specific hook to allow flushing of caches, etc. */
 extern void prepare_to_boot(void);
 
+extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+
 static struct tag *setup_start_tag(struct tag *params)
 {
 	params->hdr.tag = ATAG_CORE;
@@ -172,17 +174,29 @@ static void setup_end_tag(struct tag *params)
 }
 
 void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		    image_header_t *hdr, int verify)
+		    bootm_headers_t *images, int verify)
 {
-	ulong initrd_start, initrd_end;
-
-	void (*theKernel)(int magic, void *tagtable);
-	struct tag *params, *params_start;
-	char *commandline = getenv("bootargs");
-
-	theKernel = (void *)image_get_ep (hdr);
+	ulong	initrd_start, initrd_end;
+	ulong	ep = 0;
+	void	(*theKernel)(int magic, void *tagtable);
+	struct	tag *params, *params_start;
+	char	*commandline = getenv("bootargs");
+
+	/* find kernel entry point */
+	if (images->legacy_hdr_valid) {
+		ep = image_get_ep (images->legacy_hdr_os);
+#if defined(CONFIG_FIT)
+	} else if (images->fit_uname_os) {
+		fit_unsupported_reset ("AVR32 linux bootm");
+		do_reset (cmdtp, flag, argc, argv);
+#endif
+	} else {
+		puts ("Could not find kernel entry point!\n");
+		do_reset (cmdtp, flag, argc, argv);
+	}
+	theKernel = (void *)ep;
 
-	get_ramdisk (cmdtp, flag, argc, argv, hdr, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
 			IH_ARCH_AVR32, &initrd_start, &initrd_end);
 
 	show_boot_progress (15);
lib_blackfin/bootm.c +18 -4
index 6299415..8010e5d 100644
@@ -47,16 +47,30 @@ 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[],
-		    image_header_t *hdr, int verify)
+		    bootm_headers_t *images, int verify)
 {
-	int (*appl) (char *cmdline);
-	char *cmdline;
+	int	(*appl) (char *cmdline);
+	char	*cmdline;
+	ulong	ep = 0;
 
 #ifdef SHARED_RESOURCES
 	swap_to(FLASH);
 #endif
 
-	appl = (int (*)(char *))image_get_ep (hdr);
+	/* find kernel entry point */
+	if (images->legacy_hdr_valid) {
+		ep = image_get_ep (images->legacy_hdr_os);
+#if defined(CONFIG_FIT)
+	} else if (images->fit_uname_os) {
+		fit_unsupported_reset ("AVR32 linux bootm");
+		do_reset (cmdtp, flag, argc, argv);
+#endif
+	} else {
+		puts ("Could not find kernel entry point!\n");
+		do_reset (cmdtp, flag, argc, argv);
+	}
+	appl = (int (*)(char *))ep;
+
 	printf("Starting Kernel at = %x\n", appl);
 	cmdline = make_command_line();
 	if (icache_status()) {
lib_i386/bootm.c +24 -11
index ab6c2a9..3a6497c 100644
@@ -32,22 +32,35 @@
 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[],
-		image_header_t *hdr, int verify)
+		bootm_headers_t *images, int verify)
 {
-	void *base_ptr;
+	void		*base_ptr;
+	ulong		os_data, os_len;
+	ulong		initrd_start, initrd_end;
+	ulong		ep;
+	image_header_t	*hdr;
 
-	ulong os_data, os_len;
-	ulong initrd_start, initrd_end;
-
-	get_ramdisk (cmdtp, flag, argc, argv, hdr, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
 			IH_ARCH_I386, &initrd_start, &initrd_end);
 
-	/* if multi-part image, we need to advance base ptr */
-	if (image_check_type (hdr, IH_TYPE_MULTI)) {
-		image_multi_getimg (hdr, 0, &os_data, &os_len);
+	if (images->legacy_hdr_valid) {
+		hdr = images->legacy_hdr_os;
+		if (image_check_type (hdr, IH_TYPE_MULTI)) {
+			/* if multi-part image, we need to get first subimage */
+			image_multi_getimg (hdr, 0, &os_data, &os_len);
+		} else {
+			/* otherwise get image data */
+			os_data = image_get_data (hdr);
+			os_len = image_get_data_size (hdr);
+		}
+#if defined(CONFIG_FIT)
+	} else if (images->fit_uname_os) {
+		fit_unsupported_reset ("I386 linux bootm");
+		do_reset (cmdtp, flag, argc, argv);
+#endif
 	} else {
-		os_data = image_get_data (hdr);
-		os_len = image_get_data_size (hdr);
+		puts ("Could not find kernel image!\n");
+		do_reset (cmdtp, flag, argc, argv);
 	}
 
 	base_ptr = load_zimage ((void*)os_data, os_len,
lib_m68k/bootm.c +19 -7
index ac04da0..ce8be05 100644
@@ -42,10 +42,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static ulong get_sp (void);
 static void set_clocks_in_mhz (bd_t *kbd);
+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[],
-		    image_header_t *hdr, int verify)
+		    bootm_headers_t *images, int verify)
 {
 	ulong sp, sp_limit, alloc_current;
 
@@ -53,8 +54,9 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 	ulong initrd_start, initrd_end;
 
 	ulong cmd_start, cmd_end;
-	bd_t *kbd;
-	void (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
+	bd_t  *kbd;
+	ulong ep = 0;
+	void  (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
 
 	/*
 	 * Booting a (Linux) kernel image
@@ -78,12 +80,22 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 	alloc_current = get_boot_kbd (alloc_current, &kbd);
 	set_clocks_in_mhz(kbd);
 
-	/* find kernel */
-	kernel =
-	    (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr);
+	/* find kernel entry point */
+	if (images->legacy_hdr_valid) {
+		ep = image_get_ep (images->legacy_hdr_os);
+#if defined(CONFIG_FIT)
+	} else if (images->fit_uname_os) {
+		fit_unsupported_reset ("M68K linux bootm");
+		do_reset (cmdtp, flag, argc, argv);
+#endif
+	} else {
+		puts ("Could not find kernel entry point!\n");
+		do_reset (cmdtp, flag, argc, argv);
+	}
+	kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
 
 	/* find ramdisk */
-	get_ramdisk (cmdtp, flag, argc, argv, hdr, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
 			IH_ARCH_M68K, &rd_data_start, &rd_data_end);
 
 	rd_len = rd_data_end - rd_data_start;
lib_microblaze/bootm.c +19 -4
index bccfbe1..1455211 100644
@@ -32,14 +32,29 @@
 
 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[],
-		     image_header_t *hdr, int verify)
+		     bootm_headers_t *images, int verify)
 {
 	/* First parameter is mapped to $r5 for kernel boot args */
-	void (*theKernel) (char *);
-	char *commandline = getenv ("bootargs");
+	void	(*theKernel) (char *);
+	char	*commandline = getenv ("bootargs");
+	ulong	ep = 0;
 
-	theKernel = (void (*)(char *))image_get_ep (hdr);
+	/* find kernel entry point */
+	if (images->legacy_hdr_valid) {
+		ep = image_get_ep (images->legacy_hdr_os);
+#if defined(CONFIG_FIT)
+	} else if (images->fit_uname_os) {
+		fit_unsupported_reset ("MICROBLAZE linux bootm");
+		do_reset (cmdtp, flag, argc, argv);
+#endif
+	} else {
+		puts ("Could not find kernel entry point!\n");
+		do_reset (cmdtp, flag, argc, argv);
+	}
+	theKernel = (void (*)(char *))ep;
 
 	show_boot_progress (15);
 
lib_mips/bootm.c +22 -10
index fb91c76..5c2f28e 100644
@@ -43,20 +43,32 @@ static int	linux_env_idx;
 static void linux_params_init (ulong start, char * commandline);
 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[],
-		     image_header_t *hdr, int verify)
+		     bootm_headers_t *images, int verify)
 {
-	ulong initrd_start, initrd_end;
-
-	void (*theKernel) (int, char **, char **, int *);
-	char *commandline = getenv ("bootargs");
-	char env_buf[12];
-
-	theKernel =
-		(void (*)(int, char **, char **, int *))image_get_ep (hdr);
+	ulong	initrd_start, initrd_end;
+	ulong	ep = 0;
+	void	(*theKernel) (int, char **, char **, int *);
+	char	*commandline = getenv ("bootargs");
+	char	env_buf[12];
+
+	/* find kernel entry point */
+	if (images->legacy_hdr_valid) {
+		ep = image_get_ep (images->legacy_hdr_os);
+#if defined(CONFIG_FIT)
+	} else if (images->fit_uname_os) {
+		fit_unsupported_reset ("MIPS linux bootm");
+		do_reset (cmdtp, flag, argc, argv);
+#endif
+	} else {
+		puts ("Could not find kernel entry point!\n");
+		do_reset (cmdtp, flag, argc, argv);
+	}
+	theKernel = (void (*)(int, char **, char **, int *))ep;
 
-	get_ramdisk (cmdtp, flag, argc, argv, hdr, verify,
+	get_ramdisk (cmdtp, flag, argc, argv, images, verify,
 			IH_ARCH_MIPS, &initrd_start, &initrd_end);
 
 	show_boot_progress (15);
lib_nios/bootm.c +1 -1
index 55f7e3a..92a58f2 100644
@@ -29,6 +29,6 @@
  *
  */
 void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		image__header_t *hdr, int verify)
+		bootm_headers_t *images, int verify)
 {
 }
lib_nios2/bootm.c +18 -2
index cb84324..56d1d19 100644
@@ -25,10 +25,26 @@
 #include <command.h>
 #include <asm/byteorder.h>
 
+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[],
-		image_header_t *hdr, int verify)
+		bootm_headers_t *images, int verify)
 {
-	void (*kernel)(void) = (void (*)(void))image_get_ep (hdr);
+	ulong	ep = 0;
+
+	/* find kernel entry point */
+	if (images->legacy_hdr_valid) {
+		ep = image_get_ep (images->legacy_hdr_os);
+#if defined(CONFIG_FIT)
+	} else if (images->fit_uname_os) {
+		fit_unsupported_reset ("NIOS2 linux bootm");
+		do_reset (cmdtp, flag, argc, argv);
+#endif
+	} else {
+		puts ("Could not find kernel entry point!\n");
+		do_reset (cmdtp, flag, argc, argv);
+	}
+	void (*kernel)(void) = (void (*)(void))ep;
 
 	/* For now we assume the Microtronix linux ... which only
 	 * needs to be called ;-)
lib_ppc/bootm.c +131 -47

280 lines not on this page · raw message

lib_sh/bootm.c +19 -3
index 4e5fe77..55e64f5 100644
@@ -43,6 +43,8 @@
 
 #define RAMDISK_IMAGE_START_MASK        0x07FF
 
+extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+
 #ifdef CFG_DEBUG
 static void hexdump (unsigned char *buf, int len)
 {
@@ -58,10 +60,24 @@ static void hexdump (unsigned char *buf, int len)
 #endif
 
 void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-                     image_header_t *hdr, int verify)
+                     bootm_headers_t *images, int verify)
 {
-	char *bootargs = getenv("bootargs");
-	void (*kernel) (void) = (void (*)(void))image_get_ep (hdr);
+	ulong	ep = 0;
+	char	*bootargs = getenv("bootargs");
+
+	/* find kernel entry point */
+	if (images->legacy_hdr_valid) {
+		ep = image_get_ep (images->legacy_hdr_os);
+#if defined(CONFIG_FIT)
+	} else if (images->fit_uname_os) {
+		fit_unsupported_reset ("SH linux bootm");
+		do_reset (cmdtp, flag, argc, argv);
+#endif
+	} else {
+		puts ("Could not find kernel entry point!\n");
+		do_reset (cmdtp, flag, argc, argv);
+	}
+	void (*kernel) (void) = (void (*)(void))ep;
 
 	/* Setup parameters */
 	memset(PARAM, 0, 0x1000);	/* Clear zero page */
#2 lore raw

PATCH 2/8 POWERPC: Split get_fdt() into get and relocate routines

In reply to Marian Balakowicz

PPC specific FDT blob handling code is divided into two separate routines:

get_fdt() - find and verify a FDT blob (either raw or image embedded)
fdt_relocate() - move FDT blob to within BOOTMAP if needed

---

 lib_ppc/bootm.c |   61 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 43 insertions(+), 18 deletions(-)
lib_ppc/bootm.c +43 -18
index a1bbfc6..d5e019e 100644
@@ -41,9 +41,11 @@
 #include <fdt_support.h>
 
 static void fdt_error (const char *msg);
-static ulong get_fdt (ulong alloc_current, cmd_tbl_t *cmdtp, int flag,
-		int argc, char *argv[],
-		bootm_headers_t *images, char **of_flat_tree);
+static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		bootm_headers_t *images, char **of_flat_tree, ulong *of_size);
+static ulong fdt_relocate (ulong alloc_current,
+		cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		char **of_flat_tree, ulong *of_size);
 #endif
 
 #ifdef CFG_INIT_RAM_LOCK
@@ -73,7 +75,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	void	(*kernel)(bd_t *, ulong, ulong, ulong, ulong);
 
 #if defined(CONFIG_OF_LIBFDT)
-	char	*of_flat_tree;
+	char	*of_flat_tree = NULL;
+	ulong	of_size = 0;
 #endif
 
 	/*
@@ -124,14 +127,16 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 
 #if defined(CONFIG_OF_LIBFDT)
 	/* find flattened device tree */
-	alloc_current = get_fdt (alloc_current,
-			cmdtp, flag, argc, argv, images, &of_flat_tree);
+	get_fdt (cmdtp, flag, argc, argv, images, &of_flat_tree, &of_size);
+
+	alloc_current = fdt_relocate (alloc_current,
+			cmdtp, flag, argc, argv, &of_flat_tree, &of_size);
 
 	/*
 	 * Add the chosen node if it doesn't exist, add the env and bd_t
 	 * if the user wants it (the logic is in the subroutines).
 	 */
-	if (of_flat_tree) {
+	if (of_size) {
 		if (fdt_chosen(of_flat_tree, initrd_start, initrd_end, 0) < 0) {
 			fdt_error ("/chosen node create failed");
 			do_reset (cmdtp, flag, argc, argv);
@@ -234,16 +239,12 @@ static void fdt_error (const char *msg)
 	puts (" - must RESET the board to recover.\n");
 }
 
-static ulong get_fdt (ulong alloc_current,
-		cmd_tbl_t *cmdtp, int flag,
-		int argc, char *argv[],
-		bootm_headers_t *images, char **of_flat_tree)
+static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
 {
 	ulong		fdt_addr;
 	image_header_t	*fdt_hdr;
 	char		*fdt_blob = NULL;
-	ulong		fdt_relocate = 0;
-	ulong		new_alloc_current;
 	ulong		image_start, image_end;
 	ulong		load_start, load_end;
 #if defined(CONFIG_FIT)
@@ -410,13 +411,37 @@ static ulong get_fdt (ulong alloc_current,
 	} else {
 		debug ("## No Flattened Device Tree\n");
 		*of_flat_tree = NULL;
+		*of_size = 0;
+		return;
+	}
+
+	*of_flat_tree = fdt_blob;
+	*of_size = be32_to_cpu (fdt_totalsize (fdt_blob));
+	debug ("   of_flat_tree@0x%08lx size 0x%08lx\n",
+			*of_flat_tree, *of_size);
+}
+
+static ulong fdt_relocate (ulong alloc_current,
+		cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		char **of_flat_tree, ulong *of_size)
+{
+	char	*fdt_blob = *of_flat_tree;
+	ulong	relocate = 0;
+	ulong	new_alloc_current;
+
+	/* nothing to do */
+	if (*of_size == 0)
 		return alloc_current;
+
+	if (fdt_check_header (fdt_blob) != 0) {
+		fdt_error ("image is not a fdt");
+		do_reset (cmdtp, flag, argc, argv);
 	}
 
 #ifndef CFG_NO_FLASH
-	/* move the blob if it is in flash (set fdt_relocate) */
+	/* move the blob if it is in flash (set relocate) */
 	if (addr2info ((ulong)fdt_blob) != NULL)
-		fdt_relocate = 1;
+		relocate = 1;
 #endif
 
 #ifdef CFG_BOOTMAPSZ
@@ -425,15 +450,15 @@ static ulong get_fdt (ulong alloc_current,
 	 * so we flag it to be copied if it is not.
 	 */
 	if (fdt_blob >= (char *)CFG_BOOTMAPSZ)
-		fdt_relocate = 1;
+		relocate = 1;
 #endif
 
 	/* move flattend device tree if needed */
-	if (fdt_relocate) {
+	if (relocate) {
 		int err;
 		ulong of_start, of_len;
 
-		of_len = be32_to_cpu (fdt_totalsize (fdt_blob));
+		of_len = *of_size;
 
 		/* position on a 4K boundary before the alloc_current */
 		of_start  = alloc_current - of_len;
#3 lore raw

PATCH 2/8 POWERPC: Split get_fdt() into get and relocate routines

Quoted 6 lines · Marian Balakowicz

PPC specific FDT blob handling code is divided into two separate routines:

get_fdt() - find and verify a FDT blob (either raw or image embedded)
fdt_relocate() - move FDT blob to within BOOTMAP if needed

Quoted 6 lines

---

lib_ppc/bootm.c | 61 ++++++++++++++++++++++++++++++++++++++
+----------------

1 files changed, 43 insertions(+), 18 deletions(-)

- k

#4 lore raw

PATCH 3/8 Optimize gen_get_image() flow control

In reply to Marian Balakowicz

When CONFIG_HAS_DATAFLASH is not defined gen_get_image() routine has nothing to do, update its control flow to better reflect that simple case.

---

 common/image.c |   64 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 33 insertions(+), 31 deletions(-)
common/image.c +33 -31
index ea27b0b..dd55264 100644
@@ -408,55 +408,57 @@ int gen_image_get_format (void *img_addr)
  */
 ulong gen_get_image (ulong img_addr)
 {
-	ulong ram_addr, h_size, d_size;
-
-	h_size = image_get_header_size ();
-#if defined(CONFIG_FIT)
-	if (sizeof(struct fdt_header) > h_size)
-		h_size = sizeof(struct fdt_header);
-#endif
+	ulong ram_addr = img_addr;
 
 #ifdef CONFIG_HAS_DATAFLASH
+	ulong h_size, d_size;
+
 	if (addr_dataflash (img_addr)){
+		/* ger RAM address */
 		ram_addr = CFG_LOAD_ADDR;
+
+		/* get header size */
+		h_size = image_get_header_size ();
+#if defined(CONFIG_FIT)
+		if (sizeof(struct fdt_header) > h_size)
+			h_size = sizeof(struct fdt_header);
+#endif
+
+		/* read in header */
 		debug ("   Reading image header from dataflash address "
 			"%08lx to RAM address %08lx\n", img_addr, ram_addr);
-		read_dataflash (img_addr, h_size, (char *)ram_addr);
-	} else
-#endif
-		return img_addr;
 
-	ram_addr = img_addr;
+		read_dataflash (img_addr, h_size, (char *)ram_addr);
 
-	switch (gen_image_get_format ((void *)ram_addr)) {
-	case IMAGE_FORMAT_LEGACY:
-		d_size = image_get_data_size ((image_header_t *)ram_addr);
-		debug ("   Legacy format image found at 0x%08lx, size 0x%08lx\n",
-				ram_addr, d_size);
-		break;
+		/* get data size */
+		switch (gen_image_get_format ((void *)ram_addr)) {
+		case IMAGE_FORMAT_LEGACY:
+			d_size = image_get_data_size ((image_header_t *)ram_addr);
+			debug ("   Legacy format image found at 0x%08lx, size 0x%08lx\n",
+					ram_addr, d_size);
+			break;
 #if defined(CONFIG_FIT)
-	case IMAGE_FORMAT_FIT:
-		d_size = fdt_totalsize((void *)ram_addr) - h_size;
-		debug ("   FIT/FDT format image found at 0x%08lx, size 0x%08lx\n",
-				ram_addr, d_size);
-
-		break;
+		case IMAGE_FORMAT_FIT:
+			d_size = fdt_totalsize((void *)ram_addr) - h_size;
+			debug ("   FIT/FDT format image found at 0x%08lx, size 0x%08lx\n",
+					ram_addr, d_size);
+			break;
 #endif
-	default:
-		printf ("   No valid image found at 0x%08lx\n", img_addr);
-		return ram_addr;
-	}
+		default:
+			printf ("   No valid image found at 0x%08lx\n", img_addr);
+			return ram_addr;
+		}
 
-#ifdef CONFIG_HAS_DATAFLASH
-	if (addr_dataflash (img_addr)) {
+		/* read in image data */
 		debug ("   Reading image remaining data from dataflash address "
 			"%08lx to RAM address %08lx\n", img_addr + h_size,
 			ram_addr + h_size);
 
 		read_dataflash (img_addr + h_size, d_size,
 				(char *)(ram_addr + h_size));
+
 	}
-#endif
+#endif /* CONFIG_HAS_DATAFLASH */
 
 	return ram_addr;
 }
#5 lore raw

PATCH 3/8 Optimize gen_get_image() flow control

Quoted 10 lines · Marian Balakowicz

When CONFIG_HAS_DATAFLASH is not defined gen_get_image() routine has nothing
to do, update its control flow to better reflect that simple case.

---

common/image.c | 64 ++++++++++++++++++++++++++++
+---------------------------

1 files changed, 33 insertions(+), 31 deletions(-)

- k

#6 lore raw

PATCH 4/8 Sort COBJS in lib_<arch> Makefiles

In reply to Marian Balakowicz

---

 lib_avr32/Makefile      |    2 +-
 lib_blackfin/Makefile   |    4 ++--
 lib_i386/Makefile       |    4 ++--
 lib_m68k/Makefile       |    2 +-
 lib_microblaze/Makefile |    2 +-
 lib_mips/Makefile       |    2 +-
 lib_nios/Makefile       |    2 +-
 lib_nios2/Makefile      |    2 +-
 lib_ppc/Makefile        |    5 ++---
 9 files changed, 12 insertions(+), 13 deletions(-)
lib_avr32/Makefile +1 -1
index ebe237b..afbce45 100644
@@ -29,7 +29,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= memset.o
 
-COBJS	= board.o interrupts.o bootm.o
+COBJS	= board.o bootm.o interrupts.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_blackfin/Makefile +2 -2
index ac3fb28..4a262fc 100644
@@ -29,9 +29,9 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(ARCH).a
 
-SOBJS	= memcpy.o memcmp.o memset.o memmove.o
+SOBJS	= memcmp.o memcpy.o memmove.o memset.o
 
-COBJS	= post.o tests.o board.o bootm.o bf533_string.o cache.o muldi3.o
+COBJS	= bf533_string.o board.o bootm.o cache.o muldi3.o post.o tests.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_i386/Makefile +2 -2
index ef0ba54..004278f 100644
@@ -27,8 +27,8 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= bios.o bios_pci.o realmode_switch.o
 
-COBJS	= board.o bios_setup.o bootm.o zimage.o realmode.o \
-	  pci_type1.o pci.o video_bios.o video.o
+COBJS	= bios_setup.o board.o bootm.o pci.o pci_type1.o \
+	  realmode.o video_bios.o video.o zimage.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_m68k/Makefile +1 -1
index d515223..efde75d 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= cache.o traps.o time.o interrupts.o board.o bootm.o
+COBJS	= board.o bootm.o cache.o interrupts.o time.o traps.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_microblaze/Makefile +1 -1
index 9b317a2..9c3b519 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= board.o bootm.o time.o cache.o
+COBJS	= board.o bootm.o cache.o time.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_mips/Makefile +1 -1
index 93cca7a..bfcf463 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= board.o time.o bootm.o
+COBJS	= board.o bootm.o time.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_nios/Makefile +1 -1
index d8ae7bd..b81a3d4 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= board.o cache.o divmod.o bootm.o mult.o time.o
+COBJS	= board.o bootm.o cache.o divmod.o mult.o time.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_nios2/Makefile +1 -1
index 5f996d3..c69cdd7 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= cache.o
 
-COBJS	= board.o divmod.o bootm.o mult.o time.o
+COBJS	= board.o bootm.o divmod.o mult.o time.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_ppc/Makefile +2 -3
index 61507b0..21f644e 100644
@@ -27,9 +27,8 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= ppccache.o ppcstring.o ticks.o
 
-COBJS	= board.o \
-	  bat_rw.o cache.o extable.o kgdb.o time.o interrupts.o \
-	  bootm.o
+COBJS	= bat_rw.o board.o bootm.o cache.o extable.o \
+	  interrupts.o kgdb.o time.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
#7 lore raw

PATCH 4/8 Sort COBJS in lib_<arch> Makefiles

Quoted 33 lines · Marian Balakowicz

---

 lib_avr32/Makefile      |    2 +-
 lib_blackfin/Makefile   |    4 ++--
 lib_i386/Makefile       |    4 ++--
 lib_m68k/Makefile       |    2 +-
 lib_microblaze/Makefile |    2 +-
 lib_mips/Makefile       |    2 +-
 lib_nios/Makefile       |    2 +-
 lib_nios2/Makefile      |    2 +-
 lib_ppc/Makefile        |    5 ++---
 9 files changed, 12 insertions(+), 13 deletions(-)
lib_avr32/Makefile +1 -1
index ebe237b..afbce45 100644
@@ -29,7 +29,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= memset.o
 
-COBJS	= board.o interrupts.o bootm.o
+COBJS	= board.o bootm.o interrupts.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_blackfin/Makefile +0 -0
index ac3fb28..4a262fc 100644

lib_blackfin/Makefile include $(TOPDIR)/config.mk · line 35

Quoted 9 lines
lib_blackfin/Makefile +2 -2
@@ -29,9 +29,9 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(ARCH).a
 
-SOBJS	= memcpy.o memcmp.o memset.o memmove.o
+SOBJS	= memcmp.o memcpy.o memmove.o memset.o
 
-COBJS	= post.o tests.o board.o bootm.o bf533_string.o cache.o muldi3.o
+COBJS	= bf533_string.o board.o bootm.o cache.o muldi3.o post.o tests.o
 

It will be nice if you could split it in 1 line for 1 file as it

-SOBJS = memcpy.o memcmp.o memset.o memmove.o
+SOBJS += memcmp.o
+SOBJS += mmemcpy.o
+SOBJS += memmove.o
+SOBJS += memset.o
.....

lib_i386/Makefile

Quoted 3 lines
lib_blackfin/Makefile +0 -0
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_i386/Makefile +0 -0

Best regards,
J.

#8 lore raw

PATCH 4/8 Sort COBJS in lib_<arch> Makefiles

Quoted 40 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 39 lines · Marian Balakowicz

---

 lib_avr32/Makefile      |    2 +-
 lib_blackfin/Makefile   |    4 ++--
 lib_i386/Makefile       |    4 ++--
 lib_m68k/Makefile       |    2 +-
 lib_microblaze/Makefile |    2 +-
 lib_mips/Makefile       |    2 +-
 lib_nios/Makefile       |    2 +-
 lib_nios2/Makefile      |    2 +-
 lib_ppc/Makefile        |    5 ++---
 9 files changed, 12 insertions(+), 13 deletions(-)
lib_avr32/Makefile +1 -1
index ebe237b..afbce45 100644
@@ -29,7 +29,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= memset.o
 
-COBJS	= board.o interrupts.o bootm.o
+COBJS	= board.o bootm.o interrupts.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_blackfin/Makefile +1 -1
index ac3fb28..4a262fc 100644
@@ -29,9 +29,9 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(ARCH).a
 
-SOBJS	= memcpy.o memcmp.o memset.o memmove.o
+SOBJS	= memcmp.o memcpy.o memmove.o memset.o
 
Quoted 6 lines

lib_blackfin/Makefile include $(TOPDIR)/config.mk · line 35

Quoted 3 lines
lib_blackfin/Makefile +1 -1
-COBJS	= post.o tests.o board.o bootm.o bf533_string.o cache.o muldi3.o
+COBJS	= bf533_string.o board.o bootm.o cache.o muldi3.o post.o tests.o
 

It will be nice if you could split it in 1 line for 1 file as it
...

Right, should have done this way, will update the patch.

Thanks,
m.

#9 lore raw

PATCH 4/8 Sort COBJS in lib_<arch> Makefiles

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD

It will be nice if you could split it in 1 line for 1 file as it

-SOBJS = memcpy.o memcmp.o memset.o memmove.o
+SOBJS += memcmp.o
+SOBJS += mmemcpy.o
+SOBJS += memmove.o
+SOBJS += memset.o
.....

Quoted 7 lines

lib_i386/Makefile

Quoted 3 lines

SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))

lib_i386/Makefile +0 -0

Best regards,
J.

Yes, please. But also, while you are there, we need to go one step further and convert to SOBJS-y and COBJS-y as well.

If you don't do it, I will eventually be converting them all to look like this:

    COBJS-y	+= file.o
    COBJS-y	+= other.o

    OBJS	:= $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))

Might as well head in that direction as we go along...

Thanks,
jdl

#10 lore raw

PATCH 4/8 Sort COBJS in lib_<arch> Makefiles

Quoted 25 lines · Jon Loeliger
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD

It will be nice if you could split it in 1 line for 1 file as it

 -SOBJS    = memcpy.o memcmp.o memset.o memmove.o
 +SOBJS    += memcmp.o
 +SOBJS    += mmemcpy.o
 +SOBJS    += memmove.o
 +SOBJS    += memset.o
Quoted 8 lines

.....

lib_i386/Makefile

Quoted 3 lines

SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))

lib_i386/Makefile +0 -0

Best regards,
J.

Yes, please. But also, while you are there, we need to go one step further and convert to SOBJS-y and COBJS-y as well.

If you don't do it, I will eventually be converting them all to look like this:

Quoted 6 lines
   COBJS-y    += file.o
   COBJS-y    += other.o

   OBJS    := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))

Might as well head in that direction as we go along...

Done, updated version of the commit will cover this.

Cheers,
m.

#11 lore raw

PATCH 5/8 Move image verify flag to bootm_headers structure

In reply to Marian Balakowicz

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.

---

 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(-)
common/cmd_bootm.c +21 -26
index 3f09988..ce2de2e 100644
@@ -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;
common/image.c +8 -5
index dd55264..5ca77b9 100644
@@ -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);
include/image.h +2 -5
index 2f4b67d..1bc090a 100644
@@ -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)
lib_arm/bootm.c +2 -2
index 4849c8a..e1a9ee2 100644
@@ -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);
lib_avr32/bootm.c +2 -2
index c449394..69a69df 100644
@@ -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);
lib_blackfin/bootm.c +1 -1
index 8010e5d..26ac88b 100644
@@ -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;
lib_i386/bootm.c +2 -2
index 3a6497c..aea58d1 100644
@@ -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) {
lib_m68k/bootm.c +2 -2
index ce8be05..c611497 100644
@@ -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;
lib_microblaze/bootm.c +1 -1
index 1455211..5881df6 100644
@@ -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 *);
lib_mips/bootm.c +2 -2
index 5c2f28e..998aa22 100644
@@ -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);
lib_nios/bootm.c +1 -1
index 92a58f2..fb2e9b5 100644
@@ -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)
 {
 }
lib_nios2/bootm.c +1 -1
index 56d1d19..70d2bb0 100644
@@ -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;
 
lib_ppc/bootm.c +3 -5
index d5e019e..319d4ba 100644
@@ -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;
lib_sh/bootm.c +1 -1
index 55e64f5..de5c9ea 100644
@@ -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");
#12 lore raw

PATCH 5/8 Move image verify flag to bootm_headers structure

Quoted 11 lines · Marian Balakowicz

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.

---

common/cmd_bootm.c | 47 ++++++++++++++++++++

Quoted 15 lines
+--------------------------
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(-)

- k

#13 lore raw

PATCH 6/8 Add image_get_kernel() routine

In reply to Marian Balakowicz

Legacy image specific verification is factored out to a separate helper routine to keep get_kernel() generic and simple.

---

 common/cmd_bootm.c |   86 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 53 insertions(+), 33 deletions(-)
common/cmd_bootm.c +53 -33
index ce2de2e..e5ed167 100644
@@ -297,6 +297,57 @@ 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 image_header_t *image_get_kernel (ulong img_addr, int verify)
+{
+	image_header_t *hdr = (image_header_t *)img_addr;
+
+	if (!image_check_magic(hdr)) {
+		puts ("Bad Magic Number\n");
+		show_boot_progress (-1);
+		return NULL;
+	}
+	show_boot_progress (2);
+
+	if (!image_check_hcrc (hdr)) {
+		puts ("Bad Header Checksum\n");
+		show_boot_progress (-2);
+		return NULL;
+	}
+
+	show_boot_progress (3);
+	image_print_contents (hdr);
+
+	if (verify) {
+		puts ("   Verifying Checksum ... ");
+		if (!image_check_dcrc (hdr)) {
+			printf ("Bad Data CRC\n");
+			show_boot_progress (-3);
+			return NULL;
+		}
+		puts ("OK\n");
+	}
+	show_boot_progress (4);
+
+	if (!image_check_target_arch (hdr)) {
+		printf ("Unsupported Architecture 0x%x\n", image_get_arch (hdr));
+		show_boot_progress (-4);
+		return NULL;
+	}
+	return hdr;
+}
+
+/**
+ * get_kernel - find kernel image
+ * @os_data: pointer to a ulong variable, will hold os data start address
+ * @os_len: pointer to a ulong variable, will hold os data length
+ *
+ * get_kernel() tries to find a kernel image, verifies its integrity
+ * and locates kernel data.
+ *
+ * returns:
+ *     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[],
 		bootm_headers_t *images, ulong *os_data, ulong *os_len)
 {
@@ -339,40 +390,9 @@ static void *get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	case IMAGE_FORMAT_LEGACY:
 
 		debug ("*  kernel: legacy format image\n");
-		hdr = (image_header_t *)img_addr;
-
-		if (!image_check_magic(hdr)) {
-			puts ("Bad Magic Number\n");
-			show_boot_progress (-1);
+		hdr = image_get_kernel (img_addr, images->verify);
+		if (!hdr)
 			return NULL;
-		}
-		show_boot_progress (2);
-
-		if (!image_check_hcrc (hdr)) {
-			puts ("Bad Header Checksum\n");
-			show_boot_progress (-2);
-			return NULL;
-		}
-
-		show_boot_progress (3);
-		image_print_contents (hdr);
-
-		if (images->verify) {
-			puts ("   Verifying Checksum ... ");
-			if (!image_check_dcrc (hdr)) {
-				printf ("Bad Data CRC\n");
-				show_boot_progress (-3);
-				return NULL;
-			}
-			puts ("OK\n");
-		}
-		show_boot_progress (4);
-
-		if (!image_check_target_arch (hdr)) {
-			printf ("Unsupported Architecture 0x%x\n", image_get_arch (hdr));
-			show_boot_progress (-4);
-			return NULL;
-		}
 		show_boot_progress (5);
 
 		switch (image_get_type (hdr)) {
#14 lore raw

PATCH 6/8 Add image_get_kernel() routine

Quoted 10 lines · Marian Balakowicz

Legacy image specific verification is factored out to a separate helper
routine to keep get_kernel() generic and simple.

---

common/cmd_bootm.c | 86 +++++++++++++++++++++++++++++++
+--------------------

1 files changed, 53 insertions(+), 33 deletions(-)

- k

#15 lore raw

PATCH 7/8 POWERPC: Add image_get_fdt() routine

In reply to Marian Balakowicz

FDT blob may be passed either: (1) raw (2) or embedded in the legacy uImage
(3) or embedded in the new uImage. For the (2) case embedding image must be verified before we get FDT from it. This patch factors out legacy image specific verification routine to the separate helper routine.

---

 lib_ppc/bootm.c |   76 ++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 44 insertions(+), 32 deletions(-)
lib_ppc/bootm.c +44 -32
index 319d4ba..ad05bc5 100644
@@ -237,6 +237,39 @@ static void fdt_error (const char *msg)
 	puts (" - must RESET the board to recover.\n");
 }
 
+static image_header_t *image_get_fdt (ulong fdt_addr)
+{
+	image_header_t *fdt_hdr = (image_header_t *)fdt_addr;
+
+	image_print_contents (fdt_hdr);
+
+	puts ("   Verifying Checksum ... ");
+	if (!image_check_hcrc (fdt_hdr)) {
+		fdt_error ("fdt header checksum invalid");
+		return NULL;
+	}
+
+	if (!image_check_dcrc (fdt_hdr)) {
+		fdt_error ("fdt checksum invalid");
+		return NULL;
+	}
+	puts ("OK\n");
+
+	if (!image_check_type (fdt_hdr, IH_TYPE_FLATDT)) {
+		fdt_error ("uImage is not a fdt");
+		return NULL;
+	}
+	if (image_get_comp (fdt_hdr) != IH_COMP_NONE) {
+		fdt_error ("uImage is compressed");
+		return NULL;
+	}
+	if (fdt_check_header ((char *)image_get_data (fdt_hdr)) != 0) {
+		fdt_error ("uImage data is not a fdt");
+		return NULL;
+	}
+	return fdt_hdr;
+}
+
 static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
 {
@@ -297,12 +330,17 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		case IMAGE_FORMAT_LEGACY:
 			debug ("*  fdt: legacy format image\n");
 
-			fdt_hdr = (image_header_t *)fdt_addr;
+			/* verify fdt_addr points to a valid image header */
 			printf ("## Flattened Device Tree Legacy Image at %08lx\n",
-					fdt_hdr);
-
-			image_print_contents (fdt_hdr);
+					fdt_addr);
+			fdt_hdr = image_get_fdt (fdt_addr);
+			if (!fdt_hdr)
+				do_reset (cmdtp, flag, argc, argv);
 
+			/*
+			 * move image data to the load address,
+			 * make sure we don't overwrite initial image
+			 */
 			image_start = (ulong)fdt_hdr;
 			image_end = image_get_image_end (fdt_hdr);
 
@@ -313,35 +351,9 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 				fdt_error ("fdt overwritten");
 				do_reset (cmdtp, flag, argc, argv);
 			}
-
-			puts ("   Verifying Checksum ... ");
-			if (!image_check_hcrc (fdt_hdr)) {
-				fdt_error ("fdt header checksum invalid");
-				do_reset (cmdtp, flag, argc, argv);
-			}
-
-			if (!image_check_dcrc (fdt_hdr)) {
-				fdt_error ("fdt checksum invalid");
-				do_reset (cmdtp, flag, argc, argv);
-			}
-			puts ("OK\n");
-
-			if (!image_check_type (fdt_hdr, IH_TYPE_FLATDT)) {
-				fdt_error ("uImage is not a fdt");
-				do_reset (cmdtp, flag, argc, argv);
-			}
-			if (image_get_comp (fdt_hdr) != IH_COMP_NONE) {
-				fdt_error ("uImage is compressed");
-				do_reset (cmdtp, flag, argc, argv);
-			}
-			if (fdt_check_header ((char *)image_get_data (fdt_hdr)) != 0) {
-				fdt_error ("uImage data is not a fdt");
-				do_reset (cmdtp, flag, argc, argv);
-			}
-
 			memmove ((void *)image_get_load (fdt_hdr),
-				(void *)image_get_data (fdt_hdr),
-				image_get_data_size (fdt_hdr));
+					(void *)image_get_data (fdt_hdr),
+					image_get_data_size (fdt_hdr));
 
 			fdt_blob = (char *)image_get_load (fdt_hdr);
 			break;
#16 lore raw

PATCH 7/8 POWERPC: Add image_get_fdt() routine

Quoted 8 lines · Marian Balakowicz

FDT blob may be passed either: (1) raw (2) or embedded in the legacy uImage
(3) or embedded in the new uImage. For the (2) case embedding image must be
verified before we get FDT from it. This patch factors out legacy image
specific verification routine to the separate helper routine.

Quoted 6 lines

---

lib_ppc/bootm.c | 76 +++++++++++++++++++++++++++++++
+-----------------------

1 files changed, 44 insertions(+), 32 deletions(-)

- k

#17 lore raw

PATCH 8/8 Correct raw FDT blob handlig when CONFIG_FIT is disabled

In reply to Marian Balakowicz

Dual format image code must properly handle all three FDT passing methods:
- raw FDT blob passed
- FDT blob embedded in the legacy uImage
- FDT blob embedded in the new uImage

This patch enables proper raw FDT handling when no FIT imaeg support is compiled in. This is a bit tricky as we must dected FIT format even when FIT uImage handling is not enabled as both FIT uImages and raw FDT blobs use tha same low level format (libfdt).

---

 common/image.c  |    8 ++++++--
 include/image.h |    5 +++--
 lib_ppc/bootm.c |   18 ++++++++++++------
 3 files changed, 21 insertions(+), 10 deletions(-)
common/image.c +6 -2
index 5ca77b9..c689b0e 100644
@@ -375,6 +375,10 @@ void image_print_contents (image_header_t *hdr)
  * gen_image_get_format() checks whether provided address points to a valid
  * legacy or FIT image.
  *
+ * New uImage format and FDT blob are based on a libfdt. FDT blob
+ * may be passed directly or embedded in a FIT image. In both situations
+ * gen_image_get_format() must be able to dectect libfdt header.
+ *
  * returns:
  *     image format type or IMAGE_FORMAT_INVALID if no image is present
  */
@@ -382,14 +386,14 @@ int gen_image_get_format (void *img_addr)
 {
 	ulong		format = IMAGE_FORMAT_INVALID;
 	image_header_t	*hdr;
-#if defined(CONFIG_FIT)
+#if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
 	char		*fit_hdr;
 #endif
 
 	hdr = (image_header_t *)img_addr;
 	if (image_check_magic(hdr))
 		format = IMAGE_FORMAT_LEGACY;
-#if defined(CONFIG_FIT)
+#if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
 	else {
 		fit_hdr = (char *)img_addr;
 		if (fdt_check_header (fit_hdr) == 0)
include/image.h +3 -2
index 1bc090a..08566ea 100644
@@ -376,8 +376,9 @@ const char* image_get_comp_name (uint8_t comp);
 void image_print_contents (image_header_t *hdr);
 
 #define IMAGE_FORMAT_INVALID	0x00
-#define IMAGE_FORMAT_LEGACY	0x01
-#define IMAGE_FORMAT_FIT	0x02
+#define IMAGE_FORMAT_LEGACY	0x01	/* legacy image_header based format */
+#define IMAGE_FORMAT_FIT	0x02	/* new, libfdt based format */
+
 int gen_image_get_format (void *img_addr);
 ulong gen_get_image (ulong img_addr);
 
lib_ppc/bootm.c +12 -6
index ad05bc5..d80d69a 100644
@@ -357,11 +357,15 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
 			fdt_blob = (char *)image_get_load (fdt_hdr);
 			break;
-#if defined(CONFIG_FIT)
 		case IMAGE_FORMAT_FIT:
-
-			/* check FDT blob vs FIT hdr */
-			if (fit_uname_config || fit_uname_fdt) {
+			/*
+			 * This case will catch both: new uImage format
+			 * (libfdt based) and raw FDT blob (also libfdt
+			 * based).
+			 */
+#if defined(CONFIG_FIT)
+			/* check FDT blob vs FIT blob */
+			if (0) { /* FIXME: call FIT format verification */
 				/*
 				 * FIT image
 				 */
@@ -369,15 +373,17 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 				debug ("*  fdt: FIT format image\n");
 				fit_unsupported_reset ("PPC fdt");
 				do_reset (cmdtp, flag, argc, argv);
-			} else {
+			} else
+#endif
+			{
 				/*
 				 * FDT blob
 				 */
+				debug ("*  fdt: raw FDT blob\n");
 				printf ("## Flattened Device Tree blob at %08lx\n", fdt_blob);
 				fdt_blob = (char *)fdt_addr;
 			}
 			break;
-#endif
 		default:
 			fdt_error ("Did not find a cmdline Flattened Device Tree");
 			do_reset (cmdtp, flag, argc, argv);
#18 lore raw

cover patchset5: Dual format uImage handling framework

In reply to Marian Balakowicz
Quoted 32 lines · Marian Balakowicz

This patch series adds initial framework for dual format uImage support to
U-boot. Booting control flow is reworked and is now able to recognize both
formats: legacy format based on a binary image_header stucture and new FIT
uImage format based on a libfdt. Legacy specific code is adapted a bit and
enterd only for legacy format images. Proper new uImage format handling is not
implement in this patch series, appropriate cases are stubed and will be
updated with the new uImage format low level code in the comming patchsets.

To sum up:
Legacy format image handling shall continue to work, FIT format image handling
will produce debug messages and return with error.

Three other patches refactor legacy format specific code to a helper routines
image_get_kernel(), image_get_fdt() and move PPC FDT blob relocattion code to
a dedicated routine fdt_relocate().

Included are also fixes: reworked gen_get_image() and correced raw FDT blob
handling when CONFIG_FIT is disabled.

Please review and comment.

Quoted 11 lines

Marian Balakowicz (8):
[new uImage] Correct raw FDT blob handlig when CONFIG_FIT is
disabled
[new uImage] POWERPC: Add image_get_fdt() routine [new uImage] Add image_get_kernel() routine
[new uImage] Move image verify flag to bootm_headers structure [Makefile] Sort COBJS in lib_<arch> Makefiles
[new uImage] Optimize gen_get_image() flow control [new uImage] POWERPC: Split get_fdt() into get and relocate
routines
[new uImage] Add dual format uImage support framework

Is it just me or did patch [1/8 - add dual format..] not make it to the list?

-k

#19 lore raw

cover patchset5: Dual format uImage handling framework

Quoted 4 lines · Kumar Gala

On Feb 25, 2008, at 11:34 AM, Marian Balakowicz wrote:

Is it just me or did patch [1/8 - add dual format..] not make it to the list?

It did not make it, the reason is that it's bigger than allowed 40K, so it awaits Wolfgang's approval. As there is a show in Nurnberg at the moment, we may need to wait a bit, so I have copied it to the temp location for now:
http://frozne.semihalf.com/~m8/new-image/patchset5/01-p5.dual_format_framework.patch

Cheers,
m.

#20 lore raw

cover patchset5: Dual format uImage handling framework

Quoted 11 lines · Marian Balakowicz
Quoted 4 lines · Kumar Gala

On Feb 25, 2008, at 11:34 AM, Marian Balakowicz wrote:

Is it just me or did patch [1/8 - add dual format..] not make it to the list?

It did not make it, the reason is that it's bigger than allowed 40K, so it awaits Wolfgang's approval. As there is a show in Nurnberg at the moment, we may need to wait a bit, so I have copied it to the temp location for now:
http://frozne.semihalf.com/~m8/new-image/patchset5/01-p5.dual_format_framework.patch

Forget the above location, the correct one is:

http://frozen.semihalf.com/~m8/new-image/patchset5/01-p5.dual_format_framework.patch

m.