[U-Boot] [PATCH 09/10] MIPS: bootm.c: add YAMON style Linux preparation/jump code

Gabor Juhos juhosg at openwrt.org
Wed Jan 23 18:05:04 CET 2013


Signed-off-by: Gabor Juhos <juhosg at openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck at googlemail.com>
---
Changes since RFC: ---
---
 arch/mips/lib/bootm.c |   60 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 58 insertions(+), 2 deletions(-)

diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index a36154a..747d790 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -33,6 +33,12 @@ DECLARE_GLOBAL_DATA_PTR;
 #define	LINUX_MAX_ENVS		256
 #define	LINUX_MAX_ARGS		256
 
+#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;
 
@@ -43,7 +49,7 @@ 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 void boot_prep_linux(bootm_headers_t *images)
+static void boot_prep_linux_legacy(bootm_headers_t *images)
 {
 	char *commandline = getenv("bootargs");
 	char env_buf[12];
@@ -83,6 +89,52 @@ static void boot_prep_linux(bootm_headers_t *images)
 		linux_env_set("eth1addr", cp);
 }
 
+static void malta_env_set(char *env_name, char *env_val)
+{
+	if (linux_env_idx >= LINUX_MAX_ENVS - 2)
+		return;
+
+	linux_env[linux_env_idx] = linux_env_p;
+
+	strcpy(linux_env_p, env_name);
+	linux_env_p += strlen(env_name);
+
+	linux_env_p++;
+	linux_env[++linux_env_idx] = 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_qemu_malta(bootm_headers_t *images)
+{
+	char *bootargs = getenv("bootargs");
+	char env_buf[12];
+	char *cp;
+
+	linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), bootargs);
+
+	/* setup environment variables */
+	sprintf(env_buf, "%lu", (ulong)gd->ram_size);
+	malta_env_set("memsize", env_buf);
+	malta_env_set("modetty0", "38400n8r");
+
+	cp = getenv("ethaddr");
+	if (cp)
+		malta_env_set("ethaddr", cp);
+}
+
+static void boot_prep_linux(bootm_headers_t *images)
+{
+	if (board_is_qemu_malta)
+		boot_prep_linux_qemu_malta(images);
+	else
+		boot_prep_linux_legacy(images);
+}
+
 static void boot_jump_linux(bootm_headers_t *images)
 {
 	void (*theKernel) (int, char **, char **, int *);
@@ -98,7 +150,11 @@ static void boot_jump_linux(bootm_headers_t *images)
 	/* we assume that the kernel is in place */
 	printf("\nStarting kernel ...\n\n");
 
-	theKernel(linux_argc, linux_argv, linux_env, 0);
+	if (board_is_qemu_malta)
+		theKernel(linux_argc, linux_argv, linux_env,
+			  (int *) gd->ram_size);
+	else
+		theKernel(linux_argc, linux_argv, linux_env, 0);
 }
 
 int do_bootm_linux(int flag, int argc, char * const argv[],
-- 
1.7.10



More information about the U-Boot mailing list