From 9eb59201ab60b7ca3af41cd3000f8ff823ae5f02 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 23 Nov 2024 09:47:52 +0100 Subject: examples: implement _start and syscall for RISC-V To build the API examples on RISC-V we need to implement _start and syscall for RISC-V. Signed-off-by: Heinrich Schuchardt --- examples/api/crt0.S | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'examples/api') diff --git a/examples/api/crt0.S b/examples/api/crt0.S index f1b88ed8a3d..d2a97557817 100644 --- a/examples/api/crt0.S +++ b/examples/api/crt0.S @@ -80,6 +80,38 @@ syscall: return_addr: .align 8 .long 0 +#elif defined(CONFIG_ARCH_RV32I) + + .text + .globl _start +_start: + la t0, search_hint + sw sp, 0(t0) + la t0, main + jalr x0, t0 + + .globl syscall +syscall: + la t0, syscall_ptr + lw t0, 0(t0) + jalr x0, t0 + +#elif defined(CONFIG_ARCH_RV64I) + + .text + .globl _start +_start: + la t0, search_hint + sd sp, 0(t0) + la t0, main + jalr x0, t0 + + .globl syscall +syscall: + la t0, syscall_ptr + ld t0, 0(t0) + jalr x0, t0 + #else #error No support for this arch! #endif -- cgit v1.2.3 From e18186686fc6c4f1b7ef04a5f77b74fcd44cb721 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 23 Nov 2024 09:47:53 +0100 Subject: examples: use architecture specific memset() on RISC-V Build the architecture specific memset() if configured. Signed-off-by: Heinrich Schuchardt --- examples/api/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/api') diff --git a/examples/api/Makefile b/examples/api/Makefile index ec1643e4875..13e859cf080 100644 --- a/examples/api/Makefile +++ b/examples/api/Makefile @@ -43,8 +43,8 @@ EXT_COBJ-y += lib/vsprintf.o EXT_COBJ-y += lib/charset.o EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o -ifeq ($(ARCH),arm) -EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o +ifneq ($(CONFIG_ARM)$(CONFIG_RISCV),) +EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/$(ARCH)/lib/memset.o endif # Create a list of object files to be compiled -- cgit v1.2.3 From 8e5b57eea04c80a9226c6c71f892c8808caa3d65 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 23 Nov 2024 09:47:54 +0100 Subject: examples: use QEMU compatible LOAD_ADDR on RISC-V On some RISC-V including QEMU $loadaddr is 0x80200000. For bootelf to work choose a different LOAD_ADDR to which the demo ELF binary is relocated. Signed-off-by: Heinrich Schuchardt --- examples/api/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'examples/api') diff --git a/examples/api/Makefile b/examples/api/Makefile index 13e859cf080..722c7e45904 100644 --- a/examples/api/Makefile +++ b/examples/api/Makefile @@ -22,6 +22,9 @@ else LOAD_ADDR = 0x80200000 endif endif +ifeq ($(ARCH),riscv) +LOAD_ADDR = 0x84000000 +endif # Resulting ELF and binary exectuables will be named demo and demo.bin extra-y = demo -- cgit v1.2.3