MIPS: bootm updates
cover MIPS: bootm updates
- refactoring and optimization of bootm command
- add support for logical memory blocks (LMB)
- make external init ramdisks working again with recent kernels
- add support for bootm subcommand 'cmdline'
- prepare bootm for upcoming device tree support
- add bootm support for newly added MIPS Malta Qemu
- drop obsolete bootm support of MIPS Qemu
Daniel Schwierzeck (11):
MIPS: bootm: fix checkpatch.pl warnings
MIPS: bootm: optimise kernel entry call
MIPS: bootm: add support for LMB
MIPS: bootm: refactor initialisation of kernel cmdline
MIPS: bootm: refactor initialisation of kernel environment
MIPS: bootm: make initialisation of Linux environment optional
MIPS: bootm: add support for generic relocation of init ramdisks
MIPS: bootm: automatically initialise kernel cmdline variable 'mem'
MIPS: bootm: automatically initialise kernel cmdline variables
'rd_start' and 'rd_size'
MIPS: bootm: add YAMON style Linux preparation/jump code for Qemu
Malta
MIPS: bootm: drop obsolete Qemu specific bootm implementation
README | 6 + arch/mips/include/asm/config.h | 3 + arch/mips/lib/Makefile | 4 - arch/mips/lib/bootm.c | 274 +++++++++++++++++++++++++++------------- arch/mips/lib/bootm_qemu_mips.c | 78 ------------ 5 files changed, 198 insertions(+), 167 deletions(-) delete mode 100644 arch/mips/lib/bootm_qemu_mips.c
Signature · 1 line
1.8.1.2
PATCH 1/11 MIPS: bootm: fix checkpatch.pl warnings
--- arch/mips/lib/bootm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/mips/lib/bootm.c +5 -5
@@ -57,7 +57,7 @@ static void boot_prep_linux(bootm_headers_t *images)#else sprintf (env_buf,"%lu" , (ulong)(gd->ram_size >>20 ));debug ("## Giving linux memsize in MB, %lu\n" , - (ulong)(gd->ram_size >>20 )); + (ulong)(gd->ram_size >>20 ));#endif /* CONFIG_MEMSIZE_IN_BYTES */ linux_env_set ("memsize" , env_buf);
@@ -130,9 +130,9 @@ static void linux_params_init(ulong start, char *line)char *next, *quote, *argp; linux_argc =1 ; - linux_argv = (char **) start; + linux_argv = (char **)start; linux_argv[0 ] =0 ; - argp = (char *) (linux_argv +LINUX_MAX_ARGS ); + argp = (char *)(linux_argv +LINUX_MAX_ARGS ); next = line;
@@ -167,9 +167,9 @@ static void linux_params_init(ulong start, char *line) line = next; } - linux_env = (char **) (((ulong ) argp +15 ) & ~15 ); + linux_env = (char **)(((ulong ) argp +15 ) & ~15 ); linux_env[0 ] =0 ; - linux_env_p = (char *) (linux_env +LINUX_MAX_ENVS ); + linux_env_p = (char *)(linux_env +LINUX_MAX_ENVS ); linux_env_idx =0 ; }
Signature · 1 line
1.8.1.2
PATCH v2 1/11 MIPS: bootm: fix checkpatch.pl warnings
---
Changes in v2:
- fix multi-line comment
arch/mips/lib/bootm.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/mips/lib/bootm.c +7 -6
@@ -57,7 +57,7 @@ static void boot_prep_linux(bootm_headers_t *images)#else sprintf (env_buf,"%lu" , (ulong)(gd->ram_size >>20 ));debug ("## Giving linux memsize in MB, %lu\n" , - (ulong)(gd->ram_size >>20 )); + (ulong)(gd->ram_size >>20 ));#endif /* CONFIG_MEMSIZE_IN_BYTES */ linux_env_set ("memsize" , env_buf);
@@ -130,9 +130,9 @@ static void linux_params_init(ulong start, char *line)char *next, *quote, *argp; linux_argc =1 ; - linux_argv = (char **) start; + linux_argv = (char **)start; linux_argv[0 ] =0 ; - argp = (char *) (linux_argv +LINUX_MAX_ARGS ); + argp = (char *)(linux_argv +LINUX_MAX_ARGS ); next = line;
@@ -141,7 +141,8 @@ static void linux_params_init(ulong start, char *line) next =strchr (line,' ' );while (next && quote && quote < next) { -/* we found a left quote before the next blank +/* +* we found a left quote before the next blank * now we have to find the matching right quote */ next =strchr (quote +1 ,'"' );
@@ -167,9 +168,9 @@ static void linux_params_init(ulong start, char *line) line = next; } - linux_env = (char **) (((ulong ) argp +15 ) & ~15 ); + linux_env = (char **)(((ulong ) argp +15 ) & ~15 ); linux_env[0 ] =0 ; - linux_env_p = (char *) (linux_env +LINUX_MAX_ENVS ); + linux_env_p = (char *)(linux_env +LINUX_MAX_ENVS ); linux_env_idx =0 ; }
Signature · 1 line
1.8.1.2
PATCH 2/11 MIPS: bootm: optimise kernel entry call
In reply to Daniel SchwierzeckFix signature of kernel entry function. Mark the kernel entry with __noreturn for better code optimisation.
--- arch/mips/lib/bootm.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
arch/mips/lib/bootm.c +4 -7
@@ -85,20 +85,17 @@ static void boot_prep_linux(bootm_headers_t *images)static void boot_jump_linux (bootm_headers_t *images) { -void (*theKernel) (int ,char **,char **,int *); +typedef void __noreturn (*kernel_entry_t )(int ,ulong ,ulong ,ulong ); +kernel_entry_t kernel = (kernel_entry_t ) images->ep; -/* find kernel entry point */ - theKernel = (void (*)(int ,char **,char **,int *))images->ep; - -debug ("## Transferring control to Linux (at address %08lx) ...\n" , - (ulong ) theKernel); +debug ("## Transferring control to Linux (at address %p) ...\n" , kernel);bootstage_mark (BOOTSTAGE_ID_RUN_OS );/* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n" ); -theKernel (linux_argc, linux_argv, linux_env,0 ); +kernel (linux_argc, (ulong )linux_argv, (ulong )linux_env,0 ); } int do_bootm_linux(int flag, int argc, char * const argv[],
Signature · 1 line
1.8.1.2
PATCH 3/11 MIPS: bootm: add support for LMB
In reply to Daniel SchwierzeckThis is required for init ramdisk relocation and device tree support.
--- arch/mips/include/asm/config.h | 2 ++ arch/mips/lib/bootm.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+)
arch/mips/include/asm/config.h +2 -0
@@ -21,4 +21,6 @@#ifndef _ASM_CONFIG_H_#define _ASM_CONFIG_H_ +#define CONFIG_LMB +#endif
arch/mips/lib/bootm.c +21 -0
@@ -43,6 +43,27 @@ static int linux_env_idx;static void linux_params_init (ulong start,char *commandline);static void linux_env_set (char *env_name,char *env_val); +static ulong arch_get_sp (void ) +{ +ulong ret; + + __asm__ __volatile__("move %0, $sp" :"=r" (ret) : ); + +return ret; +} + +void arch_lmb_reserve (struct lmb *lmb) +{ +ulong sp; + + sp =arch_get_sp (); +debug ("## Current stack ends at 0x%08lx\n" , sp); + +/* adjust sp by 4K to be safe */ + sp -=4096 ; +lmb_reserve (lmb, sp,CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp); +} +static void boot_prep_linux (bootm_headers_t *images) {char *commandline =getenv ("bootargs" );
Signature · 1 line
1.8.1.2
PATCH 4/11 MIPS: bootm: refactor initialisation of kernel cmdline
In reply to Daniel SchwierzeckMove initialisation of Linux command line to separate functions. Also add support for bootm subcommand 'cmdline'.
--- arch/mips/lib/bootm.c | 130 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 84 insertions(+), 46 deletions(-)
arch/mips/lib/bootm.c +84 -46
@@ -35,12 +35,13 @@ DECLARE_GLOBAL_DATA_PTR;static int linux_argc;static char **linux_argv; +static char *linux_argp;static char **linux_env;static char *linux_env_p;static int linux_env_idx; -static void linux_params_init (ulong start,char *commandline); +static void linux_params_init (void );static void linux_env_set (char *env_name,char *env_val);static ulong arch_get_sp (void )
@@ -64,13 +65,84 @@ void arch_lmb_reserve(struct lmb *lmb)lmb_reserve (lmb, sp,CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp); } +static void linux_cmdline_init (void ) +{ + linux_argc =1 ; + linux_argv = (char **)UNCACHED_SDRAM (gd->bd->bi_boot_params); + linux_argv[0 ] =0 ; + linux_argp = (char *)(linux_argv +LINUX_MAX_ARGS ); +} + +static void linux_cmdline_set (const char *value,size_t len) +{ + linux_argv[linux_argc] = linux_argp; +memcpy (linux_argp, value, len); + linux_argp[len] =0 ; + + linux_argp += len +1 ; + linux_argc++; +} + +static void linux_cmdline_dump (void ) +{ +#ifdef DEBUG +int i; + +printf ("## cmdline argv at 0x%p, argp at 0x%p\n" , + linux_argv, linux_argp); + +for (i =1 ; i < linux_argc; i++) +printf (" arg %03d: %s\n" , i, linux_argv[i]); +#endif +} + +static void boot_cmdline_linux (bootm_headers_t *images) +{ +const char *bootargs, *next, *quote; + +linux_cmdline_init (); + + bootargs =getenv ("bootargs" ); +if (!bootargs) +return ; + + next = bootargs; + +while (bootargs && *bootargs && linux_argc <LINUX_MAX_ARGS ) { + quote =strchr (bootargs,'"' ); + next =strchr (bootargs,' ' ); + +while (next && quote && quote < next) { +/* we found a left quote before the next blank +* now we have to find the matching right quote +*/ + next =strchr (quote +1 ,'"' ); +if (next) { + quote =strchr (next +1 ,'"' ); + next =strchr (next +1 ,' ' ); + } + } + +if (!next) + next = bootargs +strlen (bootargs); + +linux_cmdline_set (bootargs, next - bootargs); + +if (*next) + next++; + + bootargs = next; + } + +linux_cmdline_dump (); +} +static void boot_prep_linux (bootm_headers_t *images) { -char *commandline =getenv ("bootargs" );char env_buf[12 ];char *cp; -linux_params_init (UNCACHED_SDRAM (gd->bd->bi_boot_params), commandline); +linux_params_init ();#ifdef CONFIG_MEMSIZE_IN_BYTES sprintf (env_buf,"%lu" , (ulong )gd->ram_size);
@@ -123,9 +195,14 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) {/* No need for those on MIPS */ -if (flag &BOOTM_STATE_OS_BD_T || flag &BOOTM_STATE_OS_CMDLINE ) +if (flag &BOOTM_STATE_OS_BD_T )return -1 ; +if (flag &BOOTM_STATE_OS_CMDLINE ) { +boot_cmdline_linux (images); +return 0 ; + } +if (flag &BOOTM_STATE_OS_PREP ) {boot_prep_linux (images);return 0 ;
@@ -136,6 +213,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[],return 0 ; } +boot_cmdline_linux (images);boot_prep_linux (images);boot_jump_linux (images);
@@ -143,49 +221,9 @@ int do_bootm_linux(int flag, int argc, char * const argv[],return 1 ; } -static void linux_params_init (ulong start,char *line) +static void linux_params_init (void ) { -char *next, *quote, *argp; - - linux_argc =1 ; - linux_argv = (char **)start; - linux_argv[0 ] =0 ; - argp = (char *)(linux_argv +LINUX_MAX_ARGS ); - - next = line; - -while (line && *line && linux_argc <LINUX_MAX_ARGS ) { - quote =strchr (line,'"' ); - next =strchr (line,' ' ); - -while (next && quote && quote < next) { -/* we found a left quote before the next blank -* now we have to find the matching right quote -*/ - next =strchr (quote +1 ,'"' ); -if (next) { - quote =strchr (next +1 ,'"' ); - next =strchr (next +1 ,' ' ); - } - } - -if (!next) - next = line +strlen (line); - - linux_argv[linux_argc] = argp; -memcpy (argp, line, next - line); - argp[next - line] =0 ; - - argp += next - line +1 ; - linux_argc++; - -if (*next) - next++; - - line = next; - } - - linux_env = (char **)(((ulong ) argp +15 ) & ~15 ); + linux_env = (char **)(((ulong ) linux_argp +15 ) & ~15 ); linux_env[0 ] =0 ; linux_env_p = (char *)(linux_env +LINUX_MAX_ENVS ); linux_env_idx =0 ;
Signature · 1 line
1.8.1.2
PATCH 4/11 MIPS: bootm: refactor initialisation of kernel cmdline
Dear Daniel Schwierzeck,
Quoted 5 lines · In message <[email protected]>…
Move initialisation of Linux command line to separate functions. Also add support for bootm subcommand 'cmdline'.
arch/mips/lib/bootm.c +2
-0+static void linux_cmdline_dump (void ) +{
arch/mips/lib/bootm.c void arch_lmb_reserve(struct lmb *lmb) · line 97
Quoted 10 lines
arch/mips/lib/bootm.c +10
-0+#ifdef DEBUG +int i; + +printf ("## cmdline argv at 0x%p, argp at 0x%p\n" , + linux_argv, linux_argp); + +for (i =1 ; i < linux_argc; i++) +printf (" arg %03d: %s\n" , i, linux_argv[i]); +#endif +}
Please remove the #ifdef here, and change printf() into debug() instead.
arch/mips/lib/bootm.c void arch_lmb_reserve(struct lmb *lmb) · line 118
Quoted 4 lines
arch/mips/lib/bootm.c +4
-0+while (next && quote && quote < next) { +/* we found a left quote before the next blank +* now we have to find the matching right quote +*/
Incorrect multiline comment style.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de IMPORTANT NOTICE TO PURCHASERS: The Entire Physical Universe, Inclu- ding This Product, May One Day Collapse Back into an Infinitesimally Small Space. Should Another Universe Subsequently Re-emerge, the Existence of This Product in That Universe Cannot Be Guaranteed.
PATCH 4/11 MIPS: bootm: refactor initialisation of kernel cmdline
2013/6/9 Wolfgang Denk <[email protected]>:
Quoted 6 lines
Dear Daniel Schwierzeck,
Quoted 2 lines · In message <[email protected]>…
Move initialisation of Linux command line to separate functions. Also add support for bootm subcommand 'cmdline'.
Quoted 15 lines
arch/mips/lib/bootm.c void arch_lmb_reserve(struct lmb *lmb) · line 97
Quoted 12 lines
arch/mips/lib/bootm.c +12
-0+static void linux_cmdline_dump (void ) +{ +#ifdef DEBUG +int i; + +printf ("## cmdline argv at 0x%p, argp at 0x%p\n" , + linux_argv, linux_argp); + +for (i =1 ; i < linux_argc; i++) +printf (" arg %03d: %s\n" , i, linux_argv[i]); +#endif +}Please remove the #ifdef here, and change
printf()intodebug()instead.
I will change it
Quoted 8 lines
arch/mips/lib/bootm.c void arch_lmb_reserve(struct lmb *lmb) · line 118
Quoted 5 lines
arch/mips/lib/bootm.c +4
-0+while (next && quote && quote < next) { +/* we found a left quote before the next blank +* now we have to find the matching right quote +*/ Incorrect multiline comment style.
a left-over from the original code. I will fix it in patch 01/11.
Thanks,
Daniel
PATCH v2 4/11 MIPS: bootm: refactor initialisation of kernel cmdline
In reply to Daniel SchwierzeckMove initialisation of Linux command line to separate functions. Also add support for bootm subcommand 'cmdline'.
---
Changes in v2:
- use debug() macro
arch/mips/lib/bootm.c | 130 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 47 deletions(-)
arch/mips/lib/bootm.c +83 -47
@@ -35,12 +35,13 @@ DECLARE_GLOBAL_DATA_PTR;static int linux_argc;static char **linux_argv; +static char *linux_argp;static char **linux_env;static char *linux_env_p;static int linux_env_idx; -static void linux_params_init (ulong start,char *commandline); +static void linux_params_init (void );static void linux_env_set (char *env_name,char *env_val);static ulong arch_get_sp (void )
@@ -64,13 +65,83 @@ void arch_lmb_reserve(struct lmb *lmb)lmb_reserve (lmb, sp,CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp); } +static void linux_cmdline_init (void ) +{ + linux_argc =1 ; + linux_argv = (char **)UNCACHED_SDRAM (gd->bd->bi_boot_params); + linux_argv[0 ] =0 ; + linux_argp = (char *)(linux_argv +LINUX_MAX_ARGS ); +} + +static void linux_cmdline_set (const char *value,size_t len) +{ + linux_argv[linux_argc] = linux_argp; +memcpy (linux_argp, value, len); + linux_argp[len] =0 ; + + linux_argp += len +1 ; + linux_argc++; +} + +static void linux_cmdline_dump (void ) +{ +int i; + +debug ("## cmdline argv at 0x%p, argp at 0x%p\n" , + linux_argv, linux_argp); + +for (i =1 ; i < linux_argc; i++) +debug (" arg %03d: %s\n" , i, linux_argv[i]); +} + +static void boot_cmdline_linux (bootm_headers_t *images) +{ +const char *bootargs, *next, *quote; + +linux_cmdline_init (); + + bootargs =getenv ("bootargs" ); +if (!bootargs) +return ; + + next = bootargs; + +while (bootargs && *bootargs && linux_argc <LINUX_MAX_ARGS ) { + quote =strchr (bootargs,'"' ); + next =strchr (bootargs,' ' ); + +while (next && quote && quote < next) { +/* +* we found a left quote before the next blank +* now we have to find the matching right quote +*/ + next =strchr (quote +1 ,'"' ); +if (next) { + quote =strchr (next +1 ,'"' ); + next =strchr (next +1 ,' ' ); + } + } + +if (!next) + next = bootargs +strlen (bootargs); + +linux_cmdline_set (bootargs, next - bootargs); + +if (*next) + next++; + + bootargs = next; + } + +linux_cmdline_dump (); +} +static void boot_prep_linux (bootm_headers_t *images) { -char *commandline =getenv ("bootargs" );char env_buf[12 ];char *cp; -linux_params_init (UNCACHED_SDRAM (gd->bd->bi_boot_params), commandline); +linux_params_init ();#ifdef CONFIG_MEMSIZE_IN_BYTES sprintf (env_buf,"%lu" , (ulong )gd->ram_size);
@@ -123,9 +194,14 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) {/* No need for those on MIPS */ -if (flag &BOOTM_STATE_OS_BD_T || flag &BOOTM_STATE_OS_CMDLINE ) +if (flag &BOOTM_STATE_OS_BD_T )return -1 ; +if (flag &BOOTM_STATE_OS_CMDLINE ) { +boot_cmdline_linux (images); +return 0 ; + } +if (flag &BOOTM_STATE_OS_PREP ) {boot_prep_linux (images);return 0 ;
@@ -136,6 +212,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[],return 0 ; } +boot_cmdline_linux (images);boot_prep_linux (images);boot_jump_linux (images);
@@ -143,50 +220,9 @@ int do_bootm_linux(int flag, int argc, char * const argv[],return 1 ; } -static void linux_params_init (ulong start,char *line) +static void linux_params_init (void ) { -char *next, *quote, *argp; - - linux_argc =1 ; - linux_argv = (char **)start; - linux_argv[0 ] =0 ; - argp = (char *)(linux_argv +LINUX_MAX_ARGS ); - - next = line; - -while (line && *line && linux_argc <LINUX_MAX_ARGS ) { - quote =strchr (line,'"' ); - next =strchr (line,' ' ); - -while (next && quote && quote < next) { -/* -* we found a left quote before the next blank -* now we have to find the matching right quote -*/ - next =strchr (quote +1 ,'"' ); -if (next) { - quote =strchr (next +1 ,'"' ); - next =strchr (next +1 ,' ' ); - } - } - -if (!next) - next = line +strlen (line); - - linux_argv[linux_argc] = argp; -memcpy (argp, line, next - line); - argp[next - line] =0 ; - - argp += next - line +1 ; - linux_argc++; - -if (*next) - next++; - - line = next; - } - - linux_env = (char **)(((ulong ) argp +15 ) & ~15 ); + linux_env = (char **)(((ulong ) linux_argp +15 ) & ~15 ); linux_env[0 ] =0 ; linux_env_p = (char *)(linux_env +LINUX_MAX_ENVS ); linux_env_idx =0 ;
Signature · 1 line
1.8.1.2
PATCH 5/11 MIPS: bootm: refactor initialisation of kernel environment
In reply to Daniel SchwierzeckMove initialisation of Linux environment to separate functions.
--- arch/mips/lib/bootm.c | 69 ++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 34 deletions(-)
arch/mips/lib/bootm.c +35 -34
@@ -41,9 +41,6 @@ static char **linux_env;static char *linux_env_p;static int linux_env_idx; -static void linux_params_init (void ); -static void linux_env_set (char *env_name,char *env_val); -static ulong arch_get_sp (void ) {ulong ret;
@@ -137,12 +134,36 @@ static void boot_cmdline_linux(bootm_headers_t *images)linux_cmdline_dump (); } -static void boot_prep_linux (bootm_headers_t *images) +static void linux_env_init (void ) { -char env_buf[12 ]; -char *cp; + linux_env = (char **)(((ulong ) linux_argp +15 ) & ~15 ); + linux_env[0 ] =0 ; + linux_env_p = (char *)(linux_env +LINUX_MAX_ENVS ); + linux_env_idx =0 ; +} -linux_params_init (); +static void linux_env_set (const char *env_name,const char *env_val) +{ +if (linux_env_idx <LINUX_MAX_ENVS -1 ) { + linux_env[linux_env_idx] = linux_env_p; + +strcpy (linux_env_p, env_name); + linux_env_p +=strlen (env_name); + + *linux_env_p++ ='=' ; + +strcpy (linux_env_p, env_val); + linux_env_p +=strlen (env_val); + + linux_env_p++; + linux_env[++linux_env_idx] =0 ; + } +} + +static void boot_prep_linux_legacy (bootm_headers_t *images) +{ +char env_buf[12 ]; +const char *cp;#ifdef CONFIG_MEMSIZE_IN_BYTES sprintf (env_buf,"%lu" , (ulong )gd->ram_size);
@@ -153,6 +174,8 @@ static void boot_prep_linux(bootm_headers_t *images) (ulong)(gd->ram_size >> 20));#endif /* CONFIG_MEMSIZE_IN_BYTES */ +linux_env_init (); +linux_env_set ("memsize" , env_buf);sprintf (env_buf,"0x%08X" , (uint )UNCACHED_SDRAM (images->rd_start));
@@ -176,6 +199,11 @@ static void boot_prep_linux(bootm_headers_t *images)linux_env_set ("eth1addr" , cp); } +static void boot_prep_linux (bootm_headers_t *images) +{ +boot_prep_linux_legacy (images); +} +static void boot_jump_linux (bootm_headers_t *images) {typedef void __noreturn (*kernel_entry_t )(int ,ulong ,ulong ,ulong );
@@ -220,30 +248,3 @@ int do_bootm_linux(int flag, int argc, char * const argv[],/* does not return */ return 1 ; } - -static void linux_params_init (void ) -{ - linux_env = (char **)(((ulong ) linux_argp +15 ) & ~15 ); - linux_env[0 ] =0 ; - linux_env_p = (char *)(linux_env +LINUX_MAX_ENVS ); - linux_env_idx =0 ; -} - -static void linux_env_set (char *env_name,char *env_val) -{ -if (linux_env_idx <LINUX_MAX_ENVS -1 ) { - linux_env[linux_env_idx] = linux_env_p; - -strcpy (linux_env_p, env_name); - linux_env_p +=strlen (env_name); - -strcpy (linux_env_p,"=" ); - linux_env_p +=1 ; - -strcpy (linux_env_p, env_val); - linux_env_p +=strlen (env_val); - - linux_env_p++; - linux_env[++linux_env_idx] =0 ; - } -}
Signature · 1 line
1.8.1.2
PATCH 6/11 MIPS: bootm: make initialisation of Linux environment optional
In reply to Daniel SchwierzeckRecent linux kernels do not use that special environment variables anymore. Add an option to disable compilation of that code but keep it for compatibilty with older kernels.
--- README | 6 ++++++ arch/mips/lib/bootm.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
README +6 -0
@@ -522,6 +522,12 @@ The following options need to be configured: expect it to be in bytes, others in MB. Define CONFIG_MEMSIZE_IN_BYTES to make it in bytes. + CONFIG_DISABLE_ENV_INIT [relevant for MIPS only] + + Disable initialization of traditional environment variables + passed to Linux. Modern kernels only use variables from command + line. + CONFIG_OF_LIBFDT New kernel versions are expecting firmware settings to be
arch/mips/lib/bootm.c +8 -1
@@ -33,6 +33,12 @@ DECLARE_GLOBAL_DATA_PTR;#define LINUX_MAX_ENVS 256#define LINUX_MAX_ARGS 256 +#if defined(CONFIG_DISABLE_ENV_INIT ) +#define need_linux_env 0 +#else +#define need_linux_env 1 +#endif +static int linux_argc;static char **linux_argv;static char *linux_argp;
@@ -201,7 +207,8 @@ static void boot_prep_linux_legacy(bootm_headers_t *images)static void boot_prep_linux (bootm_headers_t *images) { -boot_prep_linux_legacy (images); +if (need_linux_env) +boot_prep_linux_legacy (images); }static void boot_jump_linux (bootm_headers_t *images)
Signature · 1 line
1.8.1.2
PATCH 7/11 MIPS: bootm: add support for generic relocation of init ramdisks
In reply to Daniel SchwierzeckAll linux kernels after v2.6 require a page-aligned location of an external init ramdisk. Enable CONFIG_SYS_BOOT_RAMDISK_HIGH to support this with the generic U-Boot relocation code.
--- arch/mips/include/asm/config.h | 1 + arch/mips/lib/bootm.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
arch/mips/include/asm/config.h +1 -0
@@ -22,5 +22,6 @@#define _ASM_CONFIG_H_#define CONFIG_LMB +#define CONFIG_SYS_BOOT_RAMDISK_HIGH #endif
arch/mips/lib/bootm.c +6 -2
@@ -170,6 +170,7 @@ static void boot_prep_linux_legacy(bootm_headers_t *images) {char env_buf[12 ];const char *cp; +ulong rd_start, rd_size;#ifdef CONFIG_MEMSIZE_IN_BYTES sprintf (env_buf,"%lu" , (ulong )gd->ram_size);
@@ -180,14 +181,17 @@ static void boot_prep_linux_legacy(bootm_headers_t *images) (ulong)(gd->ram_size >> 20));#endif /* CONFIG_MEMSIZE_IN_BYTES */ + rd_start =UNCACHED_SDRAM (images->initrd_start); + rd_size = images->initrd_end - images->initrd_start; +linux_env_init ();linux_env_set ("memsize" , env_buf); -sprintf (env_buf,"0x%08X" , (uint )UNCACHED_SDRAM (images->rd_start)); +sprintf (env_buf,"0x%08lX" , rd_start);linux_env_set ("initrd_start" , env_buf); -sprintf (env_buf,"0x%X" , (uint) (images->rd_end - images->rd_start)); +sprintf (env_buf,"0x%lX" , rd_size);linux_env_set ("initrd_size" , env_buf);sprintf (env_buf,"0x%08X" , (uint) (gd->bd->bi_flashstart));
Signature · 1 line
1.8.1.2
PATCH 8/11 MIPS: bootm: automatically initialise kernel cmdline variable 'mem'
In reply to Daniel SchwierzeckThis replaces the passing of memory size via the traditional Linux environment. This is required for recent Linux kernels.
--- arch/mips/lib/bootm.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/mips/lib/bootm.c +6 -0
@@ -102,9 +102,15 @@ static void linux_cmdline_dump(void)static void boot_cmdline_linux (bootm_headers_t *images) {const char *bootargs, *next, *quote; +char buf[12 ]; +unsigned int mem = gd->ram_size >>20 ;linux_cmdline_init (); +/* append mem */ +sprintf (buf,"mem=%uM" , mem); +linux_cmdline_set (buf,strlen (buf)); + bootargs =getenv ("bootargs" );if (!bootargs)return ;
Signature · 1 line
1.8.1.2
PATCH 9/11 MIPS: bootm: automatically initialise kernel cmdline variables 'rd_start' and 'rd_size'
In reply to Daniel SchwierzeckThis replaces the passing of the location and size of an external init ramdisk via the traditional Linux environment. This is required to supporta again external init ramdisks with recent Linux kernels.
--- arch/mips/lib/bootm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/mips/lib/bootm.c +12 -0
@@ -104,6 +104,7 @@ static void boot_cmdline_linux(bootm_headers_t *images)const char *bootargs, *next, *quote;char buf[12 ];unsigned int mem = gd->ram_size >>20 ; +ulong rd_start, rd_size;linux_cmdline_init ();
@@ -111,6 +112,17 @@ static void boot_cmdline_linux(bootm_headers_t *images)sprintf (buf,"mem=%uM" , mem);linux_cmdline_set (buf,strlen (buf)); +/* append rd_start and rd_size */ + rd_start = images->initrd_start; + rd_size = images->initrd_end - images->initrd_start; + +if (rd_size) { +sprintf (buf,"rd_start=0x%08lX" , rd_start); +linux_cmdline_set (buf,strlen (buf)); +sprintf (buf,"rd_size=0x%lX" , rd_size); +linux_cmdline_set (buf,strlen (buf)); + } + bootargs =getenv ("bootargs" );if (!bootargs)return ;
Signature · 1 line
1.8.1.2
PATCH 10/11 MIPS: bootm: add YAMON style Linux preparation/jump code for Qemu Malta
In reply to Daniel Schwierzeck--- arch/mips/lib/bootm.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
arch/mips/lib/bootm.c +20 -2
@@ -39,6 +39,12 @@ DECLARE_GLOBAL_DATA_PTR;#define need_linux_env 1#endif +#if defined(CONFIG_QEMU_MALTA ) +#define board_is_qemu_malta 1 +#else +#define board_is_qemu_malta 0 +#endif +static int linux_argc;static char **linux_argv;static char *linux_argp;
@@ -174,7 +180,12 @@ static void linux_env_set(const char *env_name, const char *env_val)strcpy (linux_env_p, env_name); linux_env_p +=strlen (env_name); - *linux_env_p++ ='=' ; +if (board_is_qemu_malta) { + linux_env_p++; + linux_env[++linux_env_idx] = linux_env_p; + }else { + *linux_env_p++ ='=' ; + }strcpy (linux_env_p, env_val); linux_env_p +=strlen (env_val);
@@ -225,6 +236,9 @@ static void boot_prep_linux_legacy(bootm_headers_t *images) cp =getenv ("eth1addr" );if (cp)linux_env_set ("eth1addr" , cp); + +if (board_is_qemu_malta) +linux_env_set ("modetty0" ,"38400n8r" ); }static void boot_prep_linux (bootm_headers_t *images)
@@ -237,15 +251,19 @@ static void boot_jump_linux(bootm_headers_t *images) {typedef void __noreturn (*kernel_entry_t )(int ,ulong ,ulong ,ulong );kernel_entry_t kernel = (kernel_entry_t ) images->ep; +ulong linux_extra =0 ;debug ("## Transferring control to Linux (at address %p) ...\n" , kernel);bootstage_mark (BOOTSTAGE_ID_RUN_OS ); +if (board_is_qemu_malta) + linux_extra = gd->ram_size; +/* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n" ); -kernel (linux_argc, (ulong )linux_argv, (ulong )linux_env,0 ); +kernel (linux_argc, (ulong )linux_argv, (ulong )linux_env, linux_extra); } int do_bootm_linux(int flag, int argc, char * const argv[],
Signature · 1 line
1.8.1.2
PATCH 11/11 MIPS: bootm: drop obsolete Qemu specific bootm implementation
In reply to Daniel SchwierzeckThe Qemu specific bootm implementation was intended for a special Qemu target in Linux kernel. But this target has been dropped in v2.6.25-rc1 by commit 302922e5f6901eb6f29c58539631f71b3d9746b8
Author: Ralf Baechle <[email protected]>
Date: Tue Jan 29 10:15:02 2008 +0000
[MIPS] Qemu: Remove platform.
The Qemu platform was originally implemented to have an easily supportable platform until Qemu reaches a state where it emulates a real world system. Since the latest release Qemu is capable of emulating the MIPSsim and Malta platforms, so this goal has been reached. The Qemu plaform is also rather underfeatured so less useful than a Malta emulation.
Thus the special bootm implementation is obsolete by now and can be dropped. The Qemu support in U-Boot is going to be replaced by MIPS Malta board support.
--- arch/mips/lib/Makefile | 4 --- arch/mips/lib/bootm_qemu_mips.c | 78 ----------------------------------------- 2 files changed, 82 deletions(-) delete mode 100644 arch/mips/lib/bootm_qemu_mips.c
arch/mips/lib/Makefile +0 -4
@@ -35,11 +35,7 @@ LGOBJS := $(addprefix $(obj),$(GLSOBJS)) SOBJS-y += COBJS-y += board.o -ifeq ($(CONFIG_QEMU_MIPS),y) -COBJS-y += bootm_qemu_mips.o -else COBJS-y += bootm.o -endif SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
arch/mips/lib/bootm_qemu_mips.c deleted +0 -78
78 lines not on this page · raw message
Signature · 1 line
1.8.1.2
cover MIPS: bootm updates
In reply to Daniel SchwierzeckHi Daniel,
Quoted 9 lines
- refactoring and optimization of bootm command
- add support for logical memory blocks (LMB)
- make external init ramdisks working again with recent kernels
- add support for bootm subcommand 'cmdline'
- prepare bootm for upcoming device tree support
- add bootm support for newly added MIPS Malta Qemu
- drop obsolete bootm support of MIPS Qemu
Quoted 14 lines
Daniel Schwierzeck (11):
MIPS: bootm: fix checkpatch.pl warnings
MIPS: bootm: optimise kernel entry call
MIPS: bootm: add support for LMB
MIPS: bootm: refactor initialisation of kernel cmdline
MIPS: bootm: refactor initialisation of kernel environment
MIPS: bootm: make initialisation of Linux environment optional
MIPS: bootm: add support for generic relocation of init ramdisks
MIPS: bootm: automatically initialise kernel cmdline variable 'mem'
MIPS: bootm: automatically initialise kernel cmdline variables
'rd_start' and 'rd_size'
MIPS: bootm: add YAMON style Linux preparation/jump code for Qemu
Malta
MIPS: bootm: drop obsolete Qemu specific bootm implementation
The series looks good.
-Gabor
cover MIPS: bootm updates
In reply to Daniel SchwierzeckHello Daniel,
sorry for being late with my questions.
Daniel Schwierzeck wrote on?2013-06-09:
Quoted 6 lines
MIPS: bootm: refactor initialisation of kernel cmdline
MIPS: bootm: refactor initialisation of kernel environment
MIPS: bootm: make initialisation of Linux environment optional
MIPS: bootm: add support for generic relocation of init ramdisks
MIPS: bootm: automatically initialise kernel cmdline variable 'mem'
MIPS: bootm: automatically initialise kernel cmdline variables 'rd_start' and 'rd_size'
These patches changing the style, how parameters are given to the kernel (using cmdline instead of environment).
Can you explain a little, why this is necessary?
Please give some references to the corresponding kernel changes or discussions, if possible.
And how about backward compatibility? Will it still be possible to boot older kernels?
When you automatically add the variable 'mem', will it still be possible to override the memory size by manually adding it to the bootargs?
Best Regards,
Thomas
cover MIPS: bootm updates
Hi Thomas,
Am 21.06.2013 21:59 schrieb "Langer Thomas (LQDE RD ST PON SW)" < [email protected]>:
Quoted 12 lines
Hello Daniel,
sorry for being late with my questions.
Daniel Schwierzeck wrote on 2013-06-09:
Quoted 6 lines
MIPS: bootm: refactor initialisation of kernel cmdline
MIPS: bootm: refactor initialisation of kernel environment
MIPS: bootm: make initialisation of Linux environment optional
MIPS: bootm: add support for generic relocation of init ramdisks
MIPS: bootm: automatically initialise kernel cmdline variable 'mem'
MIPS: bootm: automatically initialise kernel cmdline variables
'rd_start' and 'rd_size'
Quoted 3 lines
These patches changing the style, how parameters are given to the kernel (using cmdline instead of environment)
The environment is still available
Quoted 3 lines
Can you explain a little, why this is necessary?
Please give some references to the corresponding kernel changes or
discussions, if possible.
the current U-Boot kernel interface emulates the YAMON interface. But almost all boards supported by the kernel are bootloader agnostic or don't use U-Boot.
Quoted 2 lines
And how about backward compatibility? Will it still be possible to boot
older kernels?
Quoted 7 lines
When you automatically add the variable 'mem', will it still be possible to override the memory size by manually adding it to the bootargs?
Best Regards,
Thomas
cover MIPS: bootm updates
2013/6/25 Daniel Schwierzeck <[email protected]>:
Quoted 2 lines
Hi Thomas,
oops, I hit the send key too early
Quoted 24 lines
Am 21.06.2013 21:59 schrieb "Langer Thomas (LQDE RD ST PON SW)" <[email protected]>:
Quoted 14 lines
Hello Daniel,
sorry for being late with my questions.
Daniel Schwierzeck wrote on 2013-06-09:
Quoted 7 lines
MIPS: bootm: refactor initialisation of kernel cmdline
MIPS: bootm: refactor initialisation of kernel environment
MIPS: bootm: make initialisation of Linux environment optional
MIPS: bootm: add support for generic relocation of init ramdisks
MIPS: bootm: automatically initialise kernel cmdline variable 'mem'
MIPS: bootm: automatically initialise kernel cmdline variables
'rd_start' and 'rd_size'Quoted 2 lines
These patches changing the style, how parameters are given to the kernel (using cmdline instead of environment)
The environment is still available
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Can you explain a little, why this is necessary?
Please give some references to the corresponding kernel changes or discussions, if possible.the current U-Boot kernel interface emulates the YAMON interface. But almost all boards supported by the kernel are bootloader agnostic or don't use U-Boot.
The generic kernel interface for mem and initramfs is either commandline or device tree. IMHO it makes no sense to add bootloader specific code like environment parsing to the kernel. So I want to support the generic interfaces in U-Boot. The old environment code is still available.
Quoted 4 lines
Quoted 4 lines
And how about backward compatibility? Will it still be possible to boot older kernels?
I had no problems in my tests. Also a Lantiq BSP kernel boots fine.
Quoted 4 lines
Quoted 4 lines
When you automatically add the variable 'mem', will it still be possible to override the memory size by manually adding it to the bootargs?
I think you are referring to Lantiq's way of passing memory sizes for voice firmware
to the kernel. Indeed this won't work anymore. I can add an additional if condition around
the automatic code. Anyway I think it is better to always pass the full memory size to
the kernel and reserve firmware memory by allocating contiguous DMA memory. Then there is no need for propietary or bootloader-specific boot interfaces.
--
Best regards,
Daniel