Implement initjmp() for RISC-V.

Signed-off-by: Jerome Forissier <jerome.foriss...@linaro.org>
---
 arch/Kconfig                    |  1 +
 arch/riscv/include/asm/setjmp.h |  1 +
 arch/riscv/lib/setjmp.S         | 10 ++++++++++
 3 files changed, 12 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 57695fada8d..b745222bfbe 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -152,6 +152,7 @@ config RISCV
        bool "RISC-V architecture"
        select CREATE_ARCH_SYMLINK
        select HAVE_SETJMP
+       select HAVE_INITJMP
        select SUPPORT_ACPI
        select SUPPORT_LITTLE_ENDIAN
        select SUPPORT_OF_CONTROL
diff --git a/arch/riscv/include/asm/setjmp.h b/arch/riscv/include/asm/setjmp.h
index 72383d43303..98ea157eb3b 100644
--- a/arch/riscv/include/asm/setjmp.h
+++ b/arch/riscv/include/asm/setjmp.h
@@ -21,5 +21,6 @@ typedef struct jmp_buf_data jmp_buf[1];
 
 int setjmp(jmp_buf jmp);
 void longjmp(jmp_buf jmp, int ret);
+int initjmp(jmp_buf jmp, void __noreturn (*func)(void), void *stack_top);
 
 #endif /* _SETJMP_H_ */
diff --git a/arch/riscv/lib/setjmp.S b/arch/riscv/lib/setjmp.S
index 99d6195827e..6f952a16eee 100644
--- a/arch/riscv/lib/setjmp.S
+++ b/arch/riscv/lib/setjmp.S
@@ -59,3 +59,13 @@ ENTRY(longjmp)
        ret
 ENDPROC(longjmp)
 .popsection
+
+.pushsection .text.initjmp, "ax"
+ENTRY(initjmp)
+       /* a1: entry point address, a2: stack top */
+       STORE_IDX(a1, 12)
+       STORE_IDX(a2, 13)
+       li  a0, 0
+       ret
+ENDPROC(initjmp)
+.popsection
-- 
2.43.0

Reply via email to