[U-Boot-Users] [PATCH 0/9] [new uImage] Add support for booting images at non-zero addresses

This is an updated set of patches against the latest u-boot-testing#new-image.p5
Please apply.
- k

We don't actually need the kdb param as we are just using it to get bd->bi_memsize which we can get from gd->bd->bi_memsize. Also, if we boot via OF we might not actually fill out a kdb.
Signed-off-by: Kumar Gala galak@kernel.crashing.org --- common/image.c | 9 ++++----- include/image.h | 2 +- lib_m68k/bootm.c | 3 +-- lib_ppc/bootm.c | 3 +-- 4 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/common/image.c b/common/image.c index c689b0e..92c067f 100644 --- a/common/image.c +++ b/common/image.c @@ -694,7 +694,6 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], * ramdisk_high - relocate init ramdisk * @rd_data: ramdisk data start address * @rd_len: ramdisk data length - * @kbd: kernel board info copy (within BOOTMAPSZ boundary) * @sp_limit: stack pointer limit (including BOOTMAPSZ) * @sp: current stack pointer * @initrd_start: pointer to a ulong variable, will hold final init ramdisk @@ -712,7 +711,7 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], * - returns new allc_current, next free address below BOOTMAPSZ */ ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len, - bd_t *kbd, ulong sp_limit, ulong sp, + ulong sp_limit, ulong sp, ulong *initrd_start, ulong *initrd_end) { char *s; @@ -734,9 +733,9 @@ ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len,
#ifdef CONFIG_LOGBUFFER /* Prevent initrd from overwriting logbuffer */ - if (initrd_high < (kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD)) - initrd_high = kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD; - debug ("## Logbuffer at 0x%08lx ", kbd->bi_memsize - LOGBUFF_LEN); + if (initrd_high < (gd->bd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD)) + initrd_high = gd->bd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD; + debug ("## Logbuffer at 0x%08lx ", gd->bd->bi_memsize - LOGBUFF_LEN); #endif debug ("## initrd_high = 0x%08lx, copy_to_ram = %d\n", initrd_high, initrd_copy_to_ram); diff --git a/include/image.h b/include/image.h index 08566ea..1cec1db 100644 --- a/include/image.h +++ b/include/image.h @@ -388,7 +388,7 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
#if defined(CONFIG_PPC) || defined(CONFIG_M68K) ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len, - bd_t *kbd, ulong sp_limit, ulong sp, + ulong sp_limit, ulong sp, ulong *initrd_start, ulong *initrd_end);
ulong get_boot_sp_limit (ulong sp); diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c index c611497..74240af 100644 --- a/lib_m68k/bootm.c +++ b/lib_m68k/bootm.c @@ -100,8 +100,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
rd_len = rd_data_end - rd_data_start; alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len, - kbd, sp_limit, get_sp (), - &initrd_start, &initrd_end); + sp_limit, get_sp (), &initrd_start, &initrd_end);
debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) kernel); diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index d80d69a..fa28b43 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -120,8 +120,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], rd_len = rd_data_end - rd_data_start;
alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len, - kbd, sp_limit, get_sp (), - &initrd_start, &initrd_end); + sp_limit, get_sp (), &initrd_start, &initrd_end);
#if defined(CONFIG_OF_LIBFDT) /* find flattened device tree */

If we are bootin OF style than we can skip setting up some things that are used for the old boot method.
Signed-off-by: Kumar Gala galak@kernel.crashing.org --- lib_ppc/bootm.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index fa28b43..3e89da1 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -71,10 +71,10 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], bd_t *kbd; ulong ep = 0; void (*kernel)(bd_t *, ulong, ulong, ulong, ulong); + ulong of_size = 0;
#if defined(CONFIG_OF_LIBFDT) char *of_flat_tree = NULL; - ulong of_size = 0; #endif
/* @@ -92,12 +92,19 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], alloc_current = sp_limit = get_boot_sp_limit(sp); debug ("=> set upper limit to 0x%08lx\n", sp_limit);
- /* allocate space and init command line */ - alloc_current = get_boot_cmdline (alloc_current, &cmd_start, &cmd_end); +#if defined(CONFIG_OF_LIBFDT) + /* find flattened device tree */ + get_fdt (cmdtp, flag, argc, argv, images, &of_flat_tree, &of_size); +#endif
- /* allocate space for kernel copy of board info */ - alloc_current = get_boot_kbd (alloc_current, &kbd); - set_clocks_in_mhz(kbd); + if (!of_size) { + /* allocate space and init command line */ + alloc_current = get_boot_cmdline (alloc_current, &cmd_start, &cmd_end); + + /* allocate space for kernel copy of board info */ + alloc_current = get_boot_kbd (alloc_current, &kbd); + set_clocks_in_mhz(kbd); + }
/* find kernel entry point */ if (images->legacy_hdr_valid) { @@ -123,9 +130,6 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], sp_limit, get_sp (), &initrd_start, &initrd_end);
#if defined(CONFIG_OF_LIBFDT) - /* find flattened device 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);

Doing the fdt before the ramdisk allows us to grow the fdt w/o concern however it does mean we have to go in and fixup the initrd info since we don't know where it will be.
Signed-off-by: Kumar Gala galak@kernel.crashing.org --- lib_ppc/bootm.c | 39 +++++++++++++++++++++++++++++++++++---- 1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index 3e89da1..de6995e 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -71,6 +71,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], bd_t *kbd; ulong ep = 0; void (*kernel)(bd_t *, ulong, ulong, ulong, ulong); + int ret; ulong of_size = 0;
#if defined(CONFIG_OF_LIBFDT) @@ -126,9 +127,6 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
rd_len = rd_data_end - rd_data_start;
- alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len, - sp_limit, get_sp (), &initrd_start, &initrd_end); - #if defined(CONFIG_OF_LIBFDT) alloc_current = fdt_relocate (alloc_current, cmdtp, flag, argc, argv, &of_flat_tree, &of_size); @@ -138,7 +136,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], * if the user wants it (the logic is in the subroutines). */ if (of_size) { - if (fdt_chosen(of_flat_tree, initrd_start, initrd_end, 0) < 0) { + /* pass in dummy initrd info, we'll fix up later */ + if (fdt_chosen(of_flat_tree, rd_data_start, rd_data_end, 0) < 0) { fdt_error ("/chosen node create failed"); do_reset (cmdtp, flag, argc, argv); } @@ -161,6 +160,38 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], } #endif /* CONFIG_OF_LIBFDT */
+ alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len, + sp_limit, get_sp (), &initrd_start, &initrd_end); + +#if defined(CONFIG_OF_LIBFDT) + /* fixup the initrd now that we know where it should be */ + if ((of_flat_tree) && (initrd_start && initrd_end)) { + uint64_t addr, size; + int total = fdt_num_mem_rsv(of_flat_tree); + int j; + + /* Look for the dummy entry and delete it */ + for (j = 0; j < total; j++) { + fdt_get_mem_rsv(of_flat_tree, j, &addr, &size); + if (addr == rd_data_start) { + fdt_del_mem_rsv(of_flat_tree, j); + break; + } + } + + ret = fdt_add_mem_rsv(of_flat_tree, initrd_start, + initrd_end - initrd_start + 1); + if (ret < 0) { + printf("fdt_chosen: %s\n", fdt_strerror(ret)); + do_reset (cmdtp, flag, argc, argv); + } + + do_fixup_by_path_u32(of_flat_tree, "/chosen", + "linux,initrd-start", initrd_start, 0); + do_fixup_by_path_u32(of_flat_tree, "/chosen", + "linux,initrd-end", initrd_end, 0); + } +#endif debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong)kernel);

Changed image_get_ramdisk() to just return NULL on error and have get_ramdisk() propogate that error to the caller. It's left to the caller to call do_reset() if it wants to.
Also moved calling do_reset() in get_fdt() and fdt_relocate() on ppc to a common location. In the future we will change get_fdt() and fdt_relocate() to return success/failure and not call do_reset() at all.
Signed-off-by: Kumar Gala galak@kernel.crashing.org --- common/image.c | 26 ++++++++++++++-------- include/image.h | 2 +- lib_m68k/bootm.c | 13 ++++++++++- lib_ppc/bootm.c | 61 ++++++++++++++++++++++++++++++++++++----------------- 4 files changed, 70 insertions(+), 32 deletions(-)
diff --git a/common/image.c b/common/image.c index 92c067f..d4acb6b 100644 --- a/common/image.c +++ b/common/image.c @@ -51,8 +51,6 @@ #include <fdt_support.h> #endif
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); - #ifdef CONFIG_CMD_BDI extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); #endif @@ -491,7 +489,7 @@ ulong gen_get_image (ulong img_addr) * * returns: * pointer to a ramdisk image header, if image was found and valid - * otherwise, board is reset + * otherwise, return NULL */ static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], @@ -505,13 +503,13 @@ static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, if (!image_check_magic (rd_hdr)) { puts ("Bad Magic Number\n"); show_boot_progress (-10); - do_reset (cmdtp, flag, argc, argv); + return NULL; }
if (!image_check_hcrc (rd_hdr)) { puts ("Bad Header Checksum\n"); show_boot_progress (-11); - do_reset (cmdtp, flag, argc, argv); + return NULL; }
show_boot_progress (10); @@ -522,7 +520,7 @@ static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) { puts ("Bad Data CRC\n"); show_boot_progress (-12); - do_reset (cmdtp, flag, argc, argv); + return NULL; } puts("OK\n"); } @@ -535,7 +533,7 @@ static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, printf ("No Linux %s Ramdisk Image\n", image_get_arch_name(arch)); show_boot_progress (-13); - do_reset (cmdtp, flag, argc, argv); + return NULL; }
return rd_hdr; @@ -561,9 +559,9 @@ static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, * rd_start and rd_end are set to ramdisk start/end addresses if * ramdisk image is found and valid * rd_start and rd_end are set to 0 if no ramdisk exists - * board is reset if ramdisk image is found but corrupted + * return 1 if ramdisk image is found but corrupted */ -void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], +int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], bootm_headers_t *images, uint8_t arch, ulong *rd_start, ulong *rd_end) { @@ -630,6 +628,12 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv, rd_addr, arch, images->verify);
+ if (rd_hdr == NULL) { + *rd_start = 0; + *rd_end = 0; + return 1; + } + rd_data = image_get_data (rd_hdr); rd_len = image_get_data_size (rd_hdr); rd_load = image_get_load (rd_hdr); @@ -639,7 +643,7 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], fit_hdr = (void *)rd_addr; debug ("* ramdisk: FIT format image\n"); fit_unsupported_reset ("ramdisk"); - do_reset (cmdtp, flag, argc, argv); + return 1; #endif default: printf ("Wrong Image Format for %s command\n", @@ -687,6 +691,8 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], } debug (" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n", *rd_start, *rd_end); + + return 0; }
#if defined(CONFIG_PPC) || defined(CONFIG_M68K) diff --git a/include/image.h b/include/image.h index 1cec1db..025ec0f 100644 --- a/include/image.h +++ b/include/image.h @@ -382,7 +382,7 @@ void image_print_contents (image_header_t *hdr); int gen_image_get_format (void *img_addr); ulong gen_get_image (ulong img_addr);
-void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], +int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], bootm_headers_t *images, uint8_t arch, ulong *rd_start, ulong *rd_end);
diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c index 74240af..c9d2a27 100644 --- a/lib_m68k/bootm.c +++ b/lib_m68k/bootm.c @@ -35,6 +35,8 @@
DECLARE_GLOBAL_DATA_PTR;
+extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + #define PHYSADDR(x) x
#define LINUX_MAX_ENVS 256 @@ -52,6 +54,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
ulong rd_data_start, rd_data_end, rd_len; ulong initrd_start, initrd_end; + int ret;
ulong cmd_start, cmd_end; bd_t *kbd; @@ -95,9 +98,12 @@ 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, + ret = get_ramdisk (cmdtp, flag, argc, argv, images, IH_ARCH_M68K, &rd_data_start, &rd_data_end);
+ if (ret) + goto error; + rd_len = rd_data_end - rd_data_start; alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len, sp_limit, get_sp (), &initrd_start, &initrd_end); @@ -117,6 +123,11 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, */ (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); /* does not return */ + return ; + +error: + do_reset (cmdtp, flag, argc, argv); + return ; }
static ulong get_sp (void) diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index de6995e..9f48b8d 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -41,7 +41,7 @@ #include <fdt_support.h>
static void fdt_error (const char *msg); -static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], +static int 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[], @@ -95,7 +95,10 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
#if defined(CONFIG_OF_LIBFDT) /* find flattened device tree */ - get_fdt (cmdtp, flag, argc, argv, images, &of_flat_tree, &of_size); + ret = get_fdt (cmdtp, flag, argc, argv, images, &of_flat_tree, &of_size); + + if (ret) + goto error; #endif
if (!of_size) { @@ -113,18 +116,21 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], #if defined(CONFIG_FIT) } else if (images->fit_uname_os) { fit_unsupported_reset ("PPC linux bootm"); - do_reset (cmdtp, flag, argc, argv); + goto error; #endif } else { puts ("Could not find kernel entry point!\n"); - do_reset (cmdtp, flag, argc, argv); + goto error; } kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
/* find ramdisk */ - get_ramdisk (cmdtp, flag, argc, argv, images, + ret = get_ramdisk (cmdtp, flag, argc, argv, images, IH_ARCH_PPC, &rd_data_start, &rd_data_end);
+ if (ret) + goto error; + rd_len = rd_data_end - rd_data_start;
#if defined(CONFIG_OF_LIBFDT) @@ -139,18 +145,18 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], /* pass in dummy initrd info, we'll fix up later */ if (fdt_chosen(of_flat_tree, rd_data_start, rd_data_end, 0) < 0) { fdt_error ("/chosen node create failed"); - do_reset (cmdtp, flag, argc, argv); + goto error; } #ifdef CONFIG_OF_HAS_UBOOT_ENV if (fdt_env(of_flat_tree) < 0) { fdt_error ("/u-boot-env node create failed"); - do_reset (cmdtp, flag, argc, argv); + goto error; } #endif #ifdef CONFIG_OF_HAS_BD_T if (fdt_bd_t(of_flat_tree) < 0) { fdt_error ("/bd_t node create failed"); - do_reset (cmdtp, flag, argc, argv); + goto error; } #endif #ifdef CONFIG_OF_BOARD_SETUP @@ -183,7 +189,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], initrd_end - initrd_start + 1); if (ret < 0) { printf("fdt_chosen: %s\n", fdt_strerror(ret)); - do_reset (cmdtp, flag, argc, argv); + goto error; }
do_fixup_by_path_u32(of_flat_tree, "/chosen", @@ -225,6 +231,11 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], */ (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); /* does not return */ + return ; + +error: + do_reset (cmdtp, flag, argc, argv); + return ; }
static ulong get_sp (void) @@ -304,7 +315,7 @@ static image_header_t *image_get_fdt (ulong fdt_addr) return fdt_hdr; }
-static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], +static int 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; @@ -369,7 +380,7 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], fdt_addr); fdt_hdr = image_get_fdt (fdt_addr); if (!fdt_hdr) - do_reset (cmdtp, flag, argc, argv); + goto error;
/* * move image data to the load address, @@ -383,7 +394,7 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
if ((load_start < image_end) && (load_end > image_start)) { fdt_error ("fdt overwritten"); - do_reset (cmdtp, flag, argc, argv); + goto error; } memmove ((void *)image_get_load (fdt_hdr), (void *)image_get_data (fdt_hdr), @@ -406,7 +417,7 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], fit_hdr = (void *)fdt_addr; debug ("* fdt: FIT format image\n"); fit_unsupported_reset ("PPC fdt"); - do_reset (cmdtp, flag, argc, argv); + goto error; } else #endif { @@ -420,7 +431,7 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], break; default: fdt_error ("Did not find a cmdline Flattened Device Tree"); - do_reset (cmdtp, flag, argc, argv); + goto error; }
printf (" Booting using the fdt blob at 0x%x\n", fdt_blob); @@ -446,29 +457,35 @@ static void get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
if (fdt_check_header (fdt_blob) != 0) { fdt_error ("image is not a fdt"); - do_reset (cmdtp, flag, argc, argv); + goto error; }
if (be32_to_cpu (fdt_totalsize (fdt_blob)) != fdt_len) { fdt_error ("fdt size != image size"); - do_reset (cmdtp, flag, argc, argv); + goto error; } } else { fdt_error ("Did not find a Flattened Device Tree " "in a legacy multi-component image"); - do_reset (cmdtp, flag, argc, argv); + goto error; } } else { debug ("## No Flattened Device Tree\n"); *of_flat_tree = NULL; *of_size = 0; - return; + return 0; }
*of_flat_tree = fdt_blob; *of_size = be32_to_cpu (fdt_totalsize (fdt_blob)); debug (" of_flat_tree at 0x%08lx size 0x%08lx\n", *of_flat_tree, *of_size); + + return 0; + +error: + do_reset (cmdtp, flag, argc, argv); + return 1; }
static ulong fdt_relocate (ulong alloc_current, @@ -485,7 +502,7 @@ static ulong fdt_relocate (ulong alloc_current,
if (fdt_check_header (fdt_blob) != 0) { fdt_error ("image is not a fdt"); - do_reset (cmdtp, flag, argc, argv); + goto error; }
#ifndef CFG_NO_FLASH @@ -524,7 +541,7 @@ static ulong fdt_relocate (ulong alloc_current, err = fdt_open_into (fdt_blob, (void *)of_start, of_len); if (err != 0) { fdt_error ("fdt move failed"); - do_reset (cmdtp, flag, argc, argv); + goto error; } puts ("OK\n");
@@ -536,5 +553,9 @@ static ulong fdt_relocate (ulong alloc_current, }
return new_alloc_current; + +error: + do_reset (cmdtp, flag, argc, argv); + return 1; } #endif

Introduce the LMB lib used on PPC in the kernel as a clean way to manage the memory spaces used by various boot images and structures. This code will allow us to simplify the code in bootm and its support functions.
Signed-off-by: Kumar Gala galak@kernel.crashing.org --- common/cmd_bootm.c | 14 +++ include/image.h | 2 + include/lmb.h | 54 ++++++++++ lib_generic/Makefile | 1 + lib_generic/lmb.c | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 351 insertions(+), 0 deletions(-) create mode 100644 include/lmb.h create mode 100644 lib_generic/lmb.c
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index e5ed167..92c18d0 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -34,6 +34,7 @@ #include <zlib.h> #include <bzlib.h> #include <environment.h> +#include <lmb.h> #include <asm/byteorder.h>
#ifdef CFG_HUSH_PARSER @@ -118,8 +119,19 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong image_start, image_end; ulong load_start, load_end;
+ struct lmb lmb; + memset ((void *)&images, 0, sizeof (images)); images.verify = getenv_verify(); + images.lmb = &lmb; + + lmb_init(&lmb); + +#ifdef CFG_SDRAM_BASE + lmb_add(&lmb, CFG_SDRAM_BASE, gd->bd->bi_memsize); +#else + lmb_add(&lmb, 0, gd->bd->bi_memsize); +#endif
/* get kernel image header, start address and length */ os_hdr = get_kernel (cmdtp, flag, argc, argv, @@ -237,6 +249,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
show_boot_progress (8);
+ lmb_reserve(&lmb, load_start, (load_end - load_start)); + switch (os) { default: /* handled by (original) Linux case */ case IH_OS_LINUX: diff --git a/include/image.h b/include/image.h index 025ec0f..cb4acd8 100644 --- a/include/image.h +++ b/include/image.h @@ -37,6 +37,7 @@ #include <command.h>
#ifndef USE_HOSTCC +#include <lmb.h> #include <linux/string.h> #include <asm/u-boot.h>
@@ -203,6 +204,7 @@ typedef struct bootm_headers { char *fit_uname_fdt; /* FDT blob node unit name */ #endif int verify; /* getenv("verify")[0] != 'n' */ + struct lmb *lmb; /* for memory mgmt */ #endif } bootm_headers_t;
diff --git a/include/lmb.h b/include/lmb.h new file mode 100644 index 0000000..cc64cbb --- /dev/null +++ b/include/lmb.h @@ -0,0 +1,54 @@ +#ifndef _LINUX_LMB_H +#define _LINUX_LMB_H +#ifdef __KERNEL__ + +#include <asm/types.h> +/* + * Logical memory blocks. + * + * Copyright (C) 2001 Peter Bergner, IBM Corp. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#define MAX_LMB_REGIONS 8 + +struct lmb_property { + ulong base; + ulong size; +}; + +struct lmb_region { + unsigned long cnt; + ulong size; + struct lmb_property region[MAX_LMB_REGIONS+1]; +}; + +struct lmb { + struct lmb_region memory; + struct lmb_region reserved; +}; + +extern struct lmb lmb; + +extern void lmb_init(struct lmb *lmb); +extern long lmb_add(struct lmb *lmb, ulong base, ulong size); +extern long lmb_reserve(struct lmb *lmb, ulong base, ulong size); +extern ulong lmb_alloc(struct lmb *lmb, ulong size, ulong align); +extern ulong lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr); +extern ulong __lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr); +extern int lmb_is_reserved(struct lmb *lmb, ulong addr); + +extern void lmb_dump_all(struct lmb *lmb); + +static inline ulong +lmb_size_bytes(struct lmb_region *type, unsigned long region_nr) +{ + return type->region[region_nr].size; +} +#endif /* __KERNEL__ */ + +#endif /* _LINUX_LMB_H */ diff --git a/lib_generic/Makefile b/lib_generic/Makefile index 9713353..b10793b 100644 --- a/lib_generic/Makefile +++ b/lib_generic/Makefile @@ -34,6 +34,7 @@ COBJS-y += crc32.o COBJS-y += ctype.o COBJS-y += display_options.o COBJS-y += div64.o +COBJS-y += lmb.o COBJS-y += ldiv.o COBJS-y += sha1.o COBJS-y += string.o diff --git a/lib_generic/lmb.c b/lib_generic/lmb.c new file mode 100644 index 0000000..3b8c805 --- /dev/null +++ b/lib_generic/lmb.c @@ -0,0 +1,280 @@ +/* + * Procedures for maintaining information about logical memory blocks. + * + * Peter Bergner, IBM Corp. June 2001. + * Copyright (C) 2001 Peter Bergner. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include <common.h> +#include <lmb.h> + +#define LMB_ALLOC_ANYWHERE 0 + +void lmb_dump_all(struct lmb *lmb) +{ +#ifdef DEBUG + unsigned long i; + + debug("lmb_dump_all:\n"); + debug(" memory.cnt = 0x%lx\n", lmb->memory.cnt); + debug(" memory.size = 0x%08x\n", lmb->memory.size); + for (i=0; i < lmb->memory.cnt ;i++) { + debug(" memory.reg[0x%x].base = 0x%08x\n", i, + lmb->memory.region[i].base); + debug(" .size = 0x%08x\n", + lmb->memory.region[i].size); + } + + debug("\n reserved.cnt = 0x%lx\n", lmb->reserved.cnt); + debug(" reserved.size = 0x%08x\n", lmb->reserved.size); + for (i=0; i < lmb->reserved.cnt ;i++) { + debug(" reserved.reg[0x%x].base = 0x%08x\n", i, + lmb->reserved.region[i].base); + debug(" .size = 0x%08x\n", + lmb->reserved.region[i].size); + } +#endif /* DEBUG */ +} + +static unsigned long lmb_addrs_overlap(ulong base1, + ulong size1, ulong base2, ulong size2) +{ + return ((base1 < (base2+size2)) && (base2 < (base1+size1))); +} + +static long lmb_addrs_adjacent(ulong base1, ulong size1, + ulong base2, ulong size2) +{ + if (base2 == base1 + size1) + return 1; + else if (base1 == base2 + size2) + return -1; + + return 0; +} + +static long lmb_regions_adjacent(struct lmb_region *rgn, + unsigned long r1, unsigned long r2) +{ + ulong base1 = rgn->region[r1].base; + ulong size1 = rgn->region[r1].size; + ulong base2 = rgn->region[r2].base; + ulong size2 = rgn->region[r2].size; + + return lmb_addrs_adjacent(base1, size1, base2, size2); +} + +static void lmb_remove_region(struct lmb_region *rgn, unsigned long r) +{ + unsigned long i; + + for (i = r; i < rgn->cnt - 1; i++) { + rgn->region[i].base = rgn->region[i + 1].base; + rgn->region[i].size = rgn->region[i + 1].size; + } + rgn->cnt--; +} + +/* Assumption: base addr of region 1 < base addr of region 2 */ +static void lmb_coalesce_regions(struct lmb_region *rgn, + unsigned long r1, unsigned long r2) +{ + rgn->region[r1].size += rgn->region[r2].size; + lmb_remove_region(rgn, r2); +} + +void lmb_init(struct lmb *lmb) +{ + /* Create a dummy zero size LMB which will get coalesced away later. + * This simplifies the lmb_add() code below... + */ + lmb->memory.region[0].base = 0; + lmb->memory.region[0].size = 0; + lmb->memory.cnt = 1; + lmb->memory.size = 0; + + /* Ditto. */ + lmb->reserved.region[0].base = 0; + lmb->reserved.region[0].size = 0; + lmb->reserved.cnt = 1; + lmb->reserved.size = 0; +} + +/* This routine called with relocation disabled. */ +static long lmb_add_region(struct lmb_region *rgn, ulong base, ulong size) +{ + unsigned long coalesced = 0; + long adjacent, i; + + if ((rgn->cnt == 1) && (rgn->region[0].size == 0)) { + rgn->region[0].base = base; + rgn->region[0].size = size; + return 0; + } + + /* First try and coalesce this LMB with another. */ + for (i=0; i < rgn->cnt; i++) { + ulong rgnbase = rgn->region[i].base; + ulong rgnsize = rgn->region[i].size; + + if ((rgnbase == base) && (rgnsize == size)) + /* Already have this region, so we're done */ + return 0; + + adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize); + if ( adjacent > 0 ) { + rgn->region[i].base -= size; + rgn->region[i].size += size; + coalesced++; + break; + } + else if ( adjacent < 0 ) { + rgn->region[i].size += size; + coalesced++; + break; + } + } + + if ((i < rgn->cnt-1) && lmb_regions_adjacent(rgn, i, i+1) ) { + lmb_coalesce_regions(rgn, i, i+1); + coalesced++; + } + + if (coalesced) + return coalesced; + if (rgn->cnt >= MAX_LMB_REGIONS) + return -1; + + /* Couldn't coalesce the LMB, so add it to the sorted table. */ + for (i = rgn->cnt-1; i >= 0; i--) { + if (base < rgn->region[i].base) { + rgn->region[i+1].base = rgn->region[i].base; + rgn->region[i+1].size = rgn->region[i].size; + } else { + rgn->region[i+1].base = base; + rgn->region[i+1].size = size; + break; + } + } + + if (base < rgn->region[0].base) { + rgn->region[0].base = base; + rgn->region[0].size = size; + } + + rgn->cnt++; + + return 0; +} + +/* This routine may be called with relocation disabled. */ +long lmb_add(struct lmb *lmb, ulong base, ulong size) +{ + struct lmb_region *_rgn = &(lmb->memory); + + return lmb_add_region(_rgn, base, size); +} + +long lmb_reserve(struct lmb *lmb, ulong base, ulong size) +{ + struct lmb_region *_rgn = &(lmb->reserved); + + return lmb_add_region(_rgn, base, size); +} + +long lmb_overlaps_region(struct lmb_region *rgn, ulong base, + ulong size) +{ + unsigned long i; + + for (i=0; i < rgn->cnt; i++) { + ulong rgnbase = rgn->region[i].base; + ulong rgnsize = rgn->region[i].size; + if ( lmb_addrs_overlap(base,size,rgnbase,rgnsize) ) { + break; + } + } + + return (i < rgn->cnt) ? i : -1; +} + +ulong lmb_alloc(struct lmb *lmb, ulong size, ulong align) +{ + return lmb_alloc_base(lmb, size, align, LMB_ALLOC_ANYWHERE); +} + +ulong lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr) +{ + ulong alloc; + + alloc = __lmb_alloc_base(lmb, size, align, max_addr); + + if (alloc == 0) + printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", + size, max_addr); + + return alloc; +} + +static ulong lmb_align_down(ulong addr, ulong size) +{ + return addr & ~(size - 1); +} + +static ulong lmb_align_up(ulong addr, ulong size) +{ + return (addr + (size - 1)) & ~(size - 1); +} + +ulong __lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr) +{ + long i, j; + ulong base = 0; + + for (i = lmb->memory.cnt-1; i >= 0; i--) { + ulong lmbbase = lmb->memory.region[i].base; + ulong lmbsize = lmb->memory.region[i].size; + + if (max_addr == LMB_ALLOC_ANYWHERE) + base = lmb_align_down(lmbbase + lmbsize - size, align); + else if (lmbbase < max_addr) { + base = min(lmbbase + lmbsize, max_addr); + base = lmb_align_down(base - size, align); + } else + continue; + + while ((lmbbase <= base) && + ((j = lmb_overlaps_region(&(lmb->reserved), base, size)) >= 0) ) + base = lmb_align_down(lmb->reserved.region[j].base - size, + align); + + if ((base != 0) && (lmbbase <= base)) + break; + } + + if (i < 0) + return 0; + + if (lmb_add_region(&(lmb->reserved), base, lmb_align_up(size, align)) < 0) + return 0; + + return base; +} + +int lmb_is_reserved(struct lmb *lmb, ulong addr) +{ + int i; + + for (i = 0; i < lmb->reserved.cnt; i++) { + ulong upper = lmb->reserved.region[i].base + + lmb->reserved.region[i].size - 1; + if ((addr >= lmb->reserved.region[i].base) && (addr <= upper)) + return 1; + } + return 0; +}

The autostart env variable was dropped as part of the initial new uImage cleanup. Add it back here so the arch specific code can decide if it wants to really boot or not.
Signed-off-by: Kumar Gala galak@kernel.crashing.org --- common/cmd_bootm.c | 1 + common/image.c | 6 ++++++ include/image.h | 2 ++ 3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 92c18d0..92c2f4e 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -123,6 +123,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
memset ((void *)&images, 0, sizeof (images)); images.verify = getenv_verify(); + images.autostart = getenv_autostart(); images.lmb = &lmb;
lmb_init(&lmb); diff --git a/common/image.c b/common/image.c index d4acb6b..4f2ff9c 100644 --- a/common/image.c +++ b/common/image.c @@ -126,6 +126,12 @@ int getenv_verify (void) return (s && (*s == 'n')) ? 0 : 1; }
+int getenv_autostart (void) +{ + char *s = getenv ("autostart"); + return (s && (*s == 'n')) ? 0 : 1; +} + void memmove_wd (void *to, void *from, size_t len, ulong chunksz) { #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) diff --git a/include/image.h b/include/image.h index cb4acd8..5ce2ca4 100644 --- a/include/image.h +++ b/include/image.h @@ -204,6 +204,7 @@ typedef struct bootm_headers { char *fit_uname_fdt; /* FDT blob node unit name */ #endif int verify; /* getenv("verify")[0] != 'n' */ + int autostart; /* getenv("autostart")[0] != 'n' */ struct lmb *lmb; /* for memory mgmt */ #endif } bootm_headers_t; @@ -314,6 +315,7 @@ int image_check_dcrc (image_header_t *hdr); #ifndef USE_HOSTCC int image_check_dcrc_wd (image_header_t *hdr, ulong chunksize); int getenv_verify (void); +int getenv_autostart (void); void memmove_wd (void *to, void *from, size_t len, ulong chunksz); #endif

Convert generic ramdisk_high(), get_boot_cmdline(), get_boot_kbd() functions over to using lmb for allocation of the ramdisk, command line and kernel bd info.
Convert PPC specific fdt_relocate() to use lmb for allocation of the device tree.
Provided a weak function that board code can call to do additional lmb reserves if needed.
Also introduce the concept of bootmap_base to specify the offset in physical memory that the bootmap is located at. This is used for allocations of the cmdline, kernel bd, and device tree as they should be contained within bootmap_base and bootmap_base + CFG_BOOTMAPSZ.
Signed-off-by: Kumar Gala galak@kernel.crashing.org --- common/cmd_bootm.c | 8 +++ common/image.c | 134 ++++++++++++++++++--------------------------------- include/image.h | 12 ++--- lib_m68k/bootm.c | 26 +++++++--- lib_ppc/bootm.c | 65 +++++++++++++++---------- 5 files changed, 119 insertions(+), 126 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 92c2f4e..a32a5a2 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -103,6 +103,12 @@ static boot_os_fn do_bootm_artos; ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */ static bootm_headers_t images; /* pointers to os/initrd/fdt images */
+void __board_lmb_reserve(struct lmb *lmb) +{ + /* please define platform specific board_lmb_reserve() */ +} +void board_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__board_lmb_reserve"))); +
/*******************************************************************/ /* bootm - boot application image from image in memory */ @@ -134,6 +140,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) lmb_add(&lmb, 0, gd->bd->bi_memsize); #endif
+ board_lmb_reserve(&lmb); + /* get kernel image header, start address and length */ os_hdr = get_kernel (cmdtp, flag, argc, argv, &images, &os_data, &os_len); diff --git a/common/image.c b/common/image.c index 4f2ff9c..0b71811 100644 --- a/common/image.c +++ b/common/image.c @@ -704,10 +704,9 @@ int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], #if defined(CONFIG_PPC) || defined(CONFIG_M68K) /** * ramdisk_high - relocate init ramdisk + * @lmb: pointer to lmb handle, will be used for memory mgmt * @rd_data: ramdisk data start address * @rd_len: ramdisk data length - * @sp_limit: stack pointer limit (including BOOTMAPSZ) - * @sp: current stack pointer * @initrd_start: pointer to a ulong variable, will hold final init ramdisk * start address (after possible relocation) * @initrd_end: pointer to a ulong variable, will hold final init ramdisk @@ -720,16 +719,16 @@ int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], * - initrd_start and initrd_end are set to final (after relocation) ramdisk * start/end addresses if ramdisk image start and len were provided * otherwise set initrd_start and initrd_end set to zeros - * - returns new allc_current, next free address below BOOTMAPSZ + * - returns: + * 0 - success + * -1 - failure */ -ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len, - ulong sp_limit, ulong sp, - ulong *initrd_start, ulong *initrd_end) +int ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len, + ulong *initrd_start, ulong *initrd_end) { char *s; ulong initrd_high; int initrd_copy_to_ram = 1; - ulong new_alloc_current = alloc_current;
if ((s = getenv ("initrd_high")) != NULL) { /* a value of "no" or a similar string will act like 0, @@ -743,12 +742,6 @@ ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len, initrd_high = ~0; }
-#ifdef CONFIG_LOGBUFFER - /* Prevent initrd from overwriting logbuffer */ - if (initrd_high < (gd->bd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD)) - initrd_high = gd->bd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD; - debug ("## Logbuffer at 0x%08lx ", gd->bd->bi_memsize - LOGBUFF_LEN); -#endif debug ("## initrd_high = 0x%08lx, copy_to_ram = %d\n", initrd_high, initrd_copy_to_ram);
@@ -757,40 +750,17 @@ ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len, debug (" in-place initrd\n"); *initrd_start = rd_data; *initrd_end = rd_data + rd_len; + lmb_reserve(lmb, rd_data, rd_len); } else { - new_alloc_current = alloc_current - rd_len; - *initrd_start = new_alloc_current; - *initrd_start &= ~(4096 - 1); /* align on page */ - - if (initrd_high) { - ulong nsp; - - /* - * the inital ramdisk does not need to be within - * CFG_BOOTMAPSZ as it is not accessed until after - * the mm system is initialised. - * - * do the stack bottom calculation again and see if - * the initrd will fit just below the monitor stack - * bottom without overwriting the area allocated - * for command line args and board info. - */ - nsp = sp; - nsp -= 2048; /* just to be sure */ - nsp &= ~0xF; - - if (nsp > initrd_high) /* limit as specified */ - nsp = initrd_high; - - nsp -= rd_len; - nsp &= ~(4096 - 1); /* align on page */ - - if (nsp >= sp_limit) { - *initrd_start = nsp; - new_alloc_current = alloc_current; - } + if (initrd_high) + *initrd_start = lmb_alloc_base(lmb, rd_len, 0x1000, initrd_high); + else + *initrd_start = lmb_alloc(lmb, rd_len, 0x1000); + + if (*initrd_start == 0) { + puts("ramdisk - allocation error\n"); + goto error; } - show_boot_progress (12);
*initrd_end = *initrd_start + rd_len; @@ -808,56 +778,40 @@ ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len, } debug (" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n", *initrd_start, *initrd_end); + return 0;
- return new_alloc_current; -} - -/** - * get_boot_sp_limit - calculate stack pointer limit - * @sp: current stack pointer - * - * get_boot_sp_limit() takes current stack pointer adrress and calculates - * stack pointer limit, below which kernel boot data (cmdline, board info, - * etc.) will be allocated. - * - * returns: - * stack pointer limit - */ -ulong get_boot_sp_limit(ulong sp) -{ - ulong sp_limit = sp; - - sp_limit -= 2048; /* just to be sure */ - - /* make sure sp_limit is within kernel mapped space */ - if (sp_limit > CFG_BOOTMAPSZ) - sp_limit = CFG_BOOTMAPSZ; - sp_limit &= ~0xF; - - return sp_limit; +error: + return -1; }
/** * get_boot_cmdline - allocate and initialize kernel cmdline - * @alloc_current: current boot allocation address (counting down - * from sp_limit) + * @lmb: pointer to lmb handle, will be used for memory mgmt * @cmd_start: pointer to a ulong variable, will hold cmdline start * @cmd_end: pointer to a ulong variable, will hold cmdline end + * @bootmap_base: ulong variable, holds offset in physical memory to + * base of bootmap * * get_boot_cmdline() allocates space for kernel command line below - * provided alloc_current address. If "bootargs" U-boot environemnt + * BOOTMAPSZ + bootmap_base address. If "bootargs" U-boot environemnt * variable is present its contents is copied to allocated kernel * command line. * * returns: - * alloc_current after cmdline allocation + * 0 - success + * -1 - failure */ -ulong get_boot_cmdline (ulong alloc_current, ulong *cmd_start, ulong *cmd_end) +int get_boot_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end, + ulong bootmap_base) { char *cmdline; char *s;
- cmdline = (char *)((alloc_current - CFG_BARGSIZE) & ~0xF); + cmdline = (char *)lmb_alloc_base(lmb, CFG_BARGSIZE, 0xf, + CFG_BOOTMAPSZ + bootmap_base); + + if (cmdline == NULL) + return -1;
if ((s = getenv("bootargs")) == NULL) s = ""; @@ -869,25 +823,31 @@ ulong get_boot_cmdline (ulong alloc_current, ulong *cmd_start, ulong *cmd_end)
debug ("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end);
- return (ulong)cmdline; + return 0; }
/** * get_boot_kbd - allocate and initialize kernel copy of board info - * @alloc_current: current boot allocation address (counting down - * from sp_limit) + * @lmb: pointer to lmb handle, will be used for memory mgmt * @kbd: double pointer to board info data + * @bootmap_base: ulong variable, holds offset in physical memory to + * base of bootmap * - * get_boot_kbd() - allocates space for kernel copy of board info data. - * Space is allocated below provided alloc_current address and kernel - * board info is initialized with the current u-boot board info data. + * get_boot_kbd() allocates space for kernel copy of board info data below + * BOOTMAPSZ + bootmap_base address and kernel board info is initialized with + * the current u-boot board info data. * * returns: - * alloc_current after kbd allocation + * 0 - success + * -1 - failure */ -ulong get_boot_kbd (ulong alloc_current, bd_t **kbd) +int get_boot_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base) { - *kbd = (bd_t *) (((ulong)alloc_current - sizeof(bd_t)) & ~0xF); + *kbd = (bd_t *)lmb_alloc_base(lmb, sizeof(bd_t), 0xf, + CFG_BOOTMAPSZ + bootmap_base); + if (*kbd == NULL) + return -1; + **kbd = *(gd->bd);
debug ("## kernel board info at 0x%08lx\n", (ulong)*kbd); @@ -896,7 +856,7 @@ ulong get_boot_kbd (ulong alloc_current, bd_t **kbd) do_bdinfo(NULL, 0, 0, NULL); #endif
- return (ulong)*kbd; + return 0; } #endif /* CONFIG_PPC || CONFIG_M68K */
diff --git a/include/image.h b/include/image.h index 5ce2ca4..97eb520 100644 --- a/include/image.h +++ b/include/image.h @@ -391,13 +391,11 @@ int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], ulong *rd_start, ulong *rd_end);
#if defined(CONFIG_PPC) || defined(CONFIG_M68K) -ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len, - ulong sp_limit, ulong sp, - ulong *initrd_start, ulong *initrd_end); - -ulong get_boot_sp_limit (ulong sp); -ulong get_boot_cmdline (ulong alloc_current, ulong *cmd_start, ulong *cmd_end); -ulong get_boot_kbd (ulong alloc_current, bd_t **kbd); +int ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len, + ulong *initrd_start, ulong *initrd_end); +int get_boot_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end, + ulong bootmap_base); +int get_boot_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base); #endif /* CONFIG_PPC || CONFIG_M68K */
/*******************************************************************/ diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c index c9d2a27..8429ca0 100644 --- a/lib_m68k/bootm.c +++ b/lib_m68k/bootm.c @@ -50,16 +50,18 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], bootm_headers_t *images) { - ulong sp, sp_limit, alloc_current; + ulong sp;
ulong rd_data_start, rd_data_end, rd_len; ulong initrd_start, initrd_end; int ret;
ulong cmd_start, cmd_end; + ulong bootmap_base = 0; bd_t *kbd; ulong ep = 0; void (*kernel) (bd_t *, ulong, ulong, ulong, ulong); + struct lmb *lmb = images->lmb;
/* * Booting a (Linux) kernel image @@ -73,14 +75,23 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, sp = get_sp(); debug ("## Current stack ends at 0x%08lx ", sp);
- alloc_current = sp_limit = get_boot_sp_limit(sp); - debug ("=> set upper limit to 0x%08lx\n", sp_limit); + /* adjust sp by 1K to be safe */ + sp -= 1024; + lmb_reserve(lmb, sp, (CFG_SDRAM_BASE + gd->ram_size - sp));
/* allocate space and init command line */ - alloc_current = get_boot_cmdline (alloc_current, &cmd_start, &cmd_end); + ret = get_boot_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base); + if (ret) { + puts("ERROR with allocation of cmdline\n"); + goto error; + }
/* allocate space for kernel copy of board info */ - alloc_current = get_boot_kbd (alloc_current, &kbd); + ret = get_boot_kbd (lmb, &kbd, bootmap_base); + if (ret) { + puts("ERROR with allocation of kernel bd\n"); + goto error; + } set_clocks_in_mhz(kbd);
/* find kernel entry point */ @@ -105,8 +116,9 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, goto error;
rd_len = rd_data_end - rd_data_start; - alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len, - sp_limit, get_sp (), &initrd_start, &initrd_end); + ret = ramdisk_high (lmb, rd_data_start, rd_len, &initrd_start, &initrd_end); + if (ret) + goto error;
debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) kernel); diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index 9f48b8d..d74a3f4 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -43,7 +43,7 @@ static void fdt_error (const char *msg); static int 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, +static int fdt_relocate (struct lmb *lmb, ulong bootmap_base, cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], char **of_flat_tree, ulong *of_size); #endif @@ -55,6 +55,7 @@ static ulong fdt_relocate (ulong alloc_current, DECLARE_GLOBAL_DATA_PTR;
extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); +extern ulong get_effective_memsize(void); static ulong get_sp (void); static void set_clocks_in_mhz (bd_t *kbd);
@@ -62,22 +63,25 @@ void __attribute__((noinline)) do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], bootm_headers_t *images) { - ulong sp, sp_limit, alloc_current; + ulong sp;
ulong initrd_start, initrd_end; ulong rd_data_start, rd_data_end, rd_len;
- ulong cmd_start, cmd_end; + ulong cmd_start, cmd_end, bootmap_base; bd_t *kbd; ulong ep = 0; void (*kernel)(bd_t *, ulong, ulong, ulong, ulong); int ret; ulong of_size = 0; + struct lmb *lmb = images->lmb;
#if defined(CONFIG_OF_LIBFDT) char *of_flat_tree = NULL; #endif
+ bootmap_base = 0; + /* * Booting a (Linux) kernel image * @@ -90,8 +94,9 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], sp = get_sp(); debug ("## Current stack ends at 0x%08lx ", sp);
- alloc_current = sp_limit = get_boot_sp_limit(sp); - debug ("=> set upper limit to 0x%08lx\n", sp_limit); + /* adjust sp by 1K to be safe */ + sp -= 1024; + lmb_reserve(lmb, sp, (CFG_SDRAM_BASE + get_effective_memsize() - sp));
#if defined(CONFIG_OF_LIBFDT) /* find flattened device tree */ @@ -103,10 +108,18 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
if (!of_size) { /* allocate space and init command line */ - alloc_current = get_boot_cmdline (alloc_current, &cmd_start, &cmd_end); + ret = get_boot_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base); + if (ret) { + puts("ERROR with allocation of cmdline\n"); + goto error; + }
/* allocate space for kernel copy of board info */ - alloc_current = get_boot_kbd (alloc_current, &kbd); + ret = get_boot_kbd (lmb, &kbd, bootmap_base); + if (ret) { + puts("ERROR with allocation of kernel bd\n"); + goto error; + } set_clocks_in_mhz(kbd); }
@@ -134,8 +147,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], rd_len = rd_data_end - rd_data_start;
#if defined(CONFIG_OF_LIBFDT) - alloc_current = fdt_relocate (alloc_current, - cmdtp, flag, argc, argv, &of_flat_tree, &of_size); + ret = fdt_relocate (lmb, bootmap_base, + cmdtp, flag, argc, argv, &of_flat_tree, &of_size);
/* * Add the chosen node if it doesn't exist, add the env and bd_t @@ -166,8 +179,9 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], } #endif /* CONFIG_OF_LIBFDT */
- alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len, - sp_limit, get_sp (), &initrd_start, &initrd_end); + ret = ramdisk_high (lmb, rd_data_start, rd_len, &initrd_start, &initrd_end); + if (ret) + goto error;
#if defined(CONFIG_OF_LIBFDT) /* fixup the initrd now that we know where it should be */ @@ -488,17 +502,17 @@ error: return 1; }
-static ulong fdt_relocate (ulong alloc_current, +static int fdt_relocate (struct lmb *lmb, ulong bootmap_base, 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; + ulong of_len = 0;
/* nothing to do */ if (*of_size == 0) - return alloc_current; + return 0;
if (fdt_check_header (fdt_blob) != 0) { fdt_error ("image is not a fdt"); @@ -511,25 +525,28 @@ static ulong fdt_relocate (ulong alloc_current, relocate = 1; #endif
-#ifdef CFG_BOOTMAPSZ /* * The blob must be within CFG_BOOTMAPSZ, * so we flag it to be copied if it is not. */ if (fdt_blob >= (char *)CFG_BOOTMAPSZ) relocate = 1; -#endif + + of_len = be32_to_cpu (fdt_totalsize (fdt));
/* move flattend device tree if needed */ if (relocate) { int err; - ulong of_start, of_len; - - of_len = *of_size; + ulong of_start;
/* position on a 4K boundary before the alloc_current */ - of_start = alloc_current - of_len; - of_start &= ~(4096 - 1); /* align on page */ + of_start = lmb_alloc_base(lmb, of_len, 0x1000, + (CFG_BOOTMAPSZ + bootmap_base)); + + if (of_start == 0) { + puts("device tree - allocation error\n"); + goto error; + }
debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", (ulong)fdt_blob, (ulong)fdt_blob + of_len - 1, @@ -546,16 +563,14 @@ static ulong fdt_relocate (ulong alloc_current, puts ("OK\n");
*of_flat_tree = (char *)of_start; - new_alloc_current = of_start; } else { *of_flat_tree = fdt_blob; - new_alloc_current = alloc_current; + lmb_reserve(lmb, (ulong)fdt, of_len); }
- return new_alloc_current; + return 0;
error: - do_reset (cmdtp, flag, argc, argv); return 1; } #endif

Allow the user to set 'bootm_low' and 'bootm_size' env vars as a way to restrict what memory range is used for bootm.
Signed-off-by: Kumar Gala galak@kernel.crashing.org --- common/cmd_bootm.c | 10 +++++----- common/image.c | 26 ++++++++++++++++++++++++++ include/image.h | 2 ++ lib_m68k/bootm.c | 4 +++- lib_ppc/bootm.c | 26 ++++++++++++++++++++++++-- 5 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index a32a5a2..8595ef6 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -124,6 +124,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong os_data, os_len; ulong image_start, image_end; ulong load_start, load_end; + ulong mem_start, mem_size;
struct lmb lmb;
@@ -134,11 +135,10 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
lmb_init(&lmb);
-#ifdef CFG_SDRAM_BASE - lmb_add(&lmb, CFG_SDRAM_BASE, gd->bd->bi_memsize); -#else - lmb_add(&lmb, 0, gd->bd->bi_memsize); -#endif + mem_start = getenv_bootm_low(); + mem_size = getenv_bootm_size(); + + lmb_add(&lmb, mem_start, mem_size);
board_lmb_reserve(&lmb);
diff --git a/common/image.c b/common/image.c index 0b71811..9e446fa 100644 --- a/common/image.c +++ b/common/image.c @@ -132,6 +132,32 @@ int getenv_autostart (void) return (s && (*s == 'n')) ? 0 : 1; }
+ulong getenv_bootm_low(void) +{ + char *s = getenv ("bootm_low"); + if (s) { + ulong tmp = simple_strtoul (s, NULL, 16); + return tmp; + } + +#ifdef CFG_SDRAM_BASE + return CFG_SDRAM_BASE; +#else + return 0; +#endif +} + +ulong getenv_bootm_size(void) +{ + char *s = getenv ("bootm_size"); + if (s) { + ulong tmp = simple_strtoul (s, NULL, 16); + return tmp; + } + + return gd->bd->bi_memsize; +} + void memmove_wd (void *to, void *from, size_t len, ulong chunksz) { #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) diff --git a/include/image.h b/include/image.h index 97eb520..ee692ac 100644 --- a/include/image.h +++ b/include/image.h @@ -316,6 +316,8 @@ int image_check_dcrc (image_header_t *hdr); int image_check_dcrc_wd (image_header_t *hdr, ulong chunksize); int getenv_verify (void); int getenv_autostart (void); +ulong getenv_bootm_low(void); +ulong getenv_bootm_size(void); void memmove_wd (void *to, void *from, size_t len, ulong chunksz); #endif
diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c index 8429ca0..eca044e 100644 --- a/lib_m68k/bootm.c +++ b/lib_m68k/bootm.c @@ -57,12 +57,14 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int ret;
ulong cmd_start, cmd_end; - ulong bootmap_base = 0; + ulong bootmap_base; bd_t *kbd; ulong ep = 0; void (*kernel) (bd_t *, ulong, ulong, ulong, ulong); struct lmb *lmb = images->lmb;
+ bootmap_base = getenv_bootm_low(); + /* * Booting a (Linux) kernel image * diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index d74a3f4..59cc2a4 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -59,6 +59,10 @@ extern ulong get_effective_memsize(void); static ulong get_sp (void); static void set_clocks_in_mhz (bd_t *kbd);
+#ifndef CFG_LINUX_LOWMEM_MAX_SIZE +#define CFG_LINUX_LOWMEM_MAX_SIZE (768*1024*1024) +#endif + void __attribute__((noinline)) do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], bootm_headers_t *images) @@ -67,6 +71,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ulong initrd_start, initrd_end; ulong rd_data_start, rd_data_end, rd_len; + ulong size;
ulong cmd_start, cmd_end, bootmap_base; bd_t *kbd; @@ -80,7 +85,24 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], char *of_flat_tree = NULL; #endif
- bootmap_base = 0; + bootmap_base = getenv_bootm_low(); + size = getenv_bootm_size(); + +#ifdef DEBUG + if (((u64)bootmap_base + size) > (CFG_SDRAM_BASE + (u64)gd->ram_size)) + puts("WARNING: bootm_low + bootm_size exceed total memory\n"); + if ((bootmap_base + size) > get_effective_memsize()) + puts("WARNING: bootm_low + bootm_size exceed eff. memory\n"); +#endif + + size = min(size, get_effective_memsize()); + size = min(size, CFG_LINUX_LOWMEM_MAX_SIZE); + + if (size < getenv_bootm_size()) { + ulong base = bootmap_base + size; + printf("WARNING: adjusting available memory to %x\n", size); + lmb_reserve(lmb, base, getenv_bootm_size() - size); + }
/* * Booting a (Linux) kernel image @@ -92,7 +114,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], * pointer. */ sp = get_sp(); - debug ("## Current stack ends at 0x%08lx ", sp); + debug ("## Current stack ends at 0x%08lx\n", sp);
/* adjust sp by 1K to be safe */ sp -= 1024;

Signed-off-by: Kumar Gala galak@kernel.crashing.org --- lib_arm/bootm.c | 3 +++ lib_avr32/bootm.c | 3 +++ lib_blackfin/bootm.c | 3 +++ lib_i386/bootm.c | 3 +++ lib_m68k/bootm.c | 5 ++++- lib_microblaze/bootm.c | 3 +++ lib_mips/bootm.c | 3 +++ lib_nios2/bootm.c | 3 +++ lib_ppc/bootm.c | 5 ++++- lib_sh/bootm.c | 3 +++ 10 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c index e1a9ee2..77d35fc 100644 --- a/lib_arm/bootm.c +++ b/lib_arm/bootm.c @@ -133,6 +133,9 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], setup_end_tag (bd); #endif
+ if (!images->autostart) + return ; + /* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n");
diff --git a/lib_avr32/bootm.c b/lib_avr32/bootm.c index 69a69df..918e4cf 100644 --- a/lib_avr32/bootm.c +++ b/lib_avr32/bootm.c @@ -214,6 +214,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], params = setup_ethernet_tags(params); setup_end_tag(params);
+ if (!images->autostart) + return ; + printf("\nStarting kernel at %p (params at %p)...\n\n", theKernel, params_start);
diff --git a/lib_blackfin/bootm.c b/lib_blackfin/bootm.c index 26ac88b..33979a9 100644 --- a/lib_blackfin/bootm.c +++ b/lib_blackfin/bootm.c @@ -53,6 +53,9 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], char *cmdline; ulong ep = 0;
+ if (!images->autostart) + return ; + #ifdef SHARED_RESOURCES swap_to(FLASH); #endif diff --git a/lib_i386/bootm.c b/lib_i386/bootm.c index aea58d1..89a423c 100644 --- a/lib_i386/bootm.c +++ b/lib_i386/bootm.c @@ -72,6 +72,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
}
+ if (!images->autostart) + return ; + #ifdef DEBUG printf ("## Transferring control to Linux (at address %08x) ...\n", (u32)base_ptr); diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c index eca044e..e12d1d4 100644 --- a/lib_m68k/bootm.c +++ b/lib_m68k/bootm.c @@ -127,6 +127,8 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
show_boot_progress (15);
+ if (!images->autostart) + return; /* * Linux Kernel Parameters (passing board info data): * r3: ptr to board info data @@ -140,7 +142,8 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, return ;
error: - do_reset (cmdtp, flag, argc, argv); + if (images->autostart) + do_reset (cmdtp, flag, argc, argv); return ; }
diff --git a/lib_microblaze/bootm.c b/lib_microblaze/bootm.c index 5881df6..99c4533 100644 --- a/lib_microblaze/bootm.c +++ b/lib_microblaze/bootm.c @@ -63,5 +63,8 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], (ulong) theKernel); #endif
+ if (!images->autostart) + return ; + theKernel (commandline); } diff --git a/lib_mips/bootm.c b/lib_mips/bootm.c index 998aa22..39869c1 100644 --- a/lib_mips/bootm.c +++ b/lib_mips/bootm.c @@ -106,6 +106,9 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], sprintf (env_buf, "0x%X", (uint) (gd->bd->bi_flashsize)); linux_env_set ("flash_size", env_buf);
+ if (!images->autostart) + return ; + /* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n");
diff --git a/lib_nios2/bootm.c b/lib_nios2/bootm.c index 70d2bb0..4b940cb 100644 --- a/lib_nios2/bootm.c +++ b/lib_nios2/bootm.c @@ -46,6 +46,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], } void (*kernel)(void) = (void (*)(void))ep;
+ if (!images->autostart) + return ; + /* For now we assume the Microtronix linux ... which only * needs to be called ;-) */ diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index 59cc2a4..1afef46 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -242,6 +242,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], #if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) unlock_ram_in_cache(); #endif + if (!images->autostart) + return ;
#if defined(CONFIG_OF_LIBFDT) if (of_flat_tree) { /* device tree; boot new style */ @@ -270,7 +272,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], return ;
error: - do_reset (cmdtp, flag, argc, argv); + if (images->autostart) + do_reset (cmdtp, flag, argc, argv); return ; }
diff --git a/lib_sh/bootm.c b/lib_sh/bootm.c index de5c9ea..8055841 100644 --- a/lib_sh/bootm.c +++ b/lib_sh/bootm.c @@ -79,6 +79,9 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], } void (*kernel) (void) = (void (*)(void))ep;
+ if (!images->autostart) + return ; + /* Setup parameters */ memset(PARAM, 0, 0x1000); /* Clear zero page */ strcpy(COMMAND_LINE, bootargs);

Kumar Gala wrote:
Signed-off-by: Kumar Gala galak@kernel.crashing.org
Acked-by: Marian Balakowicz m8@semihalf.com
m.

Kumar Gala wrote:
Allow the user to set 'bootm_low' and 'bootm_size' env vars as a way to restrict what memory range is used for bootm.
Signed-off-by: Kumar Gala galak@kernel.crashing.org
Acked-by: Marian Balakowicz m8@semihalf.com
With the following note:
+ulong getenv_bootm_size(void) +{
- char *s = getenv ("bootm_size");
- if (s) {
ulong tmp = simple_strtoul (s, NULL, 16);
return tmp;
- }
- return gd->bd->bi_memsize;
+}
bi_memsize use breaks ARM build. I have noticed that after I have already pulled in you changes, merges with -rc2 and rebased my other commits, so it would be good if you could have that fixed in a separate patch.
m.

Kumar Gala wrote:
The autostart env variable was dropped as part of the initial new uImage cleanup. Add it back here so the arch specific code can decide if it wants to really boot or not.
Signed-off-by: Kumar Gala galak@kernel.crashing.org
Acked-by: Marian Balakowicz m8@semihalf.com
m.

Kumar Gala wrote:
Changed image_get_ramdisk() to just return NULL on error and have get_ramdisk() propogate that error to the caller. It's left to the caller to call do_reset() if it wants to.
Also moved calling do_reset() in get_fdt() and fdt_relocate() on ppc to a common location. In the future we will change get_fdt() and fdt_relocate() to return success/failure and not call do_reset() at all.
Signed-off-by: Kumar Gala galak@kernel.crashing.org
Acked-by: Marian Balakowicz m8@semihalf.com
m.

Kumar Gala wrote:
If we are bootin OF style than we can skip setting up some things that are used for the old boot method.
Signed-off-by: Kumar Gala galak@kernel.crashing.org
Acked-by: Marian Balakowicz m8@semihalf.com
m.

Kumar Gala wrote:
We don't actually need the kdb param as we are just using it to get bd->bi_memsize which we can get from gd->bd->bi_memsize. Also, if we boot via OF we might not actually fill out a kdb.
Signed-off-by: Kumar Gala galak@kernel.crashing.org
Acked-by: Marian Balakowicz m8@semihalf.com
m.

Kumar,
Kumar Gala wrote:
This is an updated set of patches against the latest u-boot-testing#new-image.p5
Please apply.
I have pulled in your re-based patchset on top of new-image.p5 and merged with v1.3.2-rc2. I have also pulled in one of the patches from your initial patchest that did not make it to the re-based set:
[PATCH 5/9] [new uImage] ppc: Allow boards to specify effective amount of memory
All those changes are available from u-boot-testing#new-image branch, please use it as a current new-image base.
Cheers, m.
participants (2)
-
Kumar Gala
-
Marian Balakowicz