summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu/start-pbl.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-10-17 08:47:28 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-17 08:48:14 +0200
commit7787010e9b9b5f77c47856542120fa3f5d0abfc3 (patch)
tree38c97d549babc633c363e6c52419abee04d55f7c /arch/arm/cpu/start-pbl.c
parentda290d3fa3c9d4c753acb0b6c884229bcaf6d5f7 (diff)
parent3c91b44b66b17564039e329278d2e76d3eab71fe (diff)
downloadbarebox-7787010e9b9b5f77c47856542120fa3f5d0abfc3.tar.gz
barebox-7787010e9b9b5f77c47856542120fa3f5d0abfc3.tar.xz
Merge branch 'for-next/arm-start' into for-next/arm
Diffstat (limited to 'arch/arm/cpu/start-pbl.c')
-rw-r--r--arch/arm/cpu/start-pbl.c49
1 files changed, 11 insertions, 38 deletions
diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
index 929cc26055..609aedb39c 100644
--- a/arch/arm/cpu/start-pbl.c
+++ b/arch/arm/cpu/start-pbl.c
@@ -174,7 +174,7 @@ static void barebox_uncompress(void *compressed_start, unsigned int len)
*/
void __naked board_init_lowlevel_return(void)
{
- uint32_t r, offset;
+ uint32_t offset;
uint32_t pg_start, pg_end, pg_len;
/* Setup the stack */
@@ -187,43 +187,16 @@ void __naked board_init_lowlevel_return(void)
pg_end = (uint32_t)&input_data_end - offset;
pg_len = pg_end - pg_start;
- if (IS_ENABLED(CONFIG_PBL_FORCE_PIGGYDATA_COPY))
- goto copy_piggy_link;
+ if (offset && (IS_ENABLED(CONFIG_PBL_FORCE_PIGGYDATA_COPY) ||
+ region_overlap(pg_start, pg_len, TEXT_BASE, pg_len * 4))) {
+ /*
+ * copy piggydata binary to its link address
+ */
+ memcpy(&input_data, (void *)pg_start, pg_len);
+ pg_start = (uint32_t)&input_data;
+ }
- /*
- * Check if the piggydata binary will be overwritten
- * by the uncompressed binary or by the pbl relocation
- */
- if (!offset ||
- !((pg_start >= TEXT_BASE && pg_start < TEXT_BASE + pg_len * 4) ||
- ((uint32_t)_text >= pg_start && (uint32_t)_text <= pg_end)))
- goto copy_link;
-
-copy_piggy_link:
- /*
- * copy piggydata binary to its link address
- */
- memcpy(&input_data, (void *)pg_start, pg_len);
- pg_start = (uint32_t)&input_data;
-
-copy_link:
- /* relocate to link address if necessary */
- if (offset)
- memcpy((void *)_text, (void *)(_text - offset),
- __bss_start - _text);
-
- /* clear bss */
- memset(__bss_start, 0, __bss_stop - __bss_start);
-
- flush_icache();
+ setup_c();
- r = (unsigned int)&barebox_uncompress;
- /* call barebox_uncompress with its absolute address */
- __asm__ __volatile__(
- "mov r0, %1\n"
- "mov r1, %2\n"
- "mov pc, %0\n"
- :
- : "r"(r), "r"(pg_start), "r"(pg_len)
- : "r0", "r1");
+ barebox_uncompress((void *)pg_start, pg_len);
}