[U-Boot] [PATCH 05/11] MIPS: bootm: refactor initialisation of kernel environment
Daniel Schwierzeck
daniel.schwierzeck at gmail.com
Sun Jun 9 00:42:44 CEST 2013
Move initialisation of Linux environment to separate functions.
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck at gmail.com>
---
arch/mips/lib/bootm.c | 69 ++++++++++++++++++++++++++-------------------------
1 file changed, 35 insertions(+), 34 deletions(-)
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 6045905..304ee53 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -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;
- }
-}
--
1.8.1.2
More information about the U-Boot
mailing list