pussuw commented on a change in pull request #5782: URL: https://github.com/apache/incubator-nuttx/pull/5782#discussion_r837102660
########## File path: arch/risc-v/src/common/riscv_internal.h ########## @@ -283,6 +292,63 @@ int riscv_pause_handler(int irq, void *c, void *arg); uintptr_t riscv_mhartid(void); +#ifdef CONFIG_ARCH_USE_S_MODE +/* If kernel runs in Supervisor mode, declare proper function prototypes, + * this is because it is not possible to ecall from S mode to S mode + */ + +int riscv_saveusercontext(uintptr_t *saveregs); +void riscv_fullcontextrestore(uintptr_t *restoreregs) noreturn_function; +void riscv_switchcontext(uintptr_t *saveregs, uintptr_t *restoreregs); +void riscv_syscall_return(void); +void riscv_syscall_dispatch(void) noreturn_function; + +#else + +#ifndef __ASSEMBLY__ + +/* Context switching via system calls ***************************************/ + +/* SYS call 0: + * + * int riscv_saveusercontext(uintptr_t *saveregs); + * + * Return: + * 0: Normal Return + * 1: Context Switch Return + */ + +#define riscv_saveusercontext(saveregs) \ + sys_call1(SYS_save_context, (uintptr_t)saveregs) Review comment: See my comment below, but basically the same here, change these to ksys_call1 etc, so the user functions would not be used for these macros called by the kernel ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org