summaryrefslogtreecommitdiffstats
path: root/arch/arm/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-04-20 08:19:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-20 08:34:25 +0200
commit82a0c58680ee03cf23462cf0bf3e58e705205e08 (patch)
treec8da1f06c18b551d118930a83a9f4b49339e2fee /arch/arm/lib
parent3ae96610c5a86bfceb6c6679e5411ee808aab5e1 (diff)
downloadbarebox-82a0c58680ee03cf23462cf0bf3e58e705205e08.tar.gz
barebox-82a0c58680ee03cf23462cf0bf3e58e705205e08.tar.xz
ARM: bootm: Move mem_free calculation into get_kernel_addresses()
The callers of get_kernel_addresses() are not interested in the spacing after the kernel image, they are interested in the place where they can put device tree and initrd, so pass a pointer to mem_free to get_kernel_addresses(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/lib')
-rw-r--r--arch/arm/lib/bootm.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index d4ce6308c5..b9281e9c62 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -69,11 +69,12 @@ static int sdram_start_and_size(unsigned long *start, unsigned long *size)
static int get_kernel_addresses(size_t image_size,
int verbose, unsigned long *load_address,
- unsigned long *spacing)
+ unsigned long *mem_free)
{
unsigned long mem_start, mem_size;
int ret;
size_t image_decomp_size;
+ unsigned long spacing;
ret = sdram_start_and_size(&mem_start, &mem_size);
if (ret)
@@ -89,7 +90,7 @@ static int get_kernel_addresses(size_t image_size,
* By default put oftree/initrd close behind compressed kernel image to
* avoid placing it outside of the kernels lowmem region.
*/
- *spacing = SZ_1M;
+ spacing = SZ_1M;
if (*load_address == UIMAGE_INVALID_ADDRESS) {
/*
@@ -107,9 +108,11 @@ static int get_kernel_addresses(size_t image_size,
* spacing to allow this relocation to happen without
* overwriting anything placed behind the kernel.
*/
- *spacing += image_decomp_size;
+ spacing += image_decomp_size;
}
+ *mem_free = PAGE_ALIGN(*load_address + image_size + spacing);
+
return 0;
}
@@ -170,13 +173,13 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int
static int do_bootm_linux(struct image_data *data)
{
- unsigned long load_address, mem_free, spacing;
+ unsigned long load_address, mem_free;
int ret;
load_address = data->os_address;
ret = get_kernel_addresses(bootm_get_os_size(data),
- bootm_verbose(data), &load_address, &spacing);
+ bootm_verbose(data), &load_address, &mem_free);
if (ret)
return ret;
@@ -184,8 +187,6 @@ static int do_bootm_linux(struct image_data *data)
if (ret)
return ret;
- mem_free = PAGE_ALIGN(data->os_res->end + spacing);
-
return __do_bootm_linux(data, mem_free, 0);
}
@@ -281,7 +282,7 @@ static int do_bootz_linux(struct image_data *data)
u32 end, start;
size_t image_size;
unsigned long load_address = data->os_address;
- unsigned long mem_free, spacing;
+ unsigned long mem_free;
fd = open(data->os_file, O_RDONLY);
if (fd < 0) {
@@ -320,7 +321,7 @@ static int do_bootz_linux(struct image_data *data)
load_address = data->os_address;
ret = get_kernel_addresses(image_size, bootm_verbose(data),
- &load_address, &spacing);
+ &load_address, &mem_free);
if (ret)
return ret;
@@ -358,8 +359,6 @@ static int do_bootz_linux(struct image_data *data)
close(fd);
- mem_free = PAGE_ALIGN(data->os_res->end + spacing);
-
return __do_bootm_linux(data, mem_free, swap);
err_out: