[U-Boot] [PATCH v3 5/8] MIPS: bootm: refactor initialisation of kernel environment

Daniel Schwierzeck daniel.schwierzeck at gmail.com
Sun Aug 11 21:39:05 CEST 2013


Move initialisation of Linux environment to separate functions.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck at gmail.com>

---
Changes in v3:
- removed boot_prep_linux_legacy due to dropped patches

Changes in v2: None

 arch/mips/lib/bootm.c | 62 ++++++++++++++++++++++++---------------------------
 1 file 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;
-	}
-}
-- 
1.8.1.2



More information about the U-Boot mailing list