mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 07/14] bootm: handle initrds inline
Date: Tue, 6 Dec 2011 16:08:20 +0100	[thread overview]
Message-ID: <20111206150820.GD32515@game.jcrosoft.org> (raw)
In-Reply-To: <1322467340-10596-8-git-send-email-s.hauer@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 3356 bytes --]

On 09:02 Mon 28 Nov     , Sascha Hauer wrote:
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  commands/bootm.c |   78 +++++++++++++++++++----------------------------------
>  1 files changed, 28 insertions(+), 50 deletions(-)
> 
> diff --git a/commands/bootm.c b/commands/bootm.c
> index 823d387..17139f7 100644
> --- a/commands/bootm.c
> +++ b/commands/bootm.c
> @@ -141,55 +141,6 @@ static struct image_handle *get_fake_image_handle(struct image_data *data, int n
>  	return handle;
>  }
>  
> -static int initrd_handler_parse_options(struct image_data *data, int opt,
> -		char *optarg)
> -{
> -	uint32_t initrd_start;
> -
> -	switch(opt) {
> -	case 'L':
> -		if (!data->initrd) {
> -			eprintf("Warning -L ingnored. Specify the initrd first\n");
> -			break;
> -		}
> -		initrd_start = simple_strtoul(optarg, NULL, 0);
> -		printf("initrd_start=0x%x\n", initrd_start);
> -		data->initrd->header.ih_load = cpu_to_uimage(initrd_start);
> -		break;
> -	case 'r':
> -		printf("use initrd %s\n", optarg);
> -		/* check for multi image @<num> */
> -		if (optarg[0] == '@') {
> -			int num = simple_strtol(optarg + 1, NULL, 0);
> -
> -			data->initrd = get_fake_image_handle(data, num);
> -		} else {
> -			data->initrd = map_image(optarg, data->verify);
> -		}
> -		if (!data->initrd)
> -			return -1;
> -		break;
> -	default:
> -		return 1;
> -	}
> -
> -	return 0;
> -}
> -
> -static struct image_handler initrd_handler = {
> -	.cmdline_options = "r:L:",
> -	.cmdline_parse = initrd_handler_parse_options,
> -	.help_string = " -r <initrd>    specify an initrd image\n"
> -		       " -L <load addr> specify initrd load address",
> -};
> -
> -static int initrd_register_image_handler(void)
> -{
> -	return register_image_handler(&initrd_handler);
> -}
> -
> -late_initcall(initrd_register_image_handler);
> -
>  static int handler_parse_options(struct image_data *data, int opt, char *optarg)
>  {
>  	struct image_handler *handler;
> @@ -216,13 +167,14 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
>  	struct image_handle *os_handle, *initrd_handle = NULL;
>  	struct image_handler *handler;
>  	struct image_data data;
> +	u32 initrd_start;
>  	char options[53]; /* worst case: whole alphabet with colons */
>  
>  	memset(&data, 0, sizeof(struct image_data));
>  	data.verify = 1;
>  
>  	/* Collect options from registered handlers */
> -	strcpy(options, "nh");
> +	strcpy(options, "nhr:L:");
>  	list_for_each_entry(handler, &handler_list, list) {
>  		if (handler->cmdline_options)
>  			strcat(options, handler->cmdline_options);
> @@ -242,6 +194,28 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
>  			}
>  
>  			return 0;
> +		case 'L':
> +			if (!data.initrd) {
> +				eprintf("Warning -L ingnored. Specify the initrd first\n");
> +				break;
> +			}
> +			initrd_start = simple_strtoul(optarg, NULL, 0);
> +			printf("initrd_start=0x%x\n", initrd_start);
> +			data.initrd->header.ih_load = cpu_to_uimage(initrd_start);
> +			break;
> +		case 'r':
> +			printf("use initrd %s\n", optarg);
> +			/* check for multi image @<num> */
> +			if (optarg[0] == '@') {
> +				int num = simple_strtol(optarg + 1, NULL, 0);
> +
> +				data.initrd = get_fake_image_handle(&data, num);
this can not work

get_fake_image_handle expect the uImage is mapped

attached patch fix it

Best Regards,
J.

[-- Attachment #2: 0001-bootm-fix-initrd-multi-image-support.patch --]
[-- Type: text/x-diff, Size: 1864 bytes --]

From b7b35f53686f5ee0e35caf195adc97b88d393c71 Mon Sep 17 00:00:00 2001
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Date: Tue, 6 Dec 2011 23:09:37 +0800
Subject: [PATCH 1/1] bootm: fix initrd multi-image support

the -L option use get_fake_image_handle expect the uImage is mapped

so move is after the uImage is mapped

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 commands/bootm.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/commands/bootm.c b/commands/bootm.c
index d796914..c7ce42e 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -141,6 +141,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
 	struct image_handler *handler;
 	struct image_data data;
 	int ret = 1;
+	int initrd_num = 0;
 	char options[53]; /* worst case: whole alphabet with colons */
 
 	memset(&data, 0, sizeof(struct image_data));
@@ -175,14 +176,12 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
 			printf("use initrd %s\n", optarg);
 			/* check for multi image @<num> */
 			if (optarg[0] == '@') {
-				int num = simple_strtol(optarg + 1, NULL, 0);
-
-				data.initrd = get_fake_image_handle(&data, num);
+				initrd_num = simple_strtol(optarg + 1, NULL, 0);
 			} else {
 				data.initrd = map_image(optarg, data.verify);
+				if (!data.initrd)
+					goto err_out;
 			}
-			if (!data.initrd)
-				goto err_out;
 			break;
 		default:
 			break;
@@ -201,6 +200,12 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
 
 	os_header = &os_handle->header;
 
+	if (initrd_num) {
+		data.initrd = get_fake_image_handle(&data, initrd_num);
+		if (!data.initrd)
+			goto err_out;
+	}
+
 	if (image_get_arch(os_header) != IH_ARCH) {
 		printf("Unsupported Architecture 0x%x\n",
 		       image_get_arch(os_header));
-- 
1.7.7


[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2011-12-06 15:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-28  8:02 bootm work Sascha Hauer
2011-11-28  8:02 ` [PATCH 01/14] bootm: remove dead code Sascha Hauer
2011-11-28  8:02 ` [PATCH 02/14] factor out iminfo command Sascha Hauer
2011-11-28  8:02 ` [PATCH 03/14] compile in simple_strtoull Sascha Hauer
2011-11-28  8:02 ` [PATCH 04/14] introduce some env helpers Sascha Hauer
2011-11-28  8:02 ` [PATCH 05/14] armlinux: cleanup linux vars Sascha Hauer
2011-11-28 11:03   ` Jean-Christophe PLAGNIOL-VILLARD
2011-11-28 11:12     ` Sascha Hauer
2011-11-29  4:38       ` Jean-Christophe PLAGNIOL-VILLARD
2011-11-29  7:23         ` Robert Schwebel
2011-11-29  8:13           ` Jean-Christophe PLAGNIOL-VILLARD
2011-11-29 10:09             ` Sascha Hauer
2011-11-28  8:02 ` [PATCH 06/14] ARM bootm: remove now obsolete args Sascha Hauer
2011-11-28  8:02 ` [PATCH 07/14] bootm: handle initrds inline Sascha Hauer
2011-12-06 15:08   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2011-12-07  9:19     ` Sascha Hauer
2011-12-07 13:26       ` Jean-Christophe PLAGNIOL-VILLARD
2011-11-28  8:02 ` [PATCH 08/14] bootm: remove image handler options Sascha Hauer
2011-11-28  8:02 ` [PATCH 09/14] bootm: fix various memory leaks Sascha Hauer
2011-11-28  8:02 ` [PATCH 10/14] bootm: do not require -L after -r Sascha Hauer
2011-11-28  8:02 ` [PATCH 11/14] bootm: fix typo, update help str Sascha Hauer
2011-11-28 11:00   ` Jean-Christophe PLAGNIOL-VILLARD
2011-11-28  8:02 ` [PATCH 12/14] bootm relocate_image: honour load_address Sascha Hauer
2011-11-28  8:02 ` [PATCH 13/14] bootm: push relocate_image up to the generic command Sascha Hauer
2011-11-28  8:02 ` [PATCH 14/14] bootm: use initrd_address and initrd_size Sascha Hauer

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=20111206150820.GD32515@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox