diff options
Diffstat (limited to 'patches/barebox-2013.04.0/0001-arm-start-improve-memory-layout-calculation.patch')
-rw-r--r-- | patches/barebox-2013.04.0/0001-arm-start-improve-memory-layout-calculation.patch | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/patches/barebox-2013.04.0/0001-arm-start-improve-memory-layout-calculation.patch b/patches/barebox-2013.04.0/0001-arm-start-improve-memory-layout-calculation.patch new file mode 100644 index 0000000..8c6854d --- /dev/null +++ b/patches/barebox-2013.04.0/0001-arm-start-improve-memory-layout-calculation.patch @@ -0,0 +1,95 @@ +From d7df89aff4ba68d8bb57cbf6145c5cd5f201f704 Mon Sep 17 00:00:00 2001 +From: Jan Luebbe <jlu@pengutronix.de> +Date: Fri, 15 Mar 2013 12:40:55 +0100 +Subject: [PATCH 1/8] arm: start: improve memory layout calculation + +On AM335x a barebox MLO is placed at the base of the usable SRAM range. +When running without SDRAM, we should be able to pass the SRAM range +to barebox_arm_entry. + +First we check if the ends of the memory range lie in the barebox image +and reduce the range in these cases. Then we check if the image splits +the memory range in two and choose to use the larger one. + +Signed-off-by: Jan Luebbe <jlu@pengutronix.de> +--- + arch/arm/cpu/start.c | 48 +++++++++++++++++++++++++++++++----------------- + 1 file changed, 31 insertions(+), 17 deletions(-) + +diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c +index cd34d9c..fa148c2 100644 +--- a/arch/arm/cpu/start.c ++++ b/arch/arm/cpu/start.c +@@ -34,38 +34,52 @@ unsigned long arm_stack_top; + static noinline __noreturn void __start(uint32_t membase, uint32_t memsize, + uint32_t boarddata) + { +- unsigned long endmem = membase + memsize; ++ unsigned long memend; + unsigned long malloc_start, malloc_end; + + setup_c(); + +- arm_stack_top = endmem; +- endmem -= STACK_SIZE; /* Stack */ ++ if ((unsigned long)_text <= membase && ++ (unsigned long)_end > membase) { /* membase is in barebox */ ++ memsize -= (unsigned long)_end - membase; ++ membase = (unsigned long)_end; ++ } ++ ++ if ((unsigned long)_text < membase + memsize && ++ (unsigned long)_end >= membase + memsize) { /* membase + memsize is in barebox */ ++ memsize = (unsigned long)_text - membase; ++ } ++ ++ if ((unsigned long)_text > membase && ++ (unsigned long)_end < membase + memsize) { /* barebox splits or memory range */ ++ unsigned long lowsize = (unsigned long)_text - membase; ++ unsigned long highsize = membase + memsize - (unsigned long)_end; ++ /* use larger range */ ++ if (lowsize > highsize) { ++ memsize = lowsize; ++ } else { ++ membase = (unsigned long)_end; ++ memsize = highsize; ++ } ++ } ++ ++ arm_stack_top = membase + memsize; ++ memend = membase + memsize - STACK_SIZE; /* Stack */ + + if (IS_ENABLED(CONFIG_MMU_EARLY)) { + +- endmem &= ~0x3fff; +- endmem -= SZ_16K; /* ttb */ ++ memend &= ~0x3fff; ++ memend -= SZ_16K; /* ttb */ + + if (!IS_ENABLED(CONFIG_PBL_IMAGE)) +- mmu_early_enable(membase, memsize, endmem); ++ mmu_early_enable(membase, memsize, memend); + } + +- if ((unsigned long)_text > membase + memsize || +- (unsigned long)_text < membase) +- /* +- * barebox is either outside SDRAM or in another +- * memory bank, so we can use the whole bank for +- * malloc. +- */ +- malloc_end = endmem; +- else +- malloc_end = (unsigned long)_text; +- + /* + * Maximum malloc space is the Kconfig value if given + * or 64MB. + */ ++ malloc_end = memend; + if (MALLOC_SIZE > 0) { + malloc_start = malloc_end - MALLOC_SIZE; + if (malloc_start < membase) +-- +1.8.2.rc2 + |