arch/risc-v: use STACK_FRAME_SIZE for in S-mode syscall asm

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko 2022-04-03 23:11:38 +02:00 committed by Xiang Xiao
parent e88a357fa7
commit 9b7f9867aa
3 changed files with 12 additions and 10 deletions

View File

@ -65,6 +65,11 @@
# define REGSTORE __STR(sd)
#endif
/* RISC-V requires a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
#define STACK_FRAME_SIZE __XSTR(STACK_ALIGNMENT)
/****************************************************************************
* Inline functions
****************************************************************************/

View File

@ -126,11 +126,11 @@
#if defined (CONFIG_ARCH_USE_S_MODE) && defined (__KERNEL__)
# define ASM_SYS_CALL \
" addi sp, sp, -16\n" /* Make room */ \
REGSTORE " ra, 0(sp)\n" /* Save ra */ \
" jal ra, riscv_dispatch_syscall\n" /* Dispatch (modifies ra) */ \
REGLOAD " ra, 0(sp)\n" /* Restore ra */ \
" addi sp, sp, 16\n" /* Restore sp */
" addi sp, sp, -" STACK_FRAME_SIZE "\n" /* Make room */ \
REGSTORE " ra, 0(sp)\n" /* Save ra */ \
" jal ra, riscv_dispatch_syscall\n" /* Dispatch (modifies ra) */ \
REGLOAD " ra, 0(sp)\n" /* Restore ra */ \
" addi sp, sp, " STACK_FRAME_SIZE "\n" /* Restore sp */
#else
# define ASM_SYS_CALL \
"ecall"

View File

@ -33,6 +33,8 @@
# include <sys/types.h>
# include <stdint.h>
# include <syscall.h>
#else
# include <arch/arch.h>
#endif
/****************************************************************************
@ -47,11 +49,6 @@
#define INTSTACK_COLOR 0xdeadbeef
#define HEAP_COLOR 'h'
/* RISC-V requires a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
#define STACK_FRAME_SIZE __XSTR(STACK_ALIGNMENT)
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)