summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-06-03 09:26:12 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-06-09 09:36:53 +0200
commit6e51c28558cb480c2d21c0590138d9408801651a (patch)
tree0fa1d62236107ffcc73206c6520f754e03ce7518 /common
parent8d07a9da7622358257cc0593f35fa56ad5e63821 (diff)
downloadbarebox-6e51c28558cb480c2d21c0590138d9408801651a.tar.gz
barebox-6e51c28558cb480c2d21c0590138d9408801651a.tar.xz
ARM64/RISC-V: booti: support global.bootm.image.loadaddr
So far $global.bootm.image.loadaddr was ignored. Fix this, so user code may explicitly decide placement if needed. barebox will still sanity check the address and align it if necessary, but won't go below it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220603072612.1580380-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/booti.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/common/booti.c b/common/booti.c
index a2d63d8c31..dde1605fe1 100644
--- a/common/booti.c
+++ b/common/booti.c
@@ -6,11 +6,31 @@
#include <bootm.h>
#include <linux/sizes.h>
+static unsigned long get_kernel_address(unsigned long os_address,
+ unsigned long text_offset)
+{
+ resource_size_t start, end;
+ int ret;
+
+ if (os_address == UIMAGE_SOME_ADDRESS ||
+ os_address == UIMAGE_INVALID_ADDRESS) {
+ ret = memory_bank_first_find_space(&start, &end);
+ if (ret)
+ return UIMAGE_INVALID_ADDRESS;
+
+ return ALIGN(start, SZ_2M) + text_offset;
+ }
+
+ if (os_address >= text_offset && IS_ALIGNED(os_address - text_offset, SZ_2M))
+ return os_address;
+
+ return ALIGN(os_address, SZ_2M) + text_offset;
+}
+
void *booti_load_image(struct image_data *data, phys_addr_t *oftree)
{
const void *kernel_header =
data->os_fit ? data->fit_kernel : data->os_header;
- resource_size_t start, end;
unsigned long text_offset, image_size, devicetree, kernel;
unsigned long image_end;
int ret;
@@ -19,11 +39,9 @@ void *booti_load_image(struct image_data *data, phys_addr_t *oftree)
text_offset = le64_to_cpup(kernel_header + 8);
image_size = le64_to_cpup(kernel_header + 16);
- ret = memory_bank_first_find_space(&start, &end);
- if (ret)
- return ERR_PTR(ret);
-
- kernel = ALIGN(start, SZ_2M) + text_offset;
+ kernel = get_kernel_address(data->os_address, text_offset);
+ if (kernel == UIMAGE_INVALID_ADDRESS)
+ return ERR_PTR(-ENOENT);
ret = bootm_load_os(data, kernel);
if (ret)