[U-Boot] [PATCH v2 4/5] bootm: Clean up bootz_setup() function

Simon Glass sjg at chromium.org
Thu Jul 4 22:26:10 CEST 2013


This function has no prototype in the headers and passes void * around, thus
requiring several casts. Tidy this up.

- Add new patch to clean up bootz_setup() function

Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2: None

 arch/arm/lib/bootm.c | 14 ++++++++------
 common/cmd_bootm.c   |  8 +++-----
 include/image.h      | 11 +++++++++++
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index b22fbc9..0325d08 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -300,21 +300,23 @@ struct zimage_header {
 
 #define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
 
-int bootz_setup(void *image, void **start, void **end)
+int bootz_setup(ulong image, ulong *start, ulong *end)
 {
-	struct zimage_header *zi = (struct zimage_header *)image;
+	struct zimage_header *zi;
 
+	zi = (struct zimage_header *)map_sysmem(image, 0);
 	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
 		puts("Bad Linux ARM zImage magic!\n");
 		return 1;
 	}
 
-	*start = (void *)zi->zi_start;
-	*end = (void *)zi->zi_end;
+	*start = zi->zi_start;
+	*end = zi->zi_end;
 
-	debug("Kernel image @ 0x%08x [ 0x%08x - 0x%08x ]\n",
-		(uint32_t)image, (uint32_t)*start, (uint32_t)*end);
+	printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n", image, *start,
+	      *end);
 
 	return 0;
 }
+
 #endif	/* CONFIG_CMD_BOOTZ */
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 63cbfae..b89d6ad 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -1737,15 +1737,13 @@ static int do_bootm_integrity(int flag, int argc, char * const argv[],
 
 #ifdef CONFIG_CMD_BOOTZ
 
-static int __bootz_setup(void *image, void **start, void **end)
+int __weak bootz_setup(ulong image, ulong *start, ulong *end)
 {
 	/* Please define bootz_setup() for your platform */
 
 	puts("Your platform's zImage format isn't supported yet!\n");
 	return -1;
 }
-int bootz_setup(void *image, void **start, void **end)
-	__attribute__((weak, alias("__bootz_setup")));
 
 /*
  * zImage booting support
@@ -1754,7 +1752,7 @@ static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
 			char * const argv[], bootm_headers_t *images)
 {
 	int ret;
-	void *zi_start, *zi_end;
+	ulong zi_start, zi_end;
 
 	ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
 			      images, 1);
@@ -1770,7 +1768,7 @@ static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
 			images->ep);
 	}
 
-	ret = bootz_setup((void *)images->ep, &zi_start, &zi_end);
+	ret = bootz_setup(images->ep, &zi_start, &zi_end);
 	if (ret != 0)
 		return 1;
 
diff --git a/include/image.h b/include/image.h
index a7b93db..9c3e46f 100644
--- a/include/image.h
+++ b/include/image.h
@@ -662,6 +662,17 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
  */
 int image_setup_linux(bootm_headers_t *images);
 
+/**
+ * bootz_setup() - Extract stat and size of a Linux xImage
+ *
+ * @image: Address of image
+ * @start: Returns start address of image
+ * @end : Returns end address of image
+ * @return 0 if OK, 1 if the image was not recognised
+ */
+int bootz_setup(ulong image, ulong *start, ulong *end);
+
+
 /*******************************************************************/
 /* New uImage format specific code (prefixed with fit_) */
 /*******************************************************************/
-- 
1.8.3



More information about the U-Boot mailing list