From patchwork Tue Jan 24 14:27:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 137562 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 62C92B6EF2 for ; Wed, 25 Jan 2012 01:29:56 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AE80228165; Tue, 24 Jan 2012 15:29:41 +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 9Dju+X85U7wE; Tue, 24 Jan 2012 15:29:41 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D1E0F2818D; Tue, 24 Jan 2012 15:29:11 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EA3992814E for ; Tue, 24 Jan 2012 15:28:56 +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 dDdJUIV8PnK0 for ; Tue, 24 Jan 2012 15:28:55 +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 mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by theia.denx.de (Postfix) with ESMTPS id D638A2814A for ; Tue, 24 Jan 2012 15:28:53 +0100 (CET) Received: by wibhn9 with SMTP id hn9so2893450wib.3 for ; Tue, 24 Jan 2012 06:28:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=YZjvOMBsHjDWFCYjCMpbXzBeGNjeJCcKhrc0nQVo0Z4=; b=AhTVXto5+bkqaC7WycigAdHbA7g1q8/hQvQmfff3GVfotQkm13NTMWIOoYpPHYOeGB EMNccyXQiYOdVM2Y2WXRr9gdS6Ro5S7BPVFAPK5wMdsIvvxbgoKElHB9C1IHr9oJqsQ/ 7QwV+ISMKQtfD2SshJLwd52JWhGSV37o7G81c= Received: by 10.180.80.68 with SMTP id p4mr164696wix.21.1327415332723; Tue, 24 Jan 2012 06:28:52 -0800 (PST) Received: from Pali-EliteBook.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPS id n3sm52913728wiz.9.2012.01.24.06.28.51 (version=SSLv3 cipher=OTHER); Tue, 24 Jan 2012 06:28:52 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Date: Tue, 24 Jan 2012 15:27:59 +0100 Message-Id: <1327415291-13260-3-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1327415291-13260-1-git-send-email-pali.rohar@gmail.com> References: <1327415291-13260-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Cc: =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [U-Boot] [PATCH 02/14] arm: Optionally use existing atags in bootm.c 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch adapts the bootm command so that it can use an existing atags command set up by a previous bootloader. If the environment variable "atagaddr" is unset, bootm behaves as normal. If "atagaddr" is set, bootm will use atags address from environment variable and also append new boot args (if specified in u-boot). For example, if a previous boot loader already set up the atags struct at 0x80000100: setenv atagaddr 0x80000100; bootm 0x80008000 Signed-off-by: Pali Rohár --- Changes since original version: - Added info to README file - Added local define CONFIG_SETUP_ANY_TAG - Fixed compile warning - Fixed commit message - Check if atagaddr is not NULL README | 2 ++ arch/arm/lib/bootm.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/README b/README index 9d713e8..8c3b98a 100644 --- a/README +++ b/README @@ -3584,6 +3584,8 @@ Some configuration options can be set using Environment Variables. List of environment variables (most likely not complete): + atagaddr - bootm will use ATAGs struct from specified address (arm only) + baudrate - see CONFIG_BAUDRATE bootdelay - see CONFIG_BOOTDELAY diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index afa0093..8366dd5 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -93,6 +93,14 @@ static void announce_and_cleanup(void) cleanup_before_linux(); } +#if defined(CONFIG_SETUP_MEMORY_TAGS) || \ +defined(CONFIG_CMDLINE_TAG) || \ +defined(CONFIG_INITRD_TAG) || \ +defined(CONFIG_SERIAL_TAG) || \ +defined(CONFIG_REVISION_TAG) +#define CONFIG_SETUP_ANY_TAG +#endif + int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { bd_t *bd = gd->bd; @@ -125,12 +133,22 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) kernel_entry); -#if defined (CONFIG_SETUP_MEMORY_TAGS) || \ - defined (CONFIG_CMDLINE_TAG) || \ - defined (CONFIG_INITRD_TAG) || \ - defined (CONFIG_SERIAL_TAG) || \ - defined (CONFIG_REVISION_TAG) - setup_start_tag (bd); + s = getenv("atagaddr"); + if (s) + bd->bi_boot_params = simple_strtoul(s, NULL, 16); + + if (bd->bi_boot_params) { + printf("Using existing atags at %#lx\n", bd->bi_boot_params); + + params = (struct tag *) bd->bi_boot_params; + while (params->hdr.size > 0) + params = tag_next(params); + } else { +#ifdef CONFIG_SETUP_ANY_TAG + setup_start_tag(bd); +#endif + } + #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif @@ -147,8 +165,15 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) if (images->rd_start && images->rd_end) setup_initrd_tag (bd, images->rd_start, images->rd_end); #endif - setup_end_tag(bd); + + if (s) { + if (params->hdr.size > 0) + setup_end_tag(bd); + } else { +#ifdef CONFIG_SETUP_ANY_TAG + setup_end_tag(bd); #endif + } announce_and_cleanup();