[PATCH v2 1/4] firmware: Add relocatable FW_JUMP_ADDR and FW_JUMP_FDT_ADDR
Anup Patel
anup at brainfault.org
Sat Feb 24 02:59:29 PST 2024
On Fri, Feb 23, 2024 at 1:48 PM Inochi Amaoto <inochiama at outlook.com> wrote:
>
> If FW_PIC=y is defined, the fw_jump.bin will be broken if
> FW_TEXT_START is wrong. This is not the desired behavior.
>
> Add two new variables to identify relocatable jump address:
> FW_JUMP_OFFSET and FW_JUMP_FDT_ADDR. To keep the existing
> ABI, FW_JUMP_ADDR and FW_JUMP_FDT_ADDR is prefered if they
> are defined.
>
> Signed-off-by: Inochi Amaoto <inochiama at outlook.com>
LGTM.
Reviewed-by: Anup Patel <anup at brainfault.org>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
> ---
> firmware/fw_jump.S | 18 ++++++++++++++----
> firmware/objects.mk | 6 ++++++
> 2 files changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/firmware/fw_jump.S b/firmware/fw_jump.S
> index ac74dc6..ebf297f 100644
> --- a/firmware/fw_jump.S
> +++ b/firmware/fw_jump.S
> @@ -46,6 +46,10 @@ fw_save_info:
> fw_next_arg1:
> #ifdef FW_JUMP_FDT_ADDR
> li a0, FW_JUMP_FDT_ADDR
> +#elif defined(FW_JUMP_FDT_OFFSET)
> + lla a0, _fw_start
> + li a1, FW_JUMP_FDT_OFFSET
> + add a0, a0, a1
> #else
> add a0, a1, zero
> #endif
> @@ -59,8 +63,16 @@ fw_next_arg1:
> * The next address should be returned in 'a0'.
> */
> fw_next_addr:
> +#ifdef FW_JUMP_ADDR
> lla a0, _jump_addr
> REG_L a0, (a0)
> +#elif defined(FW_JUMP_OFFSET)
> + lla a0, _fw_start
> + li a1, FW_JUMP_OFFSET
> + add a0, a0, a1
> +#else
> +#error "Must define at least FW_JUMP_ADDR or FW_JUMP_OFFSET"
> +#endif
> ret
>
> .section .entry, "ax", %progbits
> @@ -86,11 +98,9 @@ fw_options:
> add a0, zero, zero
> ret
>
> -#ifndef FW_JUMP_ADDR
> -#error "Must define FW_JUMP_ADDR"
> -#endif
> -
> +#ifdef FW_JUMP_ADDR
> .section .rodata
> .align 3
> _jump_addr:
> RISCV_PTR FW_JUMP_ADDR
> +#endif
> diff --git a/firmware/objects.mk b/firmware/objects.mk
> index a1704c4..fef090a 100644
> --- a/firmware/objects.mk
> +++ b/firmware/objects.mk
> @@ -38,9 +38,15 @@ endif
> firmware-bins-$(FW_DYNAMIC) += fw_dynamic.bin
>
> firmware-bins-$(FW_JUMP) += fw_jump.bin
> +ifdef FW_JUMP_OFFSET
> +firmware-genflags-$(FW_JUMP) += -DFW_JUMP_OFFSET=$(FW_JUMP_OFFSET)
> +endif
> ifdef FW_JUMP_ADDR
> firmware-genflags-$(FW_JUMP) += -DFW_JUMP_ADDR=$(FW_JUMP_ADDR)
> endif
> +ifdef FW_JUMP_FDT_OFFSET
> +firmware-genflags-$(FW_JUMP) += -DFW_JUMP_FDT_OFFSET=$(FW_JUMP_FDT_OFFSET)
> +endif
> ifdef FW_JUMP_FDT_ADDR
> firmware-genflags-$(FW_JUMP) += -DFW_JUMP_FDT_ADDR=$(FW_JUMP_FDT_ADDR)
> endif
> --
> 2.43.2
>
More information about the opensbi
mailing list