Patchwork [U-Boot,v2,2/3] image: Support FDTs already loaded at their load address

login
register
mail settings
Submitter Stephen Warren
Date Nov. 1, 2011, 4:28 p.m.
Message ID <1320164902-24190-2-git-send-email-swarren@nvidia.com>
Download mbox | patch
Permalink /patch/123095/
State Accepted
Commit e37ae40e9dec9af417c19de72f76becebf160730
Headers show

Comments

Stephen Warren - Nov. 1, 2011, 4:28 p.m.
boot_get_fdt() expects a uImage-wrapped FDT to be loaded to a staging
location, and then memmove()s it to the load address specified in the
header. This change enhances boot_get_fdt() to detect when the image has
already been loaded to the correct address, and skip this memmove(). The
detection algorithm was written to match the equivalent for the kernel;
see bootm_load_os()'s IH_COMP_NONE case.

v2: New patch

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 common/image.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
Wolfgang Denk - March 6, 2012, 9:18 p.m.
Dear Stephen Warren,

In message <1320164902-24190-2-git-send-email-swarren@nvidia.com> you wrote:
> boot_get_fdt() expects a uImage-wrapped FDT to be loaded to a staging
> location, and then memmove()s it to the load address specified in the
> header. This change enhances boot_get_fdt() to detect when the image has
> already been loaded to the correct address, and skip this memmove(). The
> detection algorithm was written to match the equivalent for the kernel;
> see bootm_load_os()'s IH_COMP_NONE case.
> 
> v2: New patch
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  common/image.c |   13 ++++++++++---
>  1 files changed, 10 insertions(+), 3 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Patch

diff --git a/common/image.c b/common/image.c
index b773505..7ce5d33 100644
--- a/common/image.c
+++ b/common/image.c
@@ -1371,7 +1371,7 @@  int boot_get_fdt(int flag, int argc, char * const argv[],
 	const image_header_t *fdt_hdr;
 	ulong		fdt_addr;
 	char		*fdt_blob = NULL;
-	ulong		image_start, image_end;
+	ulong		image_start, image_data, image_end;
 	ulong		load_start, load_end;
 #if defined(CONFIG_FIT)
 	void		*fit_hdr;
@@ -1479,21 +1479,28 @@  int boot_get_fdt(int flag, int argc, char * const argv[],
 			 * make sure we don't overwrite initial image
 			 */
 			image_start = (ulong)fdt_hdr;
+			image_data = (ulong)image_get_data(fdt_hdr);
 			image_end = image_get_image_end(fdt_hdr);
 
 			load_start = image_get_load(fdt_hdr);
 			load_end = load_start + image_get_data_size(fdt_hdr);
 
+			if (load_start == image_start ||
+			    load_start == image_data) {
+				fdt_blob = (char *)image_data;
+				break;
+			}
+
 			if ((load_start < image_end) && (load_end > image_start)) {
 				fdt_error("fdt overwritten");
 				goto error;
 			}
 
 			debug("   Loading FDT from 0x%08lx to 0x%08lx\n",
-					image_get_data(fdt_hdr), load_start);
+					image_data, load_start);
 
 			memmove((void *)load_start,
-					(void *)image_get_data(fdt_hdr),
+					(void *)image_data,
 					image_get_data_size(fdt_hdr));
 
 			fdt_blob = (char *)load_start;