[U-Boot-Users] [PATCH 0/6] [new uImage] 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.

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.
Signed-off-by: Marian Balakowicz m8@semihalf.com --- 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(-)
diff --git a/lib_arm/Makefile b/lib_arm/Makefile index 037c475..aa9bee7 100644 --- a/lib_arm/Makefile +++ b/lib_arm/Makefile @@ -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) diff --git a/lib_arm/armlinux.c b/lib_arm/bootm.c similarity index 100% rename from lib_arm/armlinux.c rename to lib_arm/bootm.c diff --git a/lib_avr32/Makefile b/lib_avr32/Makefile index bb2938f..ebe237b 100644 --- a/lib_avr32/Makefile +++ b/lib_avr32/Makefile @@ -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)) diff --git a/lib_avr32/avr32_linux.c b/lib_avr32/bootm.c similarity index 100% rename from lib_avr32/avr32_linux.c rename to lib_avr32/bootm.c diff --git a/lib_blackfin/Makefile b/lib_blackfin/Makefile index a7aaef7..ac3fb28 100644 --- a/lib_blackfin/Makefile +++ b/lib_blackfin/Makefile @@ -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)) diff --git a/lib_blackfin/bf533_linux.c b/lib_blackfin/bootm.c similarity index 100% rename from lib_blackfin/bf533_linux.c rename to lib_blackfin/bootm.c diff --git a/lib_i386/Makefile b/lib_i386/Makefile index e344da5..ef0ba54 100644 --- a/lib_i386/Makefile +++ b/lib_i386/Makefile @@ -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) diff --git a/lib_i386/i386_linux.c b/lib_i386/bootm.c similarity index 100% rename from lib_i386/i386_linux.c rename to lib_i386/bootm.c diff --git a/lib_m68k/Makefile b/lib_m68k/Makefile index 03784fd..d515223 100644 --- a/lib_m68k/Makefile +++ b/lib_m68k/Makefile @@ -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)) diff --git a/lib_m68k/m68k_linux.c b/lib_m68k/bootm.c similarity index 100% rename from lib_m68k/m68k_linux.c rename to lib_m68k/bootm.c diff --git a/lib_microblaze/Makefile b/lib_microblaze/Makefile index 82b7bea..9b317a2 100644 --- a/lib_microblaze/Makefile +++ b/lib_microblaze/Makefile @@ -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)) diff --git a/lib_microblaze/microblaze_linux.c b/lib_microblaze/bootm.c similarity index 100% rename from lib_microblaze/microblaze_linux.c rename to lib_microblaze/bootm.c diff --git a/lib_mips/Makefile b/lib_mips/Makefile index 3163f00..93cca7a 100644 --- a/lib_mips/Makefile +++ b/lib_mips/Makefile @@ -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)) diff --git a/lib_mips/mips_linux.c b/lib_mips/bootm.c similarity index 100% rename from lib_mips/mips_linux.c rename to lib_mips/bootm.c diff --git a/lib_nios/Makefile b/lib_nios/Makefile index 7c9d62c..d8ae7bd 100644 --- a/lib_nios/Makefile +++ b/lib_nios/Makefile @@ -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)) diff --git a/lib_nios/nios_linux.c b/lib_nios/bootm.c similarity index 100% rename from lib_nios/nios_linux.c rename to lib_nios/bootm.c diff --git a/lib_nios2/Makefile b/lib_nios2/Makefile index 1ff2f29..5f996d3 100644 --- a/lib_nios2/Makefile +++ b/lib_nios2/Makefile @@ -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)) diff --git a/lib_nios2/nios_linux.c b/lib_nios2/bootm.c similarity index 100% rename from lib_nios2/nios_linux.c rename to lib_nios2/bootm.c diff --git a/lib_ppc/Makefile b/lib_ppc/Makefile index 2aa0154..6845ed0 100644 --- a/lib_ppc/Makefile +++ b/lib_ppc/Makefile @@ -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)) diff --git a/lib_ppc/ppc_linux.c b/lib_ppc/bootm.c similarity index 100% rename from lib_ppc/ppc_linux.c rename to lib_ppc/bootm.c diff --git a/lib_sh/Makefile b/lib_sh/Makefile index cf127a8..edb03d0 100644 --- a/lib_sh/Makefile +++ b/lib_sh/Makefile @@ -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)) diff --git a/lib_sh/sh_linux.c b/lib_sh/bootm.c similarity index 100% rename from lib_sh/sh_linux.c rename to lib_sh/bootm.c

On 15:44 Wed 23 Jan , Marian Balakowicz wrote:
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.
Signed-off-by: Marian Balakowicz m8@semihalf.com
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(-)
diff --git a/lib_arm/Makefile b/lib_arm/Makefile index 037c475..aa9bee7 100644 --- a/lib_arm/Makefile +++ b/lib_arm/Makefile @@ -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.

Introduce image handling API for lately added Hitachi SH architecture.
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
lib_sh/bootm.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib_sh/bootm.c b/lib_sh/bootm.c index 14b6815..4e5fe77 100644 --- a/lib_sh/bootm.c +++ b/lib_sh/bootm.c @@ -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 */

Support for OF_FLAT_TREE is to be obsoleted in the near future, remove related code from the bootm routines.
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
common/cmd_bootm.c | 10 +------- lib_ppc/bootm.c | 65 +++++----------------------------------------------- 2 files changed, 7 insertions(+), 68 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index f441e0e..3390be7 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -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" diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index 3911687..16b2f38 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -39,8 +39,6 @@ #include <fdt.h> #include <libfdt.h> #include <fdt_support.h> -#elif defined(CONFIG_OF_FLAT_TREE) -#include <ft_build.h> #endif
#ifdef CONFIG_LOGBUFFER @@ -79,7 +77,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, bd_t *kbd; void (*kernel)(bd_t *, ulong, ulong, ulong, ulong);
-#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) +#if defined(CONFIG_OF_LIBFDT) image_header_t *fdt_hdr; char *of_flat_tree = NULL; ulong of_data = 0; @@ -175,7 +173,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, * Check if there is an initrd image */
-#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) +#if defined(CONFIG_OF_LIBFDT) /* Look for a '-' which indicates to ignore the ramdisk argument */ if (argc >= 3 && strcmp(argv[2], "-") == 0) { debug ("Skipping initrd\n"); @@ -247,15 +245,12 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, rd_len = rd_data = 0; }
-#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) +#if defined(CONFIG_OF_LIBFDT) if(argc > 3) { of_flat_tree = (char *) simple_strtoul(argv[3], NULL, 16); fdt_hdr = (image_header_t *)of_flat_tree; -#if defined(CONFIG_OF_FLAT_TREE) - if (*((ulong *)(of_flat_tree)) == OF_DT_HEADER) { -#elif defined(CONFIG_OF_LIBFDT) + if (fdt_check_header (of_flat_tree) == 0) { -#endif #ifndef CFG_NO_FLASH if (addr2info((ulong)of_flat_tree) != NULL) of_data = (ulong)of_flat_tree; @@ -303,11 +298,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, "must RESET the board to recover.\n"); do_reset (cmdtp, flag, argc, argv); } -#if defined(CONFIG_OF_FLAT_TREE) - if (*((ulong *)(of_flat_tree + image_get_header_size ())) != OF_DT_HEADER) { -#elif defined(CONFIG_OF_LIBFDT) if (fdt_check_header (of_flat_tree + image_get_header_size ()) != 0) { -#endif puts ("ERROR: uImage data is not a fdt - " "must RESET the board to recover.\n"); do_reset (cmdtp, flag, argc, argv); @@ -339,21 +330,13 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, of_data = (ulong)of_flat_tree; #endif
-#if defined(CONFIG_OF_FLAT_TREE) - if (*((ulong *)(of_flat_tree)) != OF_DT_HEADER) { -#elif defined(CONFIG_OF_LIBFDT) if (fdt_check_header (of_flat_tree) != 0) { -#endif puts ("ERROR: image is not a fdt - " "must RESET the board to recover.\n"); do_reset (cmdtp, flag, argc, argv); }
-#if defined(CONFIG_OF_FLAT_TREE) - if (((struct boot_param_header *)of_flat_tree)->totalsize != fdt_len) { -#elif defined(CONFIG_OF_LIBFDT) if (be32_to_cpu (fdt_totalsize (of_flat_tree)) != fdt_len) { -#endif puts ("ERROR: fdt size != image size - " "must RESET the board to recover.\n"); do_reset (cmdtp, flag, argc, argv); @@ -480,43 +463,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, ft_board_setup(of_flat_tree, gd->bd); #endif } - -#elif defined(CONFIG_OF_FLAT_TREE) - -#ifdef CFG_BOOTMAPSZ - /* - * The blob must be within CFG_BOOTMAPSZ, - * so we flag it to be copied if it is not. - */ - if (of_flat_tree >= (char *)CFG_BOOTMAPSZ) - of_data = (ulong)of_flat_tree; -#endif - - /* move of_flat_tree if needed */ - if (of_data) { - ulong of_start, of_len; - of_len = ((struct boot_param_header *)of_data)->totalsize; - - /* provide extra 8k pad */ - of_start = (ulong)kbd - of_len - 8192; - of_start &= ~(4096 - 1); /* align on page */ - debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", - of_data, of_data + of_len - 1, of_len, of_len); - - of_flat_tree = (char *)of_start; - printf (" Loading Device Tree to %08lx, end %08lx ... ", - of_start, of_start + of_len - 1); - memmove ((void *)of_start, (void *)of_data, of_len); - puts ("OK\n"); - } - /* - * Create the /chosen node and modify the blob with board specific - * values as needed. - */ - ft_setup(of_flat_tree, kbd, initrd_start, initrd_end); - /* ft_dump_blob(of_flat_tree); */ - -#endif /* #if defined(CONFIG_OF_LIBFDT) #elif defined(CONFIG_OF_FLAT_TREE) */ +#endif /* CONFIG_OF_LIBFDT */
debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong)kernel); @@ -527,7 +474,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, unlock_ram_in_cache(); #endif
-#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) +#if defined(CONFIG_OF_LIBFDT) if (of_flat_tree) { /* device tree; boot new style */ /* * Linux Kernel Parameters (passing device tree):

Standalone applications are supposed to be run using the "go" command. This patch removes standalone images handling from the do_bootm().
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
common/cmd_bootm.c | 26 +------------------------- 1 files changed, 1 insertions(+), 25 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 3390be7..9fccb32 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -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 */

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().
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
common/cmd_bootm.c | 77 +++++++---------------------------------------- common/image.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/image.h | 5 +++ 3 files changed, 103 insertions(+), 65 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 9fccb32..356c8b3 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -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); } diff --git a/common/image.c b/common/image.c index 6eee83d..9aeca9f 100644 --- a/common/image.c +++ b/common/image.c @@ -193,3 +193,89 @@ void image_multi_getimg (image_header_t *hdr, ulong idx, *data = 0; } } + +const char* image_get_os_name (uint8_t os) +{ + const char *name; + + switch (os) { + case IH_OS_INVALID: name = "Invalid OS"; break; + case IH_OS_NETBSD: name = "NetBSD"; break; + case IH_OS_LINUX: name = "Linux"; break; + case IH_OS_VXWORKS: name = "VxWorks"; break; + case IH_OS_QNX: name = "QNX"; break; + case IH_OS_U_BOOT: name = "U-Boot"; break; + case IH_OS_RTEMS: name = "RTEMS"; break; +#ifdef CONFIG_ARTOS + case IH_OS_ARTOS: name = "ARTOS"; break; +#endif +#ifdef CONFIG_LYNXKDI + case IH_OS_LYNXOS: name = "LynxOS"; break; +#endif + default: name = "Unknown OS"; break; + } + + return name; +} + +const char* image_get_arch_name (uint8_t arch) +{ + const char *name; + + switch (arch) { + case IH_ARCH_INVALID: name = "Invalid Architecture"; break; + case IH_ARCH_ALPHA: name = "Alpha"; break; + case IH_ARCH_ARM: name = "ARM"; break; + case IH_ARCH_AVR32: name = "AVR32"; break; + case IH_ARCH_BLACKFIN: name = "Blackfin"; break; + case IH_ARCH_I386: name = "Intel x86"; break; + case IH_ARCH_IA64: name = "IA64"; break; + case IH_ARCH_M68K: name = "M68K"; break; + case IH_ARCH_MICROBLAZE:name = "Microblaze"; break; + case IH_ARCH_MIPS64: name = "MIPS 64 Bit"; break; + case IH_ARCH_MIPS: name = "MIPS"; break; + case IH_ARCH_NIOS2: name = "Nios-II"; break; + case IH_ARCH_NIOS: name = "Nios"; break; + case IH_ARCH_PPC: name = "PowerPC"; break; + case IH_ARCH_S390: name = "IBM S390"; break; + case IH_ARCH_SH: name = "SuperH"; break; + case IH_ARCH_SPARC64: name = "SPARC 64 Bit"; break; + case IH_ARCH_SPARC: name = "SPARC"; break; + default: name = "Unknown Architecture"; break; + } + + return name; +} + +const char* image_get_type_name (uint8_t type) +{ + const char *name; + + switch (type) { + case IH_TYPE_INVALID: name = "Invalid Image"; break; + case IH_TYPE_STANDALONE:name = "Standalone Program"; break; + case IH_TYPE_KERNEL: name = "Kernel Image"; break; + case IH_TYPE_RAMDISK: name = "RAMDisk Image"; break; + case IH_TYPE_MULTI: name = "Multi-File Image"; break; + case IH_TYPE_FIRMWARE: name = "Firmware"; break; + case IH_TYPE_SCRIPT: name = "Script"; break; + case IH_TYPE_FLATDT: name = "Flat Device Tree"; break; + default: name = "Unknown Image"; break; + } + + return name; +} + +const char* image_get_comp_name (uint8_t comp) +{ + const char *name; + + switch (comp) { + case IH_COMP_NONE: name = "uncompressed"; break; + case IH_COMP_GZIP: name = "gzip compressed"; break; + case IH_COMP_BZIP2: name = "bzip2 compressed"; break; + default: name = "unknown compression"; break; + } + + return name; +} diff --git a/include/image.h b/include/image.h index c605d66..87ef5d8 100644 --- a/include/image.h +++ b/include/image.h @@ -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__ */

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.
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
lib_ppc/bootm.c | 50 ++++++++++++++++++++++++-------------------------- 1 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index 16b2f38..8b8bb6d 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -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

Marian Balakowicz wrote:
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.
Signed-off-by: Marian Balakowicz m8@semihalf.com
lib_ppc/bootm.c | 50 ++++++++++++++++++++++++-------------------------- 1 files changed, 24 insertions(+), 26 deletions(-)
[snip]
@@ -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]
#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...
Acked-by: Gerald Van Baren vanbaren@cideas.com
Good improvement, thanks. gvb

On Jan 23, 2008, at 8:43 AM, Marian Balakowicz wrote:
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.
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

Kumar Gala wrote:
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
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.
participants (4)
-
Jean-Christophe PLAGNIOL-VILLARD
-
Jerry Van Baren
-
Kumar Gala
-
Marian Balakowicz