You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/30 15:31:46 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5917: arch/risc-v: move REGLOAD/REGSTORE macro to riscv_internal.h

pkarashchenko commented on a change in pull request #5917:
URL: https://github.com/apache/incubator-nuttx/pull/5917#discussion_r838685873



##########
File path: arch/risc-v/src/common/riscv_swint.c
##########
@@ -109,45 +109,24 @@ static void riscv_registerdump(const uintptr_t *regs)
 
 #ifdef CONFIG_LIB_SYSCALL
 static void dispatch_syscall(void) naked_function;
-#ifdef CONFIG_ARCH_RV64
 static void dispatch_syscall(void)
 {
   asm volatile
     (
-     " addi sp, sp, -8\n"         /* Create a stack frame to hold ra */
-     " sd   ra, 0(sp)\n"          /* Save ra in the stack frame */
-     " la   t0, g_stublookup\n"   /* t0=The base of the stub lookup table */
-     " slli a0, a0, 3\n"          /* a0=Offset for the stub lookup table */
-     " add  t0, t0, a0\n"         /* t0=The address in the table */
-     " ld   t0, 0(t0)\n"          /* t0=The address of the stub for this syscall */
-     " jalr ra, t0\n"             /* Call the stub (modifies ra) */
-     " ld   ra, 0(sp)\n"          /* Restore ra */
-     " addi sp, sp, 8\n"          /* Destroy the stack frame */
-     " mv   a2, a0\n"             /* a2=Save return value in a0 */
-     " li   a0, 3\n"              /* a0=SYS_syscall_return (3) */
-     " ecall"                     /* Return from the syscall */
+     "addi sp, sp, -" REGSSIZE "\n" /* Create a stack frame to hold ra */
+     REGSTORE " ra, 0(sp)\n"        /* Save ra in the stack frame */
+     "la   t0, g_stublookup\n"      /* t0=The base of the stub lookup table */
+     "slli a0, a0, 3\n"             /* a0=Offset for the stub lookup table */

Review comment:
       taking into account code from `arch/risc-v/src/qemu-rv/qemu_rv_head.S` I have a question here. Should it be `slli a0, a0, 2` for RV32 and `slli a0, a0, 3` for RV64? Current code `slli a0, a0, 3` for both RV32 and RV64, so I kept it untouched.




-- 
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-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org