Skip to contentSkip to conversation

patchset2 - cleanup cont.

PATCH New Marian Balakowicz 5 participants 12 messages Jan 23, 2008 – Jan 31, 2008 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover patchset2 - cleanup cont.

Hi,

This is a second patchset for new uImage, it includes architecture file renames, removals of OF_FLAT_TREE and standalone application support and further code refactoring.

This patchset is based on patchset1. MAKEALL was run for ppc/arm/mips/coldfire, architestures, plus regression tests on lite5200b.

[new uImage] Move FDT error printing to common fdt_error() routine [new uImage] Factor out common routines for getting os/arch/type/comp names [new uImage] Remove standalone applications handling from boootm [new uImage] Remove OF_FLAT_TREE support from PPC bootm code [new uImage] Use image API in SH do_bootm_linux() routine
[new uImage] Rename architecture specific bootm code files

Cheers,
m.

#1 lore raw

PATCH 1/6 Rename architecture specific bootm code files

Implementation of the do_bootm_linux() and other bootm helper routines is architecture specific code. As such it resides in lib_<arch> directories in files named <arch>_linux.c

This patch renames those files to a more clear and accurate lib_<arch>/bootm.c form.

---
 lib_arm/Makefile                               |    2 +-
 lib_arm/{armlinux.c => bootm.c}                |    0 
 lib_avr32/Makefile                             |    2 +-
 lib_avr32/{avr32_linux.c => bootm.c}           |    0 
 lib_blackfin/Makefile                          |    2 +-
 lib_blackfin/{bf533_linux.c => bootm.c}        |    0 
 lib_i386/Makefile                              |    2 +-
 lib_i386/{i386_linux.c => bootm.c}             |    0 
 lib_m68k/Makefile                              |    2 +-
 lib_m68k/{m68k_linux.c => bootm.c}             |    0 
 lib_microblaze/Makefile                        |    2 +-
 lib_microblaze/{microblaze_linux.c => bootm.c} |    0 
 lib_mips/Makefile                              |    2 +-
 lib_mips/{mips_linux.c => bootm.c}             |    0 
 lib_nios/Makefile                              |    2 +-
 lib_nios/{nios_linux.c => bootm.c}             |    0 
 lib_nios2/Makefile                             |    2 +-
 lib_nios2/{nios_linux.c => bootm.c}            |    0 
 lib_ppc/Makefile                               |    2 +-
 lib_ppc/{ppc_linux.c => bootm.c}               |    0 
 lib_sh/Makefile                                |    2 +-
 lib_sh/{sh_linux.c => bootm.c}                 |    0 
 22 files changed, 11 insertions(+), 11 deletions(-)
lib_arm/Makefile +1 -1
index 037c475..aa9bee7 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= _ashldi3.o _ashrdi3.o _divsi3.o _modsi3.o _udivsi3.o _umodsi3.o
 
-COBJS	= armlinux.o board.o \
+COBJS	= bootm.o board.o \
 	  cache.o div0.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
lib_arm/bootm.c renamed from lib_arm/armlinux.c +0 -0
similarity index 100%
rename from lib_arm/armlinux.c
rename to lib_arm/bootm.c
lib_avr32/Makefile +1 -1
index bb2938f..ebe237b 100644
@@ -29,7 +29,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= memset.o
 
-COBJS	= board.o interrupts.o avr32_linux.o
+COBJS	= board.o interrupts.o bootm.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_avr32/bootm.c renamed from lib_avr32/avr32_linux.c +0 -0
similarity index 100%
rename from lib_avr32/avr32_linux.c
rename to lib_avr32/bootm.c
lib_blackfin/Makefile +1 -1
index a7aaef7..ac3fb28 100644
@@ -31,7 +31,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= memcpy.o memcmp.o memset.o memmove.o
 
-COBJS	= post.o tests.o board.o bf533_linux.o bf533_string.o cache.o muldi3.o
+COBJS	= post.o tests.o board.o bootm.o bf533_string.o cache.o muldi3.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_blackfin/bootm.c renamed from lib_blackfin/bf533_linux.c +0 -0
similarity index 100%
rename from lib_blackfin/bf533_linux.c
rename to lib_blackfin/bootm.c
lib_i386/Makefile +1 -1
index e344da5..ef0ba54 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= bios.o bios_pci.o realmode_switch.o
 
-COBJS	= board.o bios_setup.o i386_linux.o zimage.o realmode.o \
+COBJS	= board.o bios_setup.o bootm.o zimage.o realmode.o \
 	  pci_type1.o pci.o video_bios.o video.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
lib_i386/bootm.c renamed from lib_i386/i386_linux.c +0 -0
similarity index 100%
rename from lib_i386/i386_linux.c
rename to lib_i386/bootm.c
lib_m68k/Makefile +1 -1
index 03784fd..d515223 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= cache.o traps.o time.o interrupts.o board.o m68k_linux.o
+COBJS	= cache.o traps.o time.o interrupts.o board.o bootm.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_m68k/bootm.c renamed from lib_m68k/m68k_linux.c +0 -0
similarity index 100%
rename from lib_m68k/m68k_linux.c
rename to lib_m68k/bootm.c
lib_microblaze/Makefile +1 -1
index 82b7bea..9b317a2 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= board.o microblaze_linux.o time.o cache.o
+COBJS	= board.o bootm.o time.o cache.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_microblaze/bootm.c renamed from lib_microblaze/microblaze_linux.c +0 -0
similarity index 100%
rename from lib_microblaze/microblaze_linux.c
rename to lib_microblaze/bootm.c
lib_mips/Makefile +1 -1
index 3163f00..93cca7a 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= board.o time.o mips_linux.o
+COBJS	= board.o time.o bootm.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_mips/bootm.c renamed from lib_mips/mips_linux.c +0 -0
similarity index 100%
rename from lib_mips/mips_linux.c
rename to lib_mips/bootm.c
lib_nios/Makefile +1 -1
index 7c9d62c..d8ae7bd 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= board.o cache.o divmod.o nios_linux.o mult.o time.o
+COBJS	= board.o cache.o divmod.o bootm.o mult.o time.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_nios/bootm.c renamed from lib_nios/nios_linux.c +0 -0
similarity index 100%
rename from lib_nios/nios_linux.c
rename to lib_nios/bootm.c
lib_nios2/Makefile +1 -1
index 1ff2f29..5f996d3 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= cache.o
 
-COBJS	= board.o divmod.o nios_linux.o mult.o time.o
+COBJS	= board.o divmod.o bootm.o mult.o time.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_nios2/bootm.c renamed from lib_nios2/nios_linux.c +0 -0
similarity index 100%
rename from lib_nios2/nios_linux.c
rename to lib_nios2/bootm.c
lib_ppc/Makefile +1 -1
index 2aa0154..6845ed0 100644
@@ -29,7 +29,7 @@ SOBJS	= ppcstring.o ticks.o
 
 COBJS	= board.o \
 	  bat_rw.o cache.o extable.o kgdb.o time.o interrupts.o \
-	  ppc_linux.o
+	  bootm.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_ppc/bootm.c renamed from lib_ppc/ppc_linux.c +0 -0
similarity index 100%
rename from lib_ppc/ppc_linux.c
rename to lib_ppc/bootm.c
lib_sh/Makefile +1 -1
index cf127a8..edb03d0 100644
@@ -24,7 +24,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= board.o sh_linux.o # time.o
+COBJS	= board.o bootm.o # time.o
 
 SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_sh/bootm.c renamed from lib_sh/sh_linux.c +0 -0
similarity index 100%
rename from lib_sh/sh_linux.c
rename to lib_sh/bootm.c
#2 lore raw

PATCH 1/6 Rename architecture specific bootm code files

Quoted 38 lines · Marian Balakowicz

Implementation of the do_bootm_linux() and other bootm helper routines is architecture specific code. As such it resides in lib_<arch> directories in files named <arch>_linux.c

This patch renames those files to a more clear and accurate lib_<arch>/bootm.c form.

---
 lib_arm/Makefile                               |    2 +-
 lib_arm/{armlinux.c => bootm.c}                |    0 
 lib_avr32/Makefile                             |    2 +-
 lib_avr32/{avr32_linux.c => bootm.c}           |    0 
 lib_blackfin/Makefile                          |    2 +-
 lib_blackfin/{bf533_linux.c => bootm.c}        |    0 
 lib_i386/Makefile                              |    2 +-
 lib_i386/{i386_linux.c => bootm.c}             |    0 
 lib_m68k/Makefile                              |    2 +-
 lib_m68k/{m68k_linux.c => bootm.c}             |    0 
 lib_microblaze/Makefile                        |    2 +-
 lib_microblaze/{microblaze_linux.c => bootm.c} |    0 
 lib_mips/Makefile                              |    2 +-
 lib_mips/{mips_linux.c => bootm.c}             |    0 
 lib_nios/Makefile                              |    2 +-
 lib_nios/{nios_linux.c => bootm.c}             |    0 
 lib_nios2/Makefile                             |    2 +-
 lib_nios2/{nios_linux.c => bootm.c}            |    0 
 lib_ppc/Makefile                               |    2 +-
 lib_ppc/{ppc_linux.c => bootm.c}               |    0 
 lib_sh/Makefile                                |    2 +-
 lib_sh/{sh_linux.c => bootm.c}                 |    0 
 22 files changed, 11 insertions(+), 11 deletions(-)
lib_arm/Makefile +0 -0
index 037c475..aa9bee7 100644

lib_arm/Makefile LIB = $(obj)lib$(ARCH).a · line 30

Quoted 5 lines
lib_arm/Makefile +1 -1
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	= _ashldi3.o _ashrdi3.o _divsi3.o _modsi3.o _udivsi3.o _umodsi3.o
 
-COBJS	= armlinux.o board.o \
+COBJS	= bootm.o board.o \

On All COBJS please keep it sort.

Best Regards,
J.

#3 lore raw

PATCH 2/6 Use image API in SH do_bootm_linux() routine

In reply to Marian Balakowicz

Introduce image handling API for lately added Hitachi SH architecture.

---

 lib_sh/bootm.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
lib_sh/bootm.c +2 -5
index 14b6815..4e5fe77 100644
@@ -25,8 +25,6 @@
 #include <command.h>
 #include <asm/byteorder.h>
 
-extern image_header_t header;	/* common/cmd_bootm.c */
-
 /* The SH kernel reads arguments from the empty zero page at location
  * 0 at the start of SDRAM. The following are copied from
  * arch/sh/kernel/setup.c and may require tweaking if the kernel sources
@@ -60,11 +58,10 @@ static void hexdump (unsigned char *buf, int len)
 #endif
 
 void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		     ulong addr, ulong *len_ptr, int verify)
+                     image_header_t *hdr, int verify)
 {
-	image_header_t *hdr = &header;
 	char *bootargs = getenv("bootargs");
-	void (*kernel) (void) = (void (*)(void)) ntohl (hdr->ih_ep);
+	void (*kernel) (void) = (void (*)(void))image_get_ep (hdr);
 
 	/* Setup parameters */
 	memset(PARAM, 0, 0x1000);	/* Clear zero page */
#4 lore raw

PATCH 3/6 Remove OF_FLAT_TREE support from PPC bootm code

In reply to Marian Balakowicz

Support for OF_FLAT_TREE is to be obsoleted in the near future, remove related code from the bootm routines.

---

 common/cmd_bootm.c |   10 +-------
 lib_ppc/bootm.c    |   65 +++++-----------------------------------------------
 2 files changed, 7 insertions(+), 68 deletions(-)
common/cmd_bootm.c +1 -9
index f441e0e..3390be7 100644
@@ -36,14 +36,6 @@
 #include <environment.h>
 #include <asm/byteorder.h>
 
-#if defined(CONFIG_OF_LIBFDT)
-#include <fdt.h>
-#include <libfdt.h>
-#include <fdt_support.h>
-#elif defined(CONFIG_OF_FLAT_TREE)
-#include <ft_build.h>
-#endif
-
 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
 #include <rtc.h>
 #endif
@@ -390,7 +382,7 @@ U_BOOT_CMD(
 	"[addr [arg ...]]\n    - boot application image stored in memory\n"
 	"\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
 	"\t'arg' can be the address of an initrd image\n"
-#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT)
+#if defined(CONFIG_OF_LIBFDT)
 	"\tWhen booting a Linux kernel which requires a flat device-tree\n"
 	"\ta third argument is required which is the address of the\n"
 	"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
lib_ppc/bootm.c +6 -59

125 lines not on this page · raw message

#5 lore raw

PATCH 4/6 Remove standalone applications handling from boootm

In reply to Marian Balakowicz

Standalone applications are supposed to be run using the "go" command. This patch removes standalone images handling from the do_bootm().

---

 common/cmd_bootm.c |   26 +-------------------------
 1 files changed, 1 insertions(+), 25 deletions(-)
common/cmd_bootm.c +1 -25
index 3390be7..9fccb32 100644
@@ -116,8 +116,7 @@ ulong load_addr = CFG_LOAD_ADDR;	/* Default Load Address */
 int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	ulong		iflag;
-	char		*name, *s;
-	int		(*appl)(int, char *[]);
+	char		*name;
 	uint		unc_len = CFG_BOOTM_LEN;
 	int		verify = getenv_verify();
 
@@ -189,13 +188,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	show_boot_progress (5);
 
 	switch (image_get_type (hdr)) {
-	case IH_TYPE_STANDALONE:
-		name = "Standalone Application";
-		/* A second argument overwrites the load address */
-		if (argc > 2) {
-			image_set_load (hdr, simple_strtoul (argv[2], NULL, 16));
-		}
-		break;
 	case IH_TYPE_KERNEL:
 		name = "Kernel Image";
 		os_data = image_get_data (hdr);
@@ -299,22 +291,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	}
 
 	switch (image_get_type (hdr)) {
-	case IH_TYPE_STANDALONE:
-		if (iflag)
-			enable_interrupts();
-
-		/* load (and uncompress), but don't start if "autostart"
-		 * is set to "no"
-		 */
-		if (((s = getenv("autostart")) != NULL) && (strcmp(s,"no") == 0)) {
-			char buf[32];
-			sprintf(buf, "%lX", image_get_data_size(hdr));
-			setenv("filesize", buf);
-			return 0;
-		}
-		appl = (int (*)(int, char *[]))image_get_ep (hdr);
-		(*appl)(argc-1, &argv[1]);
-		return 0;
 	case IH_TYPE_KERNEL:
 	case IH_TYPE_MULTI:
 		/* handled below */

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

PATCH 4/6 Remove standalone applications handling from boootm

Quoted 8 lines · Marian Balakowicz
Quoted 8 lines
Quoted 4 lines

Standalone applications are supposed to be run using the "go" command. This patch removes standalone images handling from the do_bootm().

For me handling standalone images in bootm is a big win and I do not want it removed.

...stuff deleted...

Quoted 5 lines

Agree. But bootm is not a place for standalone applications, bootm is a OS booting command. uImage support for standalone applications will be re-added when the new uImage format is implemented, perhaps as a separate command.

I guess I don't see why bootm shouldn't be able to boot whatever types of u-boot image files the code knows about. Why make n different boot commands for each format (unless there is a 'one ring to bind them all' kind of master boot command that will call the correct one).

In any case, can it please wait for deletion until the other code is ready?

#9 lore raw

PATCH 5/6 Factor out common routines for getting os/arch/type/comp names

In reply to Marian Balakowicz

Move numeric-id to name translation for image os/arch/type/comp header fields to a helper routines: image_get_os_name(), image_get_arch_name(), image_get_type_name(), image_get_comp_name().

---

 common/cmd_bootm.c |   77 +++++++----------------------------------------
 common/image.c     |   86 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/image.h    |    5 +++
 3 files changed, 103 insertions(+), 65 deletions(-)
common/cmd_bootm.c +12 -65
index 9fccb32..356c8b3 100644
@@ -116,7 +116,7 @@ ulong load_addr = CFG_LOAD_ADDR;	/* Default Load Address */
 int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	ulong		iflag;
-	char		*name;
+	const char	*type_name;
 	uint		unc_len = CFG_BOOTM_LEN;
 	int		verify = getenv_verify();
 
@@ -189,12 +189,10 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	switch (image_get_type (hdr)) {
 	case IH_TYPE_KERNEL:
-		name = "Kernel Image";
 		os_data = image_get_data (hdr);
 		os_len = image_get_data_size (hdr);
 		break;
 	case IH_TYPE_MULTI:
-		name = "Multi-File Image";
 		image_multi_getimg (hdr, 0, &os_data, &os_len);
 		break;
 	default:
@@ -222,6 +220,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	dcache_disable();
 #endif
 
+	type_name = image_get_type_name (image_get_type (hdr));
+
 	image_start = (ulong)hdr;
 	image_end = image_get_image_end (hdr);
 	load_start = image_get_load (hdr);
@@ -230,9 +230,9 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	switch (image_get_comp (hdr)) {
 	case IH_COMP_NONE:
 		if (image_get_load (hdr) == img_addr) {
-			printf ("   XIP %s ... ", name);
+			printf ("   XIP %s ... ", type_name);
 		} else {
-			printf ("   Loading %s ... ", name);
+			printf ("   Loading %s ... ", type_name);
 
 			memmove_wd ((void *)image_get_load (hdr),
 				   (void *)os_data, os_len, CHUNKSZ);
@@ -242,7 +242,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		}
 		break;
 	case IH_COMP_GZIP:
-		printf ("   Uncompressing %s ... ", name);
+		printf ("   Uncompressing %s ... ", type_name);
 		if (gunzip ((void *)image_get_load (hdr), unc_len,
 					(uchar *)os_data, &os_len) != 0) {
 			puts ("GUNZIP ERROR - must RESET board to recover\n");
@@ -254,7 +254,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		break;
 #ifdef CONFIG_BZIP2
 	case IH_COMP_BZIP2:
-		printf ("   Uncompressing %s ... ", name);
+		printf ("   Uncompressing %s ... ", type_name);
 		/*
 		 * If we've got less than 4 MB of malloc() space,
 		 * use slower decompression algorithm which requires
@@ -556,65 +556,12 @@ void print_image_hdr (image_header_t *hdr)
 
 static void print_type (image_header_t *hdr)
 {
-	char *os, *arch, *type, *comp;
-
-	switch (image_get_os (hdr)) {
-	case IH_OS_INVALID:	os = "Invalid OS";		break;
-	case IH_OS_NETBSD:	os = "NetBSD";			break;
-	case IH_OS_LINUX:	os = "Linux";			break;
-	case IH_OS_VXWORKS:	os = "VxWorks";			break;
-	case IH_OS_QNX:		os = "QNX";			break;
-	case IH_OS_U_BOOT:	os = "U-Boot";			break;
-	case IH_OS_RTEMS:	os = "RTEMS";			break;
-#ifdef CONFIG_ARTOS
-	case IH_OS_ARTOS:	os = "ARTOS";			break;
-#endif
-#ifdef CONFIG_LYNXKDI
-	case IH_OS_LYNXOS:	os = "LynxOS";			break;
-#endif
-	default:		os = "Unknown OS";		break;
-	}
+	const char *os, *arch, *type, *comp;
 
-	switch (image_get_arch (hdr)) {
-	case IH_ARCH_INVALID:	arch = "Invalid CPU";		break;
-	case IH_ARCH_ALPHA:	arch = "Alpha";			break;
-	case IH_ARCH_ARM:	arch = "ARM";			break;
-	case IH_ARCH_AVR32:	arch = "AVR32";			break;
-	case IH_ARCH_BLACKFIN:	arch = "Blackfin";		break;
-	case IH_ARCH_I386:	arch = "Intel x86";		break;
-	case IH_ARCH_IA64:	arch = "IA64";			break;
-	case IH_ARCH_M68K:	arch = "M68K"; 			break;
-	case IH_ARCH_MICROBLAZE:arch = "Microblaze"; 		break;
-	case IH_ARCH_MIPS64:	arch = "MIPS 64 Bit";		break;
-	case IH_ARCH_MIPS:	arch = "MIPS";			break;
-	case IH_ARCH_NIOS2:	arch = "Nios-II";		break;
-	case IH_ARCH_NIOS:	arch = "Nios";			break;
-	case IH_ARCH_PPC:	arch = "PowerPC";		break;
-	case IH_ARCH_S390:	arch = "IBM S390";		break;
-	case IH_ARCH_SH:	arch = "SuperH";		break;
-	case IH_ARCH_SPARC64:	arch = "SPARC 64 Bit";		break;
-	case IH_ARCH_SPARC:	arch = "SPARC";			break;
-	default:		arch = "Unknown Architecture";	break;
-	}
-
-	switch (image_get_type (hdr)) {
-	case IH_TYPE_INVALID:	type = "Invalid Image";		break;
-	case IH_TYPE_STANDALONE:type = "Standalone Program";	break;
-	case IH_TYPE_KERNEL:	type = "Kernel Image";		break;
-	case IH_TYPE_RAMDISK:	type = "RAMDisk Image";		break;
-	case IH_TYPE_MULTI:	type = "Multi-File Image";	break;
-	case IH_TYPE_FIRMWARE:	type = "Firmware";		break;
-	case IH_TYPE_SCRIPT:	type = "Script";		break;
-	case IH_TYPE_FLATDT:	type = "Flat Device Tree";	break;
-	default:		type = "Unknown Image";		break;
-	}
-
-	switch (image_get_comp (hdr)) {
-	case IH_COMP_NONE:	comp = "uncompressed";		break;
-	case IH_COMP_GZIP:	comp = "gzip compressed";	break;
-	case IH_COMP_BZIP2:	comp = "bzip2 compressed";	break;
-	default:		comp = "unknown compression";	break;
-	}
+	os = image_get_os_name (image_get_os (hdr));
+	arch = image_get_arch_name (image_get_arch (hdr));
+	type = image_get_type_name (image_get_type (hdr));
+	comp = image_get_comp_name (image_get_comp (hdr));
 
 	printf ("%s %s %s (%s)", arch, os, type, comp);
 }
common/image.c +86 -0

89 lines not on this page · raw message

include/image.h +5 -0
index c605d66..87ef5d8 100644
@@ -328,4 +328,9 @@ ulong image_multi_count (image_header_t *hdr);
 void image_multi_getimg (image_header_t *hdr, ulong idx,
 			ulong *data, ulong *len);
 
+const char* image_get_os_name (uint8_t os);
+const char* image_get_arch_name (uint8_t arch);
+const char* image_get_type_name (uint8_t type);
+const char* image_get_comp_name (uint8_t comp);
+
 #endif	/* __IMAGE_H__ */
#10 lore raw

PATCH 6/6 Move FDT error printing to common fdt_error() routine

In reply to Marian Balakowicz

FDT error handling in PPC do_bootm_linux() shares the same message format. This patch moves error message printing to a helper fdt_error() routine.

---

 lib_ppc/bootm.c |   50 ++++++++++++++++++++++++--------------------------
 1 files changed, 24 insertions(+), 26 deletions(-)
lib_ppc/bootm.c +24 -26
index 16b2f38..8b8bb6d 100644
@@ -39,6 +39,8 @@
 #include <fdt.h>
 #include <libfdt.h>
 #include <fdt_support.h>
+
+static void fdt_error(const char *msg);
 #endif
 
 #ifdef CONFIG_LOGBUFFER
@@ -269,38 +271,32 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 			load_end = load_start + image_get_data_size (fdt_hdr);
 
 			if ((load_start < image_end) && (load_end > image_start)) {
-				puts ("ERROR: fdt overwritten - "
-					"must RESET the board to recover.\n");
+				fdt_error ("fdt overwritten");
 				do_reset (cmdtp, flag, argc, argv);
 			}
 
 			puts ("   Verifying Checksum ... ");
 			if (!image_check_hcrc (fdt_hdr)) {
-				puts ("ERROR: fdt header checksum invalid - "
-					"must RESET the board to recover.\n");
+				fdt_error ("fdt header checksum invalid");
 				do_reset (cmdtp, flag, argc, argv);
 			}
 
 			if (!image_check_dcrc (fdt_hdr)) {
-				puts ("ERROR: fdt checksum invalid - "
-					"must RESET the board to recover.\n");
+				fdt_error ("fdt checksum invalid");
 				do_reset (cmdtp, flag, argc, argv);
 			}
 			puts ("OK\n");
 
 			if (!image_check_type (fdt_hdr, IH_TYPE_FLATDT)) {
-				puts ("ERROR: uImage is not a fdt - "
-					"must RESET the board to recover.\n");
+				fdt_error ("uImage is not a fdt");
 				do_reset (cmdtp, flag, argc, argv);
 			}
 			if (image_get_comp (fdt_hdr) != IH_COMP_NONE) {
-				puts ("ERROR: uImage is compressed - "
-					"must RESET the board to recover.\n");
+				fdt_error ("uImage is compressed");
 				do_reset (cmdtp, flag, argc, argv);
 			}
 			if (fdt_check_header (of_flat_tree + image_get_header_size ()) != 0) {
-				puts ("ERROR: uImage data is not a fdt - "
-					"must RESET the board to recover.\n");
+				fdt_error ("uImage data is not a fdt");
 				do_reset (cmdtp, flag, argc, argv);
 			}
 
@@ -310,8 +306,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 
 			of_flat_tree = (char *)image_get_load (fdt_hdr);
 		} else {
-			puts ("Did not find a flat Flat Device Tree.\n"
-				"Must RESET the board to recover.\n");
+			fdt_error ("Did not find a flat Flat Device Tree");
 			do_reset (cmdtp, flag, argc, argv);
 		}
 		printf ("   Booting using the fdt at 0x%x\n",
@@ -331,14 +326,12 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 #endif
 
 			if (fdt_check_header (of_flat_tree) != 0) {
-				puts ("ERROR: image is not a fdt - "
-					"must RESET the board to recover.\n");
+				fdt_error ("image is not a fdt");
 				do_reset (cmdtp, flag, argc, argv);
 			}
 
 			if (be32_to_cpu (fdt_totalsize (of_flat_tree)) != fdt_len) {
-				puts ("ERROR: fdt size != image size - "
-					"must RESET the board to recover.\n");
+				fdt_error ("fdt size != image size");
 				do_reset (cmdtp, flag, argc, argv);
 			}
 		}
@@ -428,8 +421,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 			of_start, of_start + of_len - 1);
 		err = fdt_open_into((void *)of_data, (void *)of_start, of_len);
 		if (err != 0) {
-			puts ("ERROR: fdt move failed - "
-				"must RESET the board to recover.\n");
+			fdt_error ("fdt move failed");
 			do_reset (cmdtp, flag, argc, argv);
 		}
 		puts ("OK\n");
@@ -440,21 +432,18 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	 */
 	if (of_flat_tree) {
 		if (fdt_chosen(of_flat_tree, initrd_start, initrd_end, 0) < 0) {
-			puts ("ERROR: /chosen node create failed - "
-				"must RESET the board to recover.\n");
+			fdt_error ("/chosen node create failed");
 			do_reset (cmdtp, flag, argc, argv);
 		}
 #ifdef CONFIG_OF_HAS_UBOOT_ENV
 		if (fdt_env(of_flat_tree) < 0) {
-			puts ("ERROR: /u-boot-env node create failed - "
-				"must RESET the board to recover.\n");
+			fdt_error ("/u-boot-env node create failed");
 			do_reset (cmdtp, flag, argc, argv);
 		}
 #endif
 #ifdef CONFIG_OF_HAS_BD_T
 		if (fdt_bd_t(of_flat_tree) < 0) {
-			puts ("ERROR: /bd_t node create failed - "
-				"must RESET the board to recover.\n");
+			fdte_error ("/bd_t node create failed");
 			do_reset (cmdtp, flag, argc, argv);
 		}
 #endif
@@ -499,3 +488,12 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
 	/* does not return */
 }
+
+#if defined(CONFIG_OF_LIBFDT)
+static void fdt_error(const char *msg)
+{
+	puts ("ERROR: ");
+	puts (msg);
+	puts (" - must RESET the board to recover.\n");
+}
+#endif
#11 lore raw

PATCH 6/6 Move FDT error printing to common fdt_error() routine

Quoted 8 lines · Marian Balakowicz

FDT error handling in PPC do_bootm_linux() shares the same message format. This patch moves error message printing to a helper fdt_error() routine.

---

 lib_ppc/bootm.c |   50 ++++++++++++++++++++++++--------------------------
 1 files changed, 24 insertions(+), 26 deletions(-)

[snip]

lib_ppc/bootm.c do_bootm_linux(cmd_tbl_t *cmdtp, int flag, · line 309

Quoted 7 lines
lib_ppc/bootm.c +1 -2
@@ -310,8 +306,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 
 			of_flat_tree = (char *)image_get_load (fdt_hdr);
 		} else {
-			puts ("Did not find a flat Flat Device Tree.\n"
-				"Must RESET the board to recover.\n");
+			fdt_error ("Did not find a flat Flat Device Tree");

Ouch, I messed that one up pretty badly in the original. Should be
"Did not find a Flattened Device Tree"
s/flat Flat/Flattened/

[snip]

lib_ppc/bootm.c do_bootm_linux(cmd_tbl_t *cmdtp, int flag, · line 446

Quoted 6 lines
lib_ppc/bootm.c +1 -2
 #endif
 #ifdef CONFIG_OF_HAS_BD_T
 		if (fdt_bd_t(of_flat_tree) < 0) {
-			puts ("ERROR: /bd_t node create failed - "
-				"must RESET the board to recover.\n");
+			fdte_error ("/bd_t node create failed");

Typo s/fdte_error/fdt_error/

[snip]

FWIIW, with the above changes...

Good improvement, thanks.
gvb

#12 lore raw

cover patchset2 - cleanup cont.

In reply to Marian Balakowicz
Quoted 20 lines · Marian Balakowicz

Hi,

This is a second patchset for new uImage, it includes architecture file
renames, removals of OF_FLAT_TREE and standalone application support and
further code refactoring.

This patchset is based on patchset1. MAKEALL was run for ppc/arm/ mips/coldfire,
architestures, plus regression tests on lite5200b.

[new uImage] Move FDT error printing to common fdt_error() routine [new uImage] Factor out common routines for getting os/arch/type/ comp names
[new uImage] Remove standalone applications handling from boootm [new uImage] Remove OF_FLAT_TREE support from PPC bootm code [new uImage] Use image API in SH do_bootm_linux() routine [new uImage] Rename architecture specific bootm code files

Quoted 2 lines

Cheers,
m.

I haven't looked through these, but is it possible to make it so if you are using a flat device tree blob on PPC that we can grow the size dynamically as we handle some of the board fixups as part of the bootm processing?

- k

#13 lore raw

cover patchset2 - cleanup cont.

Quoted 17 lines · Kumar Gala
Quoted 9 lines

This is a second patchset for new uImage, it includes architecture file renames, removals of OF_FLAT_TREE and standalone application support and further code refactoring.

This patchset is based on patchset1. MAKEALL was run for ppc/arm/mips/coldfire,
architestures, plus regression tests on lite5200b.

Quoted 7 lines

[new uImage] Move FDT error printing to common fdt_error() routine [new uImage] Factor out common routines for getting os/arch/type/comp names
[new uImage] Remove standalone applications handling from boootm [new uImage] Remove OF_FLAT_TREE support from PPC bootm code [new uImage] Use image API in SH do_bootm_linux() routine [new uImage] Rename architecture specific bootm code files

Quoted 4 lines

I haven't looked through these, but is it possible to make it so if you are using a flat device tree blob on PPC that we can grow the size dynamically as we handle some of the board fixups as part of the bootm processing?

That should be possible. It'll require to always move the blob to the new location (with the new size) - currently we move it only if needed. And, we would need to figure out what the grow delta should be, reading it from env variable (with the fallback default) should be flexible enough. But I would prefer to get back to this feature when new uImage is in place.

Cheers,
m.