[U-Boot] [u-boot PATCH] arm, lib/bootm.c: Exclude HIGHMEM from being used by u-boot

David Long dave.long at linaro.org
Fri Aug 19 19:57:26 CEST 2011


Reserve any memory above 768MB to prevent u-boot from relocating fdt or initrd
data into memory that Linux cannot reference during early boot. Code taken (with
modifications) from the powerpc bootm.c.

Signed-off-by: David A. Long <dave.long at linaro.org>
---
 arch/arm/lib/bootm.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 802e833..437ef35 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -32,6 +32,10 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifndef CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE
+#define CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE	(768*1024*1024)
+#endif
+
 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
     defined (CONFIG_CMDLINE_TAG) || \
     defined (CONFIG_INITRD_TAG) || \
@@ -60,7 +64,25 @@ static int bootm_linux_fdt(int machid, bootm_headers_t *images);
 
 void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp;
+	phys_size_t bootm_size;
+	ulong size, sp, bootmap_base;
+
+	bootmap_base = getenv_bootm_low();
+	bootm_size = getenv_bootm_size();
+
+#ifdef DEBUG
+	if (((u64)bootmap_base + bootm_size) >
+	    (CONFIG_SYS_SDRAM_BASE + (u64) gd->ram_size))
+		puts("WARNING: bootm_low + bootm_size exceed total memory\n");
+#endif
+
+	size = min(bootm_size, CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE);
+
+	if (size < bootm_size) {
+		ulong base = bootmap_base + size;
+		printf("WARNING: adjusting available memory to %lx\n", size);
+		lmb_reserve(lmb, base, bootm_size - size);
+	}
 
 	/*
 	 * Booting a (Linux) kernel image
-- 
1.7.4.1





More information about the U-Boot mailing list