From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: u-boot@lists.denx.de, Simon Glass <sjg@chromium.org>,
Tom Rini <trini@konsulko.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>
Subject: Re: [PATCH 03/16] image: Take entry point as an output of setup_booti
Date: Tue, 11 Jun 2024 15:02:37 +0200 [thread overview]
Message-ID: <4887f128-786d-4d07-8dec-79ef75e39509@gmx.de> (raw)
In-Reply-To: <20240522-loongarch-v1-3-1407e0b69678@flygoat.com>
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)
> + ulong *entry, bool force_reloc)
> {
> struct Image_header *ih;
> uint64_t dst;
> @@ -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)
> + 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 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)
> + 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 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;
> + 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 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,
> + ulong *entry, bool force_reloc)
> {
> return 1;
> }
> @@ -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
> + * @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_) */
>
next prev parent reply other threads:[~2024-06-11 13:02 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 15:34 [PATCH 00/16] LoongArch initial support Jiaxun Yang
2024-05-22 15:34 ` [PATCH 01/16] lib: fdtdec: Handle multiple memory nodes Jiaxun Yang
2024-06-11 12:26 ` Heinrich Schuchardt
2024-06-11 13:47 ` Jiaxun Yang
2024-06-11 18:51 ` Simon Glass
2024-06-12 5:55 ` Heinrich Schuchardt
2024-05-22 15:34 ` [PATCH 02/16] linux/io.h: Use map_physmem to implement ioremap Jiaxun Yang
2024-05-22 15:34 ` [PATCH 03/16] image: Take entry point as an output of setup_booti Jiaxun Yang
2024-06-11 13:02 ` Heinrich Schuchardt [this message]
2024-06-11 13:29 ` Jiaxun Yang
2024-06-11 13:52 ` Tom Rini
2024-06-11 14:01 ` Jiaxun Yang
2024-06-11 14:09 ` Tom Rini
2024-05-22 15:34 ` [PATCH 04/16] elf.h Define LoongArch bits Jiaxun Yang
2024-06-16 10:34 ` Heinrich Schuchardt
2024-05-22 15:34 ` [PATCH 05/16] image: Define IH_ARCH_LOONGARCH Jiaxun Yang
2024-06-16 10:37 ` Heinrich Schuchardt
2024-05-22 15:34 ` [PATCH 06/16] LoongArch: skeleton and headers Jiaxun Yang
2024-05-23 15:15 ` Heinrich Schuchardt
2024-05-22 15:34 ` [PATCH 07/16] LoongArch: lib: General routines Jiaxun Yang
2024-06-16 11:01 ` Heinrich Schuchardt
2024-06-16 13:06 ` Jiaxun Yang
2024-06-16 16:00 ` Heinrich Schuchardt
2024-06-18 14:19 ` Jiaxun Yang
2024-05-22 15:34 ` [PATCH 08/16] LoongArch: CPU assembly routines Jiaxun Yang
2024-05-22 15:34 ` [PATCH 09/16] LoongArch: Exception handling Jiaxun Yang
2024-05-22 15:34 ` [PATCH 10/16] LoongArch: Boot Image bits Jiaxun Yang
2024-05-22 15:34 ` [PATCH 11/16] LoongArch: Generic CPU type Jiaxun Yang
2024-05-22 15:34 ` [PATCH 12/16] cpu: Add loongarch_cpu driver Jiaxun Yang
2024-05-22 15:34 ` [PATCH 13/16] timer: Add loongarch_timer driver Jiaxun Yang
2024-05-22 15:34 ` [PATCH 14/16] board: emulation: Add qemu-loongarch Jiaxun Yang
2024-05-22 15:34 ` [PATCH 15/16] efi: LoongArch: Define LoongArch bits everywhere Jiaxun Yang
2024-05-23 16:14 ` Heinrich Schuchardt
2024-05-23 16:25 ` Jiaxun Yang
2024-05-22 15:34 ` [PATCH 16/16] efi: LoongArch: Implement everything Jiaxun Yang
2024-05-23 16:26 ` Heinrich Schuchardt
2024-05-23 16:46 ` Jiaxun Yang
2024-05-23 15:25 ` [PATCH 00/16] LoongArch initial support Tom Rini
2024-05-23 15:38 ` Jiaxun Yang
2024-05-23 15:43 ` Tom Rini
2024-06-04 10:50 ` Jiaxun Yang
2024-06-04 17:09 ` Tom Rini
2024-05-23 15:47 ` Peter Robinson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4887f128-786d-4d07-8dec-79ef75e39509@gmx.de \
--to=xypron.glpk@gmx.de \
--cc=ilias.apalodimas@linaro.org \
--cc=jiaxun.yang@flygoat.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.