diff options
author | Daniel Schwierzeck <daniel.schwierzeck@gmail.com> | 2013-05-09 17:10:06 +0200 |
---|---|---|
committer | Daniel Schwierzeck <daniel.schwierzeck@gmail.com> | 2013-08-13 11:58:48 +0200 |
commit | 15f8aa90931c47cecac41984bf80bb394c3f4dfd (patch) | |
tree | 86abc2ce9f839c3abb95e0b1205f9675f62b4689 /arch/mips/lib/bootm.c | |
parent | 59e8cbdb15953d3b3bfeb9feb20afc7205a0ad93 (diff) | |
download | u-boot-imx-15f8aa90931c47cecac41984bf80bb394c3f4dfd.zip u-boot-imx-15f8aa90931c47cecac41984bf80bb394c3f4dfd.tar.gz u-boot-imx-15f8aa90931c47cecac41984bf80bb394c3f4dfd.tar.bz2 |
MIPS: bootm: refactor initialisation of kernel environment
Move initialisation of Linux environment to separate functions.
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Diffstat (limited to 'arch/mips/lib/bootm.c')
-rw-r--r-- | arch/mips/lib/bootm.c | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index ba9fd68..257390b 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -25,9 +25,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; @@ -120,12 +117,36 @@ static void boot_cmdline_linux(bootm_headers_t *images) linux_cmdline_dump(); } +static void linux_env_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(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(bootm_headers_t *images) { char env_buf[12]; - char *cp; - - linux_params_init(); + const char *cp; #ifdef CONFIG_MEMSIZE_IN_BYTES sprintf(env_buf, "%lu", (ulong)gd->ram_size); @@ -136,6 +157,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)); @@ -203,30 +226,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; - } -} |