Skip to contentSkip to conversation

unbreak bootm

PATCH In review Eric Bénard 3 participants 7 messages Oct 13, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unbreak bootm

commit a3c1e5d888d0ee317ffc7635694684bb71213c9c was not tested as all the tests are wrong and it breaks bootm

---
 commands/bootm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
commands/bootm.c +3 -3
index 83d36d3..666deeb 100644
@@ -167,7 +167,7 @@ struct image_handle *map_image(const char *filename, int verify)
 		goto err_out;
 	}
 
-	if (image_check_magic(header)) {
+	if (! image_check_magic(header)) {
 		puts ("Bad Magic Number\n");
 		goto err_out;
 	}
@@ -332,7 +332,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
 
 	os_header = &os_handle->header;
 
-	if (image_check_arch(os_header, IH_ARCH)) {
+	if (! image_check_arch(os_header, IH_ARCH)) {
 		printf("Unsupported Architecture 0x%x\n",
 		       image_get_arch(os_header));
 		goto err_out;
@@ -409,7 +409,7 @@ static int image_info (ulong addr)
 	/* Copy header so we can blank CRC field for re-calculation */
 	memmove (&header, (char *)addr, image_get_header_size());
 
-	if (image_check_magic(hdr)) {
+	if (! image_check_magic(hdr)) {
 		puts ("   Bad Magic Number\n");
 		return 1;
 	}
Signature · 7 lines
1.7.0.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 2 lines · Eric Bénard

commit a3c1e5d888d0ee317ffc7635694684bb71213c9c was not tested as all the tests are wrong and it breaks bootm

I test it but no see it

Quoted 11 lines
---
 commands/bootm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
commands/bootm.c +0 -0
index 83d36d3..666deeb 100644

commands/bootm.c struct image_handle *map_image(const char *filename, int verify) · line 170

Quoted 5 lines
commands/bootm.c +1 -1
@@ -167,7 +167,7 @@ struct image_handle *map_image(const char *filename, int verify)
 		goto err_out;
 	}
 
-	if (image_check_magic(header)) {
+	if (! image_check_magic(header)) {

no space after !

commands/bootm.c struct image_handle *map_image(const char *filename, int verify) · line 173

Quoted 3 lines
commands/bootm.c +0 -0
 		puts ("Bad Magic Number\n");
 		goto err_out;
 	}

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#2 lore raw

Hi Jean-Christophe,

Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 2 lines · Eric Bénard

commit a3c1e5d888d0ee317ffc7635694684bb71213c9c was not tested as all the tests are wrong and it breaks bootm

Sorry this was not meant to be offensive, just spent to much time on this so my comment may be a little bit to agressive.

Quoted 1 line

I test it but no see it

How do you test this ? In the present case it prevents to boot a uImage.

I think some other tests may be concerned also but I didn't have time to check everywhere.

Will resend with the space fixed.

Eric

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
In reply to Eric Bénard
Quoted 3 lines · Eric Bénard

commit a3c1e5d888d0ee317ffc7635694684bb71213c9c was not tested as all the tests are wrong and it breaks bootm

:-(

How about the following patch (currently untested)?

[PATCH] image: remove confusing image_check_* functions

The function names do not make it clear what return value is expected and do not save a single line of code. Put the code inline and unbreak the wrong checks introduced with a3c1e5d888d0ee317ffc7635694684bb71213c9c.

---
 arch/arm/lib/armlinux.c        |    2 +-
 arch/m68k/lib/m68k-linuxboot.c |    2 +-
 arch/ppc/lib/ppclinux.c        |    2 +-
 commands/bootm.c               |    8 +++---
 common/image.c                 |    7 +++--
 include/image.h                |   55 ----------------------------------------
 6 files changed, 11 insertions(+), 65 deletions(-)
arch/arm/lib/armlinux.c +1 -1
index 7c2cbf9..f690fef 100644
@@ -212,7 +212,7 @@ int do_bootm_linux(struct image_data *data)
 	void (*theKernel)(int zero, int arch, void *params);
 	image_header_t *os_header = &data->os->header;
 
-	if (image_check_type(os_header, IH_TYPE_MULTI)) {
+	if (image_get_type(os_header) == IH_TYPE_MULTI) {
 		printf("Multifile images not handled at the moment\n");
 		return -1;
 	}
arch/m68k/lib/m68k-linuxboot.c +1 -1
index e5e90a8..144d5a3 100644
@@ -109,7 +109,7 @@ static int do_bootm_linux(struct image_data *data)
 	const char *commandline = getenv ("bootargs");
 	uint32_t loadaddr,loadsize;
 
-	if (image_check_type(os_header, IH_TYPE_MULTI)) {
+	if (image_get_type(os_header) == IH_TYPE_MULTI) {
 		printf("Multifile images not handled at the moment\n");
 		return -1;
 	}
arch/ppc/lib/ppclinux.c +1 -1
index 5ee908d..fc22a87 100644
@@ -45,7 +45,7 @@ static int do_bootm_linux(struct image_data *idata)
 	printf("entering %s: os_header: %p initrd_header: %p oftree: %s\n",
 			__FUNCTION__, os_header, initrd_header, idata->oftree);
 
-	if (image_check_type(os_header, IH_TYPE_MULTI)) {
+	if (image_get_type(os_header) == IH_TYPE_MULTI) {
 		unsigned long *data = (unsigned long *)(idata->os->data);
 		unsigned long len1 = 0, len2 = 0;
 
commands/bootm.c +4 -4
index 83d36d3..a7cbfb9 100644
@@ -167,7 +167,7 @@ struct image_handle *map_image(const char *filename, int verify)
 		goto err_out;
 	}
 
-	if (image_check_magic(header)) {
+	if (image_get_magic(header) != IH_MAGIC) {
 		puts ("Bad Magic Number\n");
 		goto err_out;
 	}
@@ -332,7 +332,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
 
 	os_header = &os_handle->header;
 
-	if (image_check_arch(os_header, IH_ARCH)) {
+	if (image_get_arch(os_header) != IH_ARCH) {
 		printf("Unsupported Architecture 0x%x\n",
 		       image_get_arch(os_header));
 		goto err_out;
@@ -350,7 +350,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
 
 	/* loop through the registered handlers */
 	list_for_each_entry(handler, &handler_list, list) {
-		if (image_check_os(os_header, handler->image_type)) {
+		if (image_get_os(hdr) == handler->image_type) {
 			handler->bootm(&data);
 			printf("handler returned!\n");
 			goto err_out;
@@ -409,7 +409,7 @@ static int image_info (ulong addr)
 	/* Copy header so we can blank CRC field for re-calculation */
 	memmove (&header, (char *)addr, image_get_header_size());
 
-	if (image_check_magic(hdr)) {
+	if (image_get_magic(hdr) != IH_MAGIC) {
 		puts ("   Bad Magic Number\n");
 		return 1;
 	}
common/image.c +4 -3
index 104446a..2b2c410 100644
@@ -266,6 +266,7 @@ void image_print_contents(const void *ptr)
 {
 	const image_header_t *hdr = (const image_header_t *)ptr;
 	const char *p;
+	int type;
 
 #ifdef __BAREBOX__
 	p = "   ";
@@ -285,8 +286,8 @@ void image_print_contents(const void *ptr)
 	printf ("%sLoad Address: %08x\n", p, image_get_load(hdr));
 	printf ("%sEntry Point:  %08x\n", p, image_get_ep(hdr));
 
-	if (image_check_type(hdr, IH_TYPE_MULTI) ||
-			image_check_type(hdr, IH_TYPE_SCRIPT)) {
+	type = image_get_type(hdr);
+	if (type != IH_TYPE_MULTI || type != IH_TYPE_SCRIPT) {
 		int i;
 		ulong data, len;
 		ulong count = image_multi_count(hdr);
@@ -298,7 +299,7 @@ void image_print_contents(const void *ptr)
 			printf("%s   Image %d: ", p, i);
 			image_print_size(len);
 
-			if (image_check_type(hdr, IH_TYPE_SCRIPT) && i > 0) {
+			if (image_get_type(hdr) != IH_TYPE_SCRIPT && i > 0) {
 				/*
 				 * the user may need to know offsets
 				 * if planning to do something with
include/image.h +0 -55

61 lines not on this page · raw message

Signature · 13 lines
1.7.2.3


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

Hi Sascha,

Quoted 9 lines · Sascha Hauer
Quoted 3 lines · Eric Bénard

commit a3c1e5d888d0ee317ffc7635694684bb71213c9c was not tested as all the tests are wrong and it breaks bootm

:-(

How about the following patch (currently untested)?

works with the attached fix.

Eric

From 214d68524f90e4d7f223d1bf05b49e9958bd3c68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eric=20B=C3=A9nard?= <[email protected]>
Date: Wed, 13 Oct 2010 14:27:19 +0200
Subject: [PATCH] fix Sascha's patch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 commands/bootm.c  |    2 +-
 common/image.c    |    2 +-
 scripts/mkimage.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
commands/bootm.c +1 -1
index a7cbfb9..14475c7 100644
@@ -350,7 +350,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
 
 	/* loop through the registered handlers */
 	list_for_each_entry(handler, &handler_list, list) {
-		if (image_get_os(hdr) == handler->image_type) {
+		if (image_get_os(os_header) == handler->image_type) {
 			handler->bootm(&data);
 			printf("handler returned!\n");
 			goto err_out;
common/image.c +1 -1
index 2b2c410..a4c8b95 100644
@@ -287,7 +287,7 @@ void image_print_contents(const void *ptr)
 	printf ("%sEntry Point:  %08x\n", p, image_get_ep(hdr));
 
 	type = image_get_type(hdr);
-	if (type != IH_TYPE_MULTI || type != IH_TYPE_SCRIPT) {
+	if (type == IH_TYPE_MULTI || type == IH_TYPE_SCRIPT) {
 		int i;
 		ulong data, len;
 		ulong count = image_multi_count(hdr);
scripts/mkimage.c +1 -1
index f6cbb1c..40a3483 100644
@@ -224,7 +224,7 @@ NXTARG:		;
 		 */
 		memcpy (hdr, ptr, sizeof(image_header_t));
 
-		if (image_check_magic(hdr)) {
+		if (image_get_magic(hdr) != IH_MAGIC) {
 			fprintf (stderr,
 				"%s: Bad Magic Number: \"%s\" is no valid image\n",
 				cmdname, imagefile);
Signature · 1 line
1.7.0.4

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#5 lore raw
Quoted 8 lines · Eric Bénard

Hi Sascha,

Quoted 5 lines · Sascha Hauer
Quoted 3 lines · Eric Bénard

commit a3c1e5d888d0ee317ffc7635694684bb71213c9c was not tested as all the tests are wrong and it breaks bootm

Quoted 5 lines
Quoted 4 lines

:-(

How about the following patch (currently untested)?

works with the attached fix.

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#6 lore raw
In reply to Eric Bénard
Quoted 8 lines · Eric Bénard

Hi Sascha,

Quoted 5 lines · Sascha Hauer
Quoted 3 lines · Eric Bénard

commit a3c1e5d888d0ee317ffc7635694684bb71213c9c was not tested as all the tests are wrong and it breaks bootm

Quoted 5 lines
Quoted 4 lines

:-(

How about the following patch (currently untested)?

works with the attached fix.

Ok, thanks for testing and fixing. I squashed the fixes into my patch and added it to next.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox