From patchwork Sat Jun 8 22:42:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 249994 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 4B77E2C008A for ; Sun, 9 Jun 2013 08:52:08 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 091F24A23C; Sun, 9 Jun 2013 00:51:47 +0200 (CEST) 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 GXPTTFMrgHZz; Sun, 9 Jun 2013 00:51:46 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E66C94A22D; Sun, 9 Jun 2013 00:51:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E3C764A218 for ; Sun, 9 Jun 2013 00:51:40 +0200 (CEST) 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 pm8GO1-FUD4i for ; Sun, 9 Jun 2013 00:51:36 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by theia.denx.de (Postfix) with ESMTPS id C8BB34A180 for ; Sun, 9 Jun 2013 00:51:02 +0200 (CEST) Received: by mail-ee0-f44.google.com with SMTP id c13so2251835eek.17 for ; Sat, 08 Jun 2013 15:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=6tACi6dzHueAVwmhusgFx9DiWeqvTVkiOPqzO3M980Q=; b=Q0iHE/7+rASyNUqbs5liM9JiH5RgGbquyMai0w5T6Bc8+51c7p8gNWKbkfsECKI3XG GjGsI+m4VWflQtV+5KfsroYwtF58pVJZSWPx00/Jp64QNoCVdeCjZwlh4zdv4ZnYqmMr dKNapOpo6Hcm3dI7YCWFka5/KmNGbKJVceR2RvLylvhkftMdqKoYYCHTCEfp9eAS39I9 n9hMjMaY21DYOOUQO9Nne2fkkfIsE+5r8hV+oiva5qonpUeiGqkt1EpWwv++zKpuPd7K fA3TUbNwZ4jnCiGHMU/HvpfxHXGLUQFcVXklYG24mnd+x/PBSpKmLuHR/C1S4gmzsDdz XHpg== X-Received: by 10.15.61.67 with SMTP id h43mr4485379eex.102.1370731379919; Sat, 08 Jun 2013 15:42:59 -0700 (PDT) Received: from workstation.zombienet.local (p5DDCAFD5.dip0.t-ipconnect.de. [93.220.175.213]) by mx.google.com with ESMTPSA id u7sm10052133eef.14.2013.06.08.15.42.59 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 08 Jun 2013 15:42:59 -0700 (PDT) From: Daniel Schwierzeck To: u-boot@lists.denx.de Date: Sun, 9 Jun 2013 00:42:44 +0200 Message-Id: <1370731370-32767-6-git-send-email-daniel.schwierzeck@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1370731370-32767-1-git-send-email-daniel.schwierzeck@gmail.com> References: <1370731370-32767-1-git-send-email-daniel.schwierzeck@gmail.com> Subject: [U-Boot] [PATCH 05/11] MIPS: bootm: refactor initialisation of kernel environment 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 Move initialisation of Linux environment to separate functions. Signed-off-by: Daniel Schwierzeck --- 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; - } -}