
On 22.05.24 17:34, Jiaxun Yang wrote:
For LoongArch the start of the image is not the entry point to the image.
Looking at arch/loongarch/kernel/head.S there seem to be two cases:
* The kernel has an EFI stub (CONFIG_EFI_STUB=y). The legacy physical entry point is available at offset 0x08 of the header. * The kernel has no EFI stub. The kernel entry point matches the start of the image.
Where do you differentiate between the cases?
Best regards
Heinrich
We refactor the code base to allow entry point to be supplied by setup_booti.
Signed-off-by: Jiaxun Yang jiaxun.yang@flygoat.com
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 e394c1ad9093..024b6adc75e7 100644 --- a/arch/arm/lib/image.c +++ b/arch/arm/lib/image.c @@ -30,7 +30,7 @@ struct Image_header { };
int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
bool force_reloc)
{ struct Image_header *ih; uint64_t dst;ulong *entry, bool force_reloc)
@@ -73,6 +73,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, dst = gd->bd->bi_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..2fd1f6c535ae 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)
{ struct linux_image_h *lhdr;ulong entry, bool force_reloc)
@@ -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 44ba8b52e139..4ef34c81d6d2 100644 --- a/arch/sandbox/lib/bootm.c +++ b/arch/sandbox/lib/bootm.c @@ -83,7 +83,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)
{ log_err("Booting is not supported on the sandbox.\n");ulong entry, bool force_reloc)
diff --git a/boot/bootm.c b/boot/bootm.c index 032f5a4a1605..770300132891 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;
int ret;ulong entry;
ret = booti_setup(load, &relocated_addr, &image_size, false);
if (ret) { printf("Failed to prep arm64 kernel (err=%d)\n", ret); return BOOTM_ERR_RESET;ret = booti_setup(load, &relocated_addr, &image_size, &entry, false);
@@ -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->os.start = relocated_addr; images->os.end = relocated_addr + image_size; }images->ep = entry;
diff --git a/cmd/booti.c b/cmd/booti.c index b9637b3ec3d8..9586a4c58ac1 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;
@@ -73,7 +74,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;
@@ -84,7 +85,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 e06bc75d36b2..52a4bee13728 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -113,7 +113,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,
{ return 1; }ulong *entry, bool force_reloc)
@@ -324,13 +325,13 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
#if CONFIG_IS_ENABLED(OS_BOOT) #if defined(CMD_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(SPL_TPL_PROMPT "payload Image, load addr: 0x%lx size: %d\n",
diff --git a/include/image.h b/include/image.h index acffd17e0dfd..a2bfc7bb19a3 100644 --- a/include/image.h +++ b/include/image.h @@ -1061,11 +1061,12 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
- @image: Address of image
- @start: Returns start address of image
- @size : Returns size image
*/ int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
- @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
bool force_reloc);
ulong *entry, bool force_reloc);
/*******************************************************************/ /* New uImage format specific code (prefixed with fit_) */