Add support for booting images at non-zero addresses
cover 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
PATCH 1/9 Don't pass kdb to ramdisk_high since we may not have one
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.
--- 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(-)
common/image.c +4 -5
@@ -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);
include/image.h +1 -1
@@ -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);
lib_m68k/bootm.c +1 -2
@@ -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);
lib_ppc/bootm.c +1 -2
@@ -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 */
Signature · 1 line
1.5.4.1
PATCH 2/9 ppc: Determine if we are booting an OF style
If we are bootin OF style than we can skip setting up some things that are used for the old boot method.
--- lib_ppc/bootm.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
lib_ppc/bootm.c +13 -9
@@ -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);
Signature · 1 line
1.5.4.1
PATCH 3/9 ppc: Re-order ramdisk/fdt handling sequence
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.
--- lib_ppc/bootm.c | 39 +++++++++++++++++++++++++++++++++++---- 1 files changed, 35 insertions(+), 4 deletions(-)
lib_ppc/bootm.c +35 -4
@@ -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);
Signature · 1 line
1.5.4.1
PATCH 4/9 rework error handling so common functions don't reset
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.
--- 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(-)
common/image.c +16 -10
@@ -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 )
include/image.h +1 -1
@@ -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);
lib_m68k/bootm.c +12 -1
@@ -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 )
lib_ppc/bootm.c +41 -20
187 lines not on this page · raw message
Signature · 1 line
1.5.4.1
PATCH 5/9 Introduce lmb from linux kernel for memory mgmt of boot images
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.
--- 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
common/cmd_bootm.c +14 -0
@@ -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 :
include/image.h +2 -0
@@ -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;
include/lmb.h new file +54 -0
54 lines not on this page · raw message
lib_generic/Makefile +1 -0
@@ -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
lib_generic/lmb.c new file +280 -0
280 lines not on this page · raw message
Signature · 1 line
1.5.4.1
PATCH 6/9 Add autostart flag to bootm_headers structure
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.
--- common/cmd_bootm.c | 1 + common/image.c | 6 ++++++ include/image.h | 2 ++ 3 files changed, 9 insertions(+), 0 deletions(-)
common/cmd_bootm.c +1 -0
@@ -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);
common/image.c +6 -0
@@ -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 )
include/image.h +2 -0
@@ -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
Signature · 1 line
1.5.4.1
PATCH 7/9 Use lmb for bootm allocations
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.
--- 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(-)
common/cmd_bootm.c +8 -0
@@ -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);
common/image.c +47 -87
213 lines not on this page · raw message
include/image.h +5 -7
@@ -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 */ /*******************************************************************/
lib_m68k/bootm.c +19 -7
@@ -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);
lib_ppc/bootm.c +40 -25
167 lines not on this page · raw message
Signature · 1 line
1.5.4.1
PATCH 8/9 Provide ability to restrict region used for boot images
Allow the user to set 'bootm_low' and 'bootm_size' env vars as a way to restrict what memory range is used for bootm.
--- 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(-)
common/cmd_bootm.c +5 -5
@@ -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);
common/image.c +26 -0
@@ -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 )
include/image.h +2 -0
@@ -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
lib_m68k/bootm.c +3 -1
@@ -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 *
lib_ppc/bootm.c +24 -2
@@ -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@0x%08lx\n" , sp);/* adjust sp by 1K to be safe */ sp -=1024 ;
Signature · 1 line
1.5.4.1
PATCH 9/9 Respect autostart setting in linux bootm
--- 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(-)
lib_arm/bootm.c +3 -0
@@ -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" );
lib_avr32/bootm.c +3 -0
@@ -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);
lib_blackfin/bootm.c +3 -0
@@ -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
lib_i386/bootm.c +3 -0
@@ -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);
lib_m68k/bootm.c +4 -1
@@ -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 ; }
lib_microblaze/bootm.c +3 -0
@@ -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); }
lib_mips/bootm.c +3 -0
@@ -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" );
lib_nios2/bootm.c +3 -0
@@ -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 ;-) */
lib_ppc/bootm.c +4 -1
@@ -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 ; }
lib_sh/bootm.c +3 -0
@@ -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);
Signature · 1 line
1.5.4.1
PATCH 9/9 Respect autostart setting in linux bootm
Quoted 1 line · Kumar Gala
Signed-off-by Kumar Gala <[email protected]>
m.
PATCH 8/9 Provide ability to restrict region used for boot images
In reply to Kumar GalaQuoted 4 lines · Kumar Gala
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 <[email protected]>
With the following note:
common/image.c int getenv_autostart (void) · line 159
Quoted 10 lines
common/image.c +10
-0+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.
PATCH 6/9 Add autostart flag to bootm_headers structure
In reply to Kumar GalaQuoted 5 lines · Kumar Gala
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 <[email protected]>
m.
PATCH 4/9 rework error handling so common functions don't reset
In reply to Kumar GalaQuoted 9 lines · Kumar Gala
Changed
image_get_ramdisk()to just return NULL on error and haveget_ramdisk()propogate that error to the caller. It's left to the caller to calldo_reset()if it wants to.Also moved calling
do_reset()inget_fdt()andfdt_relocate()on ppc to a common location. In the future we will changeget_fdt()andfdt_relocate()to return success/failure and not calldo_reset()at all.Signed-off-by Kumar Gala <[email protected]>
m.
PATCH 2/9 ppc: Determine if we are booting an OF style
In reply to Kumar GalaQuoted 4 lines · Kumar Gala
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 <[email protected]>
m.
PATCH 1/9 Don't pass kdb to ramdisk_high since we may not have one
In reply to Kumar GalaQuoted 5 lines · Kumar Gala
We don't actually need the kdb param as we are just using it to get
bd->bi_memsizewhich we can get fromgd->bd->bi_memsize. Also, if we boot via OF we might not actually fill out a kdb.Signed-off-by Kumar Gala <[email protected]>
m.
cover Add support for booting images at non-zero addresses
In reply to Kumar GalaKumar,
Quoted 3 lines · Kumar Gala
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.