diff mbox

[U-Boot,RFC,1/2] arm: Added prep subcommand support to bootm

Message ID 1310124687-11494-1-git-send-email-simonschwarzcor@gmail.com
State Superseded
Headers show

Commit Message

Simon Schwarz July 8, 2011, 11:31 a.m. UTC
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(-)

Comments

Simon Schwarz July 8, 2011, 11:35 a.m. UTC | #1
Sorry, this was meant in-reply to this  message: [PATCH] arm: Adds
saving of Kernel boot args to NAND flash

2011/7/8 Simon Schwarz <simonschwarzcor@googlemail.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
>
>
diff mbox

Patch

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