All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Schwarz <simonschwarzcor@googlemail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 1/2] arm: Added prep subcommand support to bootm
Date: Fri,  8 Jul 2011 13:37:36 +0200	[thread overview]
Message-ID: <1310125056-11643-1-git-send-email-simonschwarzcor@gmail.com> (raw)
In-Reply-To: <1309872039-15316-1-git-send-email-simonschwarzcor@gmail.com>

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 <simonschwarzcor@gmail.com>
---
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 <schwarz@corscience.de>
+ *  - Added prep subcommand support
+ *
  * (C) Copyright 2002
  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  * Marius Groeger <mgroeger@sysgo.de>
@@ -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 (&params);
+		setup_serial_tag (&params);
 #endif
 #ifdef CONFIG_REVISION_TAG
-	setup_revision_tag (&params);
+		setup_revision_tag (&params);
 #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
-- 
1.7.4.1

  parent reply	other threads:[~2011-07-08 11:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 13:20 [U-Boot] [PATCH] arm: Adds saving of Kernel boot args to NAND flash Simon Schwarz
2011-07-05 19:36 ` Scott Wood
2011-07-06  7:42   ` Simon Schwarz
2011-07-06 17:27     ` Scott Wood
2011-07-07 15:50       ` Simon Schwarz
2011-07-07 16:34         ` Scott Wood
2011-07-08  7:53           ` Simon Schwarz
2011-07-08 16:03             ` Scott Wood
2011-07-06 11:54   ` Simon Schwarz
2011-07-06 18:55 ` Albert ARIBAUD
2011-07-08 11:31 ` [U-Boot] [RFC 1/2] arm: Added prep subcommand support to bootm Simon Schwarz
2011-07-08 11:31   ` [U-Boot] [RFC 2/2] arm: Adds saving of Kernel boot args to NAND flash Simon Schwarz
2011-07-08 11:35   ` [U-Boot] [RFC 1/2] arm: Added prep subcommand support to bootm Simon Schwarz
2011-07-08 11:37 ` Simon Schwarz [this message]
2011-07-08 12:34   ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1310125056-11643-1-git-send-email-simonschwarzcor@gmail.com \
    --to=simonschwarzcor@googlemail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.