diff options
author | Markus Pargmann <mpa@pengutronix.de> | 2015-12-08 10:39:29 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-12-10 08:49:52 +0100 |
commit | 65071bd0910ef109c86b9645c570a6ceed7de534 (patch) | |
tree | d7718bf2bd128991861304999cbbc2ad17fdcc26 /arch/arm/include/asm | |
parent | 899b3822d2be2eb07622fd1946614675a9bb5109 (diff) | |
download | barebox-65071bd0910ef109c86b9645c570a6ceed7de534.tar.gz barebox-65071bd0910ef109c86b9645c570a6ceed7de534.tar.xz |
arm: Clarify memory layout calculation
The memory calculations used are all hardcoded into three different
files, start-pbl.c, uncompress.c and start.c. To make this more readable
and reliable, this patch gathers these information in barebox-arm.h with
static inline functions for the calculation of the memory offsets.
This patch also adds proper handling of different barebox/board data
sizes. Currently only 1MB+Alignment of RAM is reserved for Barebox and
board data. This could be too small for bigger devicetrees and barebox.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/include/asm')
-rw-r--r-- | arch/arm/include/asm/barebox-arm.h | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h index 76e356413a..8d52882981 100644 --- a/arch/arm/include/asm/barebox-arm.h +++ b/arch/arm/include/asm/barebox-arm.h @@ -94,25 +94,44 @@ static inline void arm_fixup_vectors(void) void *barebox_arm_boot_dtb(void); -/* - * For relocatable binaries find a suitable start address for the - * relocated binary. Beginning at the memory end substract the reserved - * space and round down a bit at the end. This is used by the pbl to - * extract the image to a suitable place so that the uncompressed image - * does not have to copy itself to another place. Also it's used by - * the uncompressed image to relocate itself to the same place. - */ -static inline unsigned long arm_barebox_image_place(unsigned long endmem) +static inline unsigned long arm_mem_stack(unsigned long membase, + unsigned long endmem) +{ + return endmem - STACK_SIZE; +} + +static inline unsigned long arm_mem_ttb(unsigned long membase, + unsigned long endmem) { - endmem -= STACK_SIZE; - endmem -= SZ_32K; /* ttb */ - endmem -= SZ_128K; /* early malloc */ - endmem -= SZ_1M; /* place for barebox image */ - - /* - * round down to make translating the objdump easier - */ - endmem &= ~(SZ_1M - 1); + endmem = arm_mem_stack(membase, endmem); + endmem &= ~(SZ_16K - 1); + endmem -= SZ_16K; + + return endmem; +} + +static inline unsigned long arm_mem_early_malloc(unsigned long membase, + unsigned long endmem) +{ + return arm_mem_ttb(membase, endmem) - SZ_128K; +} + +static inline unsigned long arm_mem_early_malloc_end(unsigned long membase, + unsigned long endmem) +{ + return arm_mem_ttb(membase, endmem); +} + +static inline unsigned long arm_mem_barebox_image(unsigned long membase, + unsigned long endmem, + unsigned long size) +{ + endmem = arm_mem_ttb(membase, endmem); + + if (IS_ENABLED(CONFIG_RELOCATABLE)) { + endmem -= size; + endmem &= ~(SZ_1M - 1); + } return endmem; } |