From patchwork Sat Apr 28 17:26:41 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: 155677 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 F25B2B6FEA for ; Sun, 29 Apr 2012 03:27:47 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C9A94282C9; Sat, 28 Apr 2012 19:27:45 +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 KxkQkZgNLOfZ; Sat, 28 Apr 2012 19:27:44 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 20162281FE; Sat, 28 Apr 2012 19:27:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A4D41280DE for ; Sat, 28 Apr 2012 19:27:16 +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 0UshNOfz4k-s for ; Sat, 28 Apr 2012 19:27:16 +0200 (CEST) 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-we0-f172.google.com (mail-we0-f172.google.com [74.125.82.172]) by theia.denx.de (Postfix) with ESMTPS id CCFF328121 for ; Sat, 28 Apr 2012 19:27:10 +0200 (CEST) Received: by werb10 with SMTP id b10so1167102wer.3 for ; Sat, 28 Apr 2012 10:27:08 -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 :mime-version:content-type:content-transfer-encoding; bh=M/OvJCjLsb1W3a0V5OtpygI4Nb/XiZDVp+6UFjJqPws=; b=e0QOSpmEpXMFtfrVgpvd7QlSAtfP3hBgRBSkv02+1v+7DI7YTRjAgh525UPdrEg/Ew BKSoWpwG9rI+M21uCO3DnAn6pwGGPnKQLcG5CEciZ+d26WfCQ/hS1iKWEZSBRNpMnMGv v9pIw0kBucdNM3OPaZKm0UPXWU1lzM4KdWP3YgPuEESWLdnLIJxWy0T6fFarTU2iwnhr Uq7zF4jJKaJToxC+h4HPaSpHZ6qcs6eJzaPUWlvSdQ3kkQoZZaXxXlg8mtzBiqKv39Yf izE8WZbN3hAAaSQlj3JBRBsHmS11o06nKyqdplGx/MeMdFvEYcFPQmL6D0qfBngMrUCi hwDA== Received: by 10.180.96.228 with SMTP id dv4mr15880785wib.14.1335634028513; Sat, 28 Apr 2012 10:27:08 -0700 (PDT) Received: from Pali-EliteBook.kolej.mff.cuni.cz (atrey.karlin.mff.cuni.cz. [195.113.26.193]) by mx.google.com with ESMTPS id w10sm22440738wiy.3.2012.04.28.10.27.07 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 28 Apr 2012 10:27:07 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Date: Sat, 28 Apr 2012 19:26:41 +0200 Message-Id: <1335634011-9104-2-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1335634011-9104-1-git-send-email-pali.rohar@gmail.com> References: <1335634011-9104-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Cc: marcel@mesa.nl, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [U-Boot] [PATCH v2 01/11] 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 v1: - Rebased on u-boot master 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 | 60 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/README b/README index 43074cf..60ad9c2 100644 --- a/README +++ b/README @@ -3687,6 +3687,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 599547d..0f3c97b 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -42,6 +42,10 @@ DECLARE_GLOBAL_DATA_PTR; defined(CONFIG_INITRD_TAG) || \ defined(CONFIG_SERIAL_TAG) || \ defined(CONFIG_REVISION_TAG) + #define CONFIG_SETUP_ANY_TAG +#endif + +#ifdef CONFIG_SETUP_ANY_TAG static struct tag *params; #endif @@ -106,11 +110,7 @@ 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) +#ifdef CONFIG_SETUP_ANY_TAG static void setup_start_tag (bd_t *bd) { params = (struct tag *)bd->bi_boot_params; @@ -217,11 +217,7 @@ void setup_revision_tag(struct tag **in_params) } #endif -#if defined(CONFIG_SETUP_MEMORY_TAGS) || \ - defined(CONFIG_CMDLINE_TAG) || \ - defined(CONFIG_INITRD_TAG) || \ - defined(CONFIG_SERIAL_TAG) || \ - defined(CONFIG_REVISION_TAG) +#ifdef CONFIG_SETUP_ANY_TAG static void setup_end_tag(bd_t *bd) { params->hdr.tag = ATAG_NONE; @@ -280,13 +276,23 @@ static void boot_prep_linux(bootm_headers_t *images) } else #endif { -#if defined(CONFIG_SETUP_MEMORY_TAGS) || \ - defined(CONFIG_CMDLINE_TAG) || \ - defined(CONFIG_INITRD_TAG) || \ - defined(CONFIG_SERIAL_TAG) || \ - defined(CONFIG_REVISION_TAG) + char *atagaddr = getenv("atagaddr"); debug("using: ATAGS\n"); - setup_start_tag(gd->bd); + + if (atagaddr) + gd->bd->bi_boot_params = simple_strtoul(atagaddr, NULL, 16); + + if (gd->bd->bi_boot_params) { + printf("Using existing atags at %#lx\n", gd->bd->bi_boot_params); + + params = (struct tag *) gd->bd->bi_boot_params; + while (params->hdr.size > 0) + params = tag_next(params); + } else { +#ifdef CONFIG_SETUP_ANY_TAG + setup_start_tag(gd->bd); +#endif + } #ifdef CONFIG_SERIAL_TAG setup_serial_tag(¶ms); #endif @@ -297,18 +303,28 @@ static void boot_prep_linux(bootm_headers_t *images) setup_revision_tag(¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS - setup_memory_tags(gd->bd); + if (!atagaddr) + setup_memory_tags(gd->bd); #endif #ifdef CONFIG_INITRD_TAG if (images->rd_start && images->rd_end) setup_initrd_tag(gd->bd, images->rd_start, images->rd_end); #endif - setup_end_tag(gd->bd); -#else /* all tags */ - printf("FDT and ATAGS support not compiled in - hanging\n"); - hang(); -#endif /* all tags */ + if (atagaddr) { + if (params->hdr.size > 0) + setup_end_tag(gd->bd); + } else { +#ifdef CONFIG_SETUP_ANY_TAG + setup_end_tag(gd->bd); +#endif + } +#ifndef CONFIG_SETUP_ANY_TAG + if (!atagaddr) { + printf("FDT and ATAGS support not compiled in - hanging\n"); + hang(); + } +#endif } }