xiaoxiang781216 commented on code in PR #20873:
URL: https://github.com/apache/nuttx/pull/20873#discussion_r4343552247
##########
arch/arm/include/syscall.h:
##########
@@ -135,33 +135,38 @@
#ifndef __ASSEMBLY__
+/* A system call returns with R1-R3 and R12 changed (dispatch_syscall() calls
+ * the stub function), so the macros give these registers to the compiler
+ * as outputs or as clobbered.
+ */
+
/* SVC with SYS_ call number and no parameters */
#ifdef __ghs__
-# define sys_call0(nbr) \
-({ \
- uintptr_t ret; \
- __asm__ __volatile__ \
- ( \
- "mov r0, %2\n\t" \
- "svc %1\n\t" \
- "mov %0, r0" \
- : "=r"(ret) \
- : "i"(SYS_syscall), "r"((uintptr_t)nbr) \
- : "memory", "r0" \
- ); \
- ret; \
+# define sys_call0(nbr) \
+({ \
+ uintptr_t ret; \
+ __asm__ __volatile__ \
+ ( \
+ "mov r0, %2\n\t" \
+ "svc %1\n\t" \
+ "mov %0, r0" \
+ : "=r"(ret) \
+ : "i"(SYS_syscall), "r"((uintptr_t)nbr) \
+ : "memory", "r0", "r1", "r2", "r3", "r12" \
+ ); \
+ ret; \
})
#else
# define sys_call0(nbr) \
({ \
register uintptr_t reg0 __asm__("r0") = (uintptr_t)(nbr); \
__asm__ __volatile__ \
( \
- "svc %1" \
- : "=r"(reg0) \
- : "i"(SYS_syscall), "r"(reg0) \
- : "memory" \
+ "svc %[svc]" \
+ : "+r"(reg0) \
+ : [svc] "i"(SYS_syscall) \
Review Comment:
why add svc symbol? let's algin the implementation of gcc and ghs
##########
arch/arm/src/armv7-a/arm_syscall.c:
##########
@@ -132,7 +145,8 @@ static void dispatch_syscall(void)
" str r5, [sp, #4]\n" /* Move parameter 5 (if
any) into position */
" str r6, [sp, #8]\n" /* Move parameter 6 (if
any) into position */
" str lr, [sp, #12]\n" /* Save lr in the stack
frame */
- " ldr ip, =g_stublookup\n" /* R12=The base of the
stub lookup table */
+ " ldr ip, =g_stublookup_ptr\n" /* R12=The address of the
table pointer */
Review Comment:
how about reference g_stublookup_ptr through assemble argument
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]