diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-10-07 19:06:30 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-07 12:38:01 +0100 |
commit | a81ec0225f5a100341c20b4329c8b1d81ab025c4 (patch) | |
tree | 0d38efb6ba77f80dc0759513d33ab73f7f9bc868 /arch/arm/cpu/start-pbl.c | |
parent | b08e08506b9752d3768e42d075283f91d2ed5180 (diff) | |
download | barebox-a81ec0225f5a100341c20b4329c8b1d81ab025c4.tar.gz barebox-a81ec0225f5a100341c20b4329c8b1d81ab025c4.tar.xz |
ARM: Add relocatable binary support
For making the same binary executable on different SoCs which have
different DRAM addresses we have to be independent of the compile
time link address.
This patch adds relocatable binary support for the ARM architecture.
With this two new functions are available. relocate_to_current_adr
will fixup the binary to continue executing from the current position.
relocate_to_adr will copy the binary to a given address, fixup the
binary and continue executing from there.
For the PBL and the real image relocatable support can be enabled
independently. This is done to (hopefully) better cope with setups
where the PBL runs from SRAM or ROM and the real binary does not.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu/start-pbl.c')
-rw-r--r-- | arch/arm/cpu/start-pbl.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c index 91bc8fe9ff..6f03c4a7df 100644 --- a/arch/arm/cpu/start-pbl.c +++ b/arch/arm/cpu/start-pbl.c @@ -55,9 +55,13 @@ static noinline __noreturn void __barebox_arm_entry(uint32_t membase, uint32_t pg_start, pg_end, pg_len; void __noreturn (*barebox)(uint32_t, uint32_t, uint32_t); uint32_t endmem = membase + memsize; + unsigned long barebox_base; endmem -= STACK_SIZE; /* stack */ + if (IS_ENABLED(CONFIG_PBL_RELOCATABLE)) + relocate_to_current_adr(); + /* Get offset between linked address and runtime address */ offset = get_runtime_offset(); @@ -65,8 +69,13 @@ static noinline __noreturn void __barebox_arm_entry(uint32_t membase, pg_end = (uint32_t)&input_data_end - offset; pg_len = pg_end - pg_start; + if (IS_ENABLED(CONFIG_RELOCATABLE)) + barebox_base = arm_barebox_image_place(membase + memsize); + else + barebox_base = TEXT_BASE; + if (offset && (IS_ENABLED(CONFIG_PBL_FORCE_PIGGYDATA_COPY) || - region_overlap(pg_start, pg_len, TEXT_BASE, pg_len * 4))) { + region_overlap(pg_start, pg_len, barebox_base, pg_len * 4))) { /* * copy piggydata binary to its link address */ @@ -86,14 +95,15 @@ static noinline __noreturn void __barebox_arm_entry(uint32_t membase, free_mem_ptr = endmem; free_mem_end_ptr = free_mem_ptr + SZ_128K; - pbl_barebox_uncompress((void*)TEXT_BASE, (void *)pg_start, pg_len); + pbl_barebox_uncompress((void*)barebox_base, (void *)pg_start, pg_len); + arm_early_mmu_cache_flush(); flush_icache(); if (IS_ENABLED(CONFIG_THUMB2_BAREBOX)) - barebox = (void *)(TEXT_BASE + 1); + barebox = (void *)(barebox_base + 1); else - barebox = (void *)TEXT_BASE; + barebox = (void *)barebox_base; barebox(membase, memsize, boarddata); } |