From patchwork Sat Jan 19 15:19:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabor Juhos X-Patchwork-Id: 213873 X-Patchwork-Delegate: daniel.schwierzeck@googlemail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 785F12C0082 for ; Sun, 20 Jan 2013 02:21:28 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B46E14A158; Sat, 19 Jan 2013 16:21:11 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PL3i+z3zysUa; Sat, 19 Jan 2013 16:21:11 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CA5644A131; Sat, 19 Jan 2013 16:20:25 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 934974A116 for ; Sat, 19 Jan 2013 16:20:11 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Mtqbd807AXDH for ; Sat, 19 Jan 2013 16:20:10 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) by theia.denx.de (Postfix) with ESMTPS id 08A704A0A8 for ; Sat, 19 Jan 2013 16:19:56 +0100 (CET) Received: from arrakis.dune.hu ([127.0.0.1]) by localhost (arrakis.dune.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uEAGwoez0ZkF; Sat, 19 Jan 2013 16:18:48 +0100 (CET) Received: from localhost.localdomain (catvpool-576570d8.szarvasnet.hu [87.101.112.216]) by arrakis.dune.hu (Postfix) with ESMTPSA id 8EC2528446C; Sat, 19 Jan 2013 16:18:47 +0100 (CET) From: Gabor Juhos To: u-boot@lists.denx.de Date: Sat, 19 Jan 2013 16:19:36 +0100 Message-Id: <1358608777-7270-10-git-send-email-juhosg@openwrt.org> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1358608777-7270-1-git-send-email-juhosg@openwrt.org> References: <1358608777-7270-1-git-send-email-juhosg@openwrt.org> Subject: [U-Boot] [RFC 09/10] MIPS: bootm.c: add YAMON style Linux preparation/jump code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- 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[],