From patchwork Fri Jul 8 11:37:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Schwarz X-Patchwork-Id: 103828 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 19F8E1007D1 for ; Fri, 8 Jul 2011 21:38:15 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F1BD8280B2; Fri, 8 Jul 2011 13:38:12 +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 fRlh96zZH+cK; Fri, 8 Jul 2011 13:38:12 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5BB4328083; Fri, 8 Jul 2011 13:38:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8BF1428083 for ; Fri, 8 Jul 2011 13:38:09 +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 T5YfrOznCfnm for ; Fri, 8 Jul 2011 13:38:09 +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-fx0-f50.google.com (mail-fx0-f50.google.com [209.85.161.50]) by theia.denx.de (Postfix) with ESMTPS id 61EBC28077 for ; Fri, 8 Jul 2011 13:38:07 +0200 (CEST) Received: by fxh2 with SMTP id 2so1544630fxh.23 for ; Fri, 08 Jul 2011 04:38:07 -0700 (PDT) Received: by 10.223.132.210 with SMTP id c18mr1092829fat.97.1310125087453; Fri, 08 Jul 2011 04:38:07 -0700 (PDT) Received: from localhost.localdomain (DSL01.212.114.252.242.ip-pool.NEFkom.net [212.114.252.242]) by mx.google.com with ESMTPS id b13sm7327017fab.36.2011.07.08.04.38.06 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 08 Jul 2011 04:38:06 -0700 (PDT) From: Simon Schwarz To: u-boot@lists.denx.de, simonschwarzcor@gmail.com Date: Fri, 8 Jul 2011 13:37:36 +0200 Message-Id: <1310125056-11643-1-git-send-email-simonschwarzcor@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1309872039-15316-1-git-send-email-simonschwarzcor@gmail.com> References: <1309872039-15316-1-git-send-email-simonschwarzcor@gmail.com> Organization: Corscience GmbH & Co. KG Subject: [U-Boot] [RFC 1/2] arm: Added prep subcommand support to bootm X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 Adds prep subcommand to bootm implementation of ARM. When bootm is called prep the function stops right after ATAGS creation and before announce_and_cleanup. This is used in savebp command Signed-off-by: Simon Schwarz --- Ok second RFC! I know that there are many style problems - but I don't have the time before weekend/at the weekend to fix them. So please no close inspection just a comment on the way how the patch is done. I will address the styleproblems on Monday! Thanks, and have a nive weekend! Simon --- arch/arm/lib/bootm.c | 107 +++++++++++++++++++++++++++----------------------- 1 files changed, 58 insertions(+), 49 deletions(-) diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 802e833..58334a2 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -1,4 +1,7 @@ -/* +/* Copyright (C) 2011 + * Corscience GmbH & Co. KG - Simon Schwarz + * - Added prep subcommand support + * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH * Marius Groeger @@ -55,7 +58,7 @@ static struct tag *params; static ulong get_sp(void); #if defined(CONFIG_OF_LIBFDT) -static int bootm_linux_fdt(int machid, bootm_headers_t *images); +static int bootm_linux_fdt(int machid, bootm_headers_t *images, int flag); #endif void arch_lmb_reserve(struct lmb *lmb) @@ -104,57 +107,61 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) char *commandline = getenv ("bootargs"); #endif - if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) - return 1; - - s = getenv ("machid"); - if (s) { - machid = simple_strtoul (s, NULL, 16); - printf ("Using machid 0x%x from environment\n", machid); - } + if ((flag != 0) && (flag != BOOTM_STATE_OS_GO || + flag != BOOTM_STATE_OS_PREP)) + return 1; /* subcommand not implemented */ + else + if((flag == 0) || flag == BOOTM_STATE_OS_PREP) { + s = getenv ("machid"); + if (s) { + machid = simple_strtoul (s, NULL, 16); + printf ("Using machid 0x%x from environment\n", machid); + } - show_boot_progress (15); + show_boot_progress (15); #ifdef CONFIG_OF_LIBFDT - if (images->ft_len) - return bootm_linux_fdt(machid, images); + if (images->ft_len) + return bootm_linux_fdt(machid, images, flag); #endif - kernel_entry = (void (*)(int, int, uint))images->ep; + kernel_entry = (void (*)(int, int, uint))images->ep; - debug ("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) kernel_entry); + 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); + setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG - setup_serial_tag (¶ms); + setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG - setup_revision_tag (¶ms); + setup_revision_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS - setup_memory_tags (bd); + setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG - setup_commandline_tag (bd, commandline); + setup_commandline_tag (bd, commandline); #endif #ifdef CONFIG_INITRD_TAG - if (images->rd_start && images->rd_end) - setup_initrd_tag (bd, images->rd_start, images->rd_end); + if (images->rd_start && images->rd_end) + setup_initrd_tag (bd, images->rd_start, images->rd_end); #endif - setup_end_tag(bd); + setup_end_tag(bd); #endif + } - announce_and_cleanup(); - - kernel_entry(0, machid, bd->bi_boot_params); - /* does not return */ + if(flag == 0 || flag == BOOTM_STATE_OS_GO) { + announce_and_cleanup(); + kernel_entry(0, machid, bd->bi_boot_params); + /* does not return */ + } return 1; } @@ -174,7 +181,7 @@ static int fixup_memory_node(void *blob) return fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS); } -static int bootm_linux_fdt(int machid, bootm_headers_t *images) +static int bootm_linux_fdt(int machid, bootm_headers_t *images, int flag) { ulong rd_len; void (*kernel_entry)(int zero, int dt_machid, void *dtblob); @@ -185,34 +192,36 @@ static int bootm_linux_fdt(int machid, bootm_headers_t *images) struct lmb *lmb = &images->lmb; int ret; - kernel_entry = (void (*)(int, int, void *))images->ep; - - boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); - - rd_len = images->rd_end - images->rd_start; - ret = boot_ramdisk_high(lmb, images->rd_start, rd_len, - initrd_start, initrd_end); - if (ret) - return ret; + if((flag == 0) || flag == BOOTM_STATE_OS_PREP) { + kernel_entry = (void (*)(int, int, void *))images->ep; - ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); - if (ret) - return ret; + boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); - debug("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) kernel_entry); + rd_len = images->rd_end - images->rd_start; + ret = boot_ramdisk_high(lmb, images->rd_start, rd_len, + initrd_start, initrd_end); + if (ret) + return ret; - fdt_chosen(*of_flat_tree, 1); + ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); + if (ret) + return ret; - fixup_memory_node(*of_flat_tree); + debug("## Transferring control to Linux (at address %08lx) ...\n", + (ulong) kernel_entry); - fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1); + fdt_chosen(*of_flat_tree, 1); - announce_and_cleanup(); + fixup_memory_node(*of_flat_tree); - kernel_entry(0, machid, *of_flat_tree); - /* does not return */ + fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1); + } + if(flag == 0 || flag == BOOTM_STATE_OS_GO) { + announce_and_cleanup(); + kernel_entry(0, machid, *of_flat_tree); + /* does not return */ + } return 1; } #endif