[PATCH v2 03/16] image: Take entry point as an output of setup_booti
Yao Zi
me at ziyao.cc
Wed Jul 1 13:17:55 CEST 2026
From: Jiaxun Yang <jiaxun.yang at flygoat.com>
For LoongArch the start of the image is not the entry
point to the image.
We refactor the code base to allow entry point to be
supplied by setup_booti.
Signed-off-by: Jiaxun Yang <jiaxun.yang at flygoat.com>
Signed-off-by: Yao Zi <me at ziyao.cc>
---
Changed from v1
- Correct type of "entry" argument for RISC-V and sandbox
arch/arm/lib/image.c | 3 ++-
arch/riscv/lib/image.c | 4 +++-
arch/sandbox/lib/bootm.c | 2 +-
boot/bootm.c | 5 +++--
cmd/booti.c | 5 +++--
common/spl/spl.c | 9 +++++----
include/image.h | 3 ++-
7 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/arch/arm/lib/image.c b/arch/arm/lib/image.c
index 2268661de93a..62c28b8310a5 100644
--- a/arch/arm/lib/image.c
+++ b/arch/arm/lib/image.c
@@ -29,7 +29,7 @@ struct Image_header {
};
int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
- bool force_reloc)
+ ulong *entry, bool force_reloc)
{
struct Image_header *ih;
uint64_t dst;
@@ -72,6 +72,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
dst = gd->dram[0].start;
*relocated_addr = ALIGN(dst, SZ_2M) + text_offset;
+ *entry = *relocated_addr;
unmap_sysmem(ih);
diff --git a/arch/riscv/lib/image.c b/arch/riscv/lib/image.c
index a82f48e9a505..300be365ddfd 100644
--- a/arch/riscv/lib/image.c
+++ b/arch/riscv/lib/image.c
@@ -33,7 +33,7 @@ struct linux_image_h {
};
int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
- bool force_reloc)
+ ulong *entry, bool force_reloc)
{
struct linux_image_h *lhdr;
@@ -56,6 +56,8 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
*relocated_addr = image;
}
+ *entry = *relocated_addr;
+
unmap_sysmem(lhdr);
return 0;
diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
index 7a5f6f7d36ed..1a41c7c2735b 100644
--- a/arch/sandbox/lib/bootm.c
+++ b/arch/sandbox/lib/bootm.c
@@ -84,7 +84,7 @@ int do_bootm_linux(int flag, struct bootm_info *bmi)
/* used for testing 'booti' command */
int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
- bool force_reloc)
+ ulong *entry, bool force_reloc)
{
log_err("Booting is not supported on the sandbox.\n");
diff --git a/boot/bootm.c b/boot/bootm.c
index 4c260a5f5ced..50d18cb2c294 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -693,9 +693,10 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
images->os.os == IH_OS_LINUX) {
ulong relocated_addr;
ulong image_size;
+ ulong entry;
int ret;
- ret = booti_setup(load, &relocated_addr, &image_size, false);
+ ret = booti_setup(load, &relocated_addr, &image_size, &entry, false);
if (ret) {
printf("Failed to prep arm64 kernel (err=%d)\n", ret);
return BOOTM_ERR_RESET;
@@ -709,7 +710,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
memmove((void *)relocated_addr, load_buf, image_size);
}
- images->ep = relocated_addr;
+ images->ep = entry;
images->os.start = relocated_addr;
images->os.end = relocated_addr + image_size;
}
diff --git a/cmd/booti.c b/cmd/booti.c
index e6f67d6e1368..24c55ff92a27 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -27,6 +27,7 @@ static int booti_start(struct bootm_info *bmi)
ulong ld;
ulong relocated_addr;
ulong image_size;
+ ulong entry;
uint8_t *temp;
ulong dest;
ulong dest_end;
@@ -74,7 +75,7 @@ static int booti_start(struct bootm_info *bmi)
}
unmap_sysmem((void *)ld);
- ret = booti_setup(ld, &relocated_addr, &image_size, false);
+ ret = booti_setup(ld, &relocated_addr, &image_size, &entry, false);
if (ret)
return 1;
@@ -85,7 +86,7 @@ static int booti_start(struct bootm_info *bmi)
memmove((void *)relocated_addr, (void *)ld, image_size);
}
- images->ep = relocated_addr;
+ images->ep = entry;
images->os.start = relocated_addr;
images->os.end = relocated_addr + image_size;
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 722b18c98edc..1d32b0a5b7fd 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -114,7 +114,8 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)
return 1;
}
-int __weak booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool force_reloc)
+int __weak booti_setup(ulong image, ulong *relocated_addr, ulong *size,
+ ulong *entry, bool force_reloc)
{
return 1;
}
@@ -341,13 +342,13 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
}
if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_BOOTI)) {
- ulong start, size;
+ ulong start, size, entry;
- if (!booti_setup((ulong)header, &start, &size, 0)) {
+ if (!booti_setup((ulong)header, &start, &size, &entry, 0)) {
spl_image->name = "Linux";
spl_image->os = IH_OS_LINUX;
spl_image->load_addr = start;
- spl_image->entry_point = start;
+ spl_image->entry_point = entry;
spl_image->size = size;
debug(PHASE_PROMPT
"payload Image, load addr: 0x%lx size: %d\n",
diff --git a/include/image.h b/include/image.h
index 9c8a746d576e..97f66b9045bd 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1131,11 +1131,12 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
* @image: Address of image
* @start: Returns start address of image
* @size : Returns size image
+ * @entry: Returns entry point of image
* @force_reloc: Ignore image->ep field, always place image to RAM start
* Return: 0 if OK, 1 if the image was not recognised
*/
int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
- bool force_reloc);
+ ulong *entry, bool force_reloc);
/*******************************************************************/
/* New uImage format specific code (prefixed with fit_) */
--
2.54.0
More information about the U-Boot
mailing list