From a63d9652757605ec5f7104addc5d38bf10ba8671 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Mon, 28 Nov 2011 20:19:41 +0100 Subject: menu.c: use puts() instead of printf() where possible common/menu.c used printf() in a number of places to print user provided, constant strings (like the "title" string). printf() is dangerous here for example in case the user unwittingly embeds some '%' caracters that printf() would interpret as formatting and then pick up random arguments. Use puts() instead. We also omit the trailing ':' in the title line - if a user wants this, he can provide it as part of the title string. Signed-off-by: Wolfgang Denk --- common/menu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/menu.c b/common/menu.c index f004823..ca1baef 100644 --- a/common/menu.c +++ b/common/menu.c @@ -87,10 +87,12 @@ static inline void *menu_item_print(struct menu *m, struct menu_item *item, void *extra) { - if (!m->item_data_print) - printf("%s\n", item->key); - else + if (!m->item_data_print) { + putc(item->key); + putc('\n'); + } else { m->item_data_print(item->data); + } return NULL; } @@ -117,8 +119,10 @@ static inline void *menu_item_destroy(struct menu *m, */ static inline void menu_display(struct menu *m) { - if (m->title) - printf("%s:\n", m->title); + if (m->title) { + puts(m->title); + putc('\n'); + } menu_items_iter(m, menu_item_print, NULL); } @@ -226,7 +230,7 @@ static inline int menu_interactive_choice(struct menu *m, void **choice) if (!choice_item) printf("%s not found\n", cbuf); } else { - printf("^C\n"); + puts("^C\n"); return -EINTR; } } -- cgit v1.1 From a76fc70ee190416e0c161efebdb955a5fac904d3 Mon Sep 17 00:00:00 2001 From: Graeme Russ Date: Tue, 8 Nov 2011 02:33:20 +0000 Subject: x86: Provide more configuration granularity Planned future ports requires more granularity for some options Signed-off-by: Graeme Russ --- common/cmd_bdinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index 688b238..6c48594 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -31,7 +31,8 @@ DECLARE_GLOBAL_DATA_PTR; static void print_num(const char *, ulong); -#if !(defined(CONFIG_ARM) || defined(CONFIG_M68K) || defined(CONFIG_SANDBOX)) \ +#if !(defined(CONFIG_ARM) || defined(CONFIG_M68K) || \ + defined(CONFIG_SANDBOX) || defined(CONFIG_X86)) \ || defined(CONFIG_CMD_NET) #define HAVE_PRINT_ETH static void print_eth(int idx); -- cgit v1.1 From b9b50e89d317c58becd0e2d7fac2e21e3a81dd0a Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 10 Nov 2011 13:17:53 -0700 Subject: image: Implement IH_TYPE_KERNEL_NOLOAD The legacy uImage format includes an absolute load and entry-point address. When bootm operates on a kernel uImage in memory that isn't loaded at the address in the image's load address, U-Boot will copy the image to its address in the header. Some kernel images can actually be loaded and used at any arbitrary address. An example is an ARM Linux kernel zImage file. To represent this capability, IH_TYPE_KERNEL_NOLOAD is implemented, which operates just like IH_TYPE_KERNEL, except that the load address header is ignored, and U-Boot does not copy the image to its load address, but rather uses it in-place. This is useful when sharing a single (uImage-wrapped) zImage across multiple boards with different memory layouts; in this case, a specific load address need not be picked when creating the uImage, but instead is selected by the board-specific U-Boot environment used to load and boot that image. v2: Rename from IH_TYPE_KERNEL_ANYLOAD to IH_TYPE_KERNEL_NOLOAD. Signed-off-by: Stephen Warren Signed-off-by: Stefan Roese --- common/cmd_bootm.c | 10 +++++++++- common/image.c | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index b073f09..8cafe3e 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -272,7 +272,13 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] return 1; } + if (images.os.type == IH_TYPE_KERNEL_NOLOAD) { + images.os.load = images.os.image_start; + images.ep += images.os.load; + } + if (((images.os.type == IH_TYPE_KERNEL) || + (images.os.type == IH_TYPE_KERNEL_NOLOAD) || (images.os.type == IH_TYPE_MULTI)) && (images.os.os == IH_OS_LINUX)) { /* find ramdisk */ @@ -796,7 +802,8 @@ static int fit_check_kernel(const void *fit, int os_noffset, int verify) } show_boot_progress(106); - if (!fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL)) { + if (!fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL) && + !fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL_NOLOAD)) { puts("Not a kernel image\n"); show_boot_progress(-106); return 0; @@ -874,6 +881,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, /* get os_data and os_len */ switch (image_get_type(hdr)) { case IH_TYPE_KERNEL: + case IH_TYPE_KERNEL_NOLOAD: *os_data = image_get_data(hdr); *os_len = image_get_data_size(hdr); break; diff --git a/common/image.c b/common/image.c index 555d9d9..aacae5a 100644 --- a/common/image.c +++ b/common/image.c @@ -136,6 +136,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_FIRMWARE, "firmware", "Firmware", }, { IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", }, { IH_TYPE_KERNEL, "kernel", "Kernel Image", }, + { IH_TYPE_KERNEL_NOLOAD, "kernel_noload", "Kernel Image (no loading done)", }, { IH_TYPE_KWBIMAGE, "kwbimage", "Kirkwood Boot Image",}, { IH_TYPE_IMXIMAGE, "imximage", "Freescale i.MX Boot Image",}, { IH_TYPE_INVALID, NULL, "Invalid Image", }, -- cgit v1.1 From d510859bed4165ebf2635c74c40a037cd2819fce Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 10 Nov 2011 13:17:54 -0700 Subject: image: Don't detect XIP images as overlapping. bootm_load_os() detects when it writes the decompressed image over the top of the compressed image. If this happens, the original image is corrupted. When the original image is a multi-component legacy image, or a (potentially multi-component) FIT image, this implies that other components may be corrupted. In turn, this means that booting is unlikely to be successful. However, in the case of no image compresssion coupled with an image with load address equal to where the image is already located (e.g. an XIP kernel, or IH_TYPE_KERNEL_ANYLOAD), there has been no copy and hence no corruption, no matter whether it's a single-component legacy image, a multi-component legacy image, or a FIT image. In this case, disable the overlap detection, and allow boot to continue. Without this change, when booting a single-component legacy image that contains an IH_TYPE_KERNEL_ANYLOAD, bootm_load_os() would have returned BOOTM_ERR_OVERLAP, but the caller ignores this, and boot continues and succeeds. Now, the false error is no longer even returned. Without this change, when booting a FIT image that contains an IH_TYPE_KERNEL_ANYLOAD, bootm_load_os() would have returned BOOTM_ERR_OVERLAP, which would then cause the caller to reset the board. Now, the false error is no longer returned, and boot succeeds. Signed-off-by: Stephen Warren Signed-off-by: Stefan Roese --- common/cmd_bootm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 8cafe3e..d5745b1 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -320,6 +320,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) ulong image_start = os.image_start; ulong image_len = os.image_len; __maybe_unused uint unc_len = CONFIG_SYS_BOOTM_LEN; + int no_overlap = 0; #if defined(CONFIG_LZMA) || defined(CONFIG_LZO) int ret; #endif /* defined(CONFIG_LZMA) || defined(CONFIG_LZO) */ @@ -330,6 +331,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) case IH_COMP_NONE: if (load == blob_start || load == image_start) { printf(" XIP %s ... ", type_name); + no_overlap = 1; } else { printf(" Loading %s ... ", type_name); memmove_wd((void *)load, (void *)image_start, @@ -424,7 +426,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) if (boot_progress) show_boot_progress(7); - if ((load < blob_end) && (*load_end > blob_start)) { + if (!no_overlap && (load < blob_end) && (*load_end > blob_start)) { debug("images.os.start = 0x%lX, images.os.end = 0x%lx\n", blob_start, blob_end); debug("images.os.load = 0x%lx, load_end = 0x%lx\n", load, -- cgit v1.1