arch/arm: Replace the hardcode syscall number with macro

and change SYS_context_[save|restore] to SYS_[save|restore]_context

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-04-03 03:15:03 +08:00 committed by Alan Carvalho de Assis
parent 7de43596da
commit e7dffdf06f
29 changed files with 39 additions and 62 deletions

View File

@ -71,7 +71,7 @@ arm_fullcontextrestore:
mov r1, r0 /* R1: regs */
mov r0, #SYS_restore_context /* R0: restore context */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* This call should not return */

View File

@ -73,7 +73,7 @@ arm_saveusercontext:
mov r1, r0 /* R1: regs */
mov r0, #SYS_save_context /* R0: save context (also return value) */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* There are two return conditions. On the first return, R0 (the
* return value will be zero. On the second return we need to

View File

@ -95,7 +95,7 @@ up_signal_handler:
/* Execute the SYS_signal_handler_return SVCall (will not return) */
mov r0, #SYS_signal_handler_return
svc 0
svc #SYS_syscall
nop
.size up_signal_handler, .-up_signal_handler

View File

@ -33,10 +33,6 @@
#include <arch/irq.h>
#include <nuttx/sched.h>
#ifdef CONFIG_LIB_SYSCALL
# include <syscall.h>
#endif
#include "signal/signal.h"
#include "svcall.h"
#include "exc_return.h"

View File

@ -73,7 +73,7 @@ arm_switchcontext:
mov r2, r1 /* R2: restoreregs */
mov r1, r0 /* R1: saveregs */
mov r0, #SYS_switch_context /* R0: context switch */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* We will get here only after the rerturn from the context switch */

View File

@ -27,9 +27,7 @@
#include <nuttx/config.h>
#ifdef CONFIG_LIB_SYSCALL
# include <syscall.h>
#endif
#include <syscall.h>
/****************************************************************************
* Pre-processor Definitions

View File

@ -96,11 +96,11 @@ arm_fullcontextrestore:
* to either user or kernel mode.
*/
/* Perform the System call with R0=SYS_context_restore, R1=restoreregs */
/* Perform the System call with R0=1 and R1=regs */
mov r1, r0 /* R1: restoreregs */
mov r0, #SYS_context_restore /* R0: SYS_context_restore syscall */
svc #0x900001 /* Perform the system call */
mov r1, r0 /* R1: regs */
mov r0, #SYS_restore_context /* R0: restore context */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* This call should not return */

View File

@ -27,7 +27,6 @@
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <syscall.h>
#include <assert.h>
#include <debug.h>
@ -219,19 +218,19 @@ uint32_t *arm_syscall(uint32_t *regs)
}
break;
/* R0=SYS_context_restore: Restore task context
/* R0=SYS_restore_context: Restore task context
*
* void arm_fullcontextrestore(uint32_t *restoreregs)
* noreturn_function;
*
* At this point, the following values are saved in context:
*
* R0 = SYS_context_restore
* R0 = SYS_restore_context
* R1 = restoreregs
*/
#ifdef CONFIG_BUILD_KERNEL
case SYS_context_restore:
case SYS_restore_context:
{
/* Replace 'regs' with the pointer to the register set in
* regs[REG_R1]. On return from the system call, that register

View File

@ -78,7 +78,8 @@ static void sig_trampoline(void)
" pop {r2}\n" /* Recover LR in R2 */
" mov lr, r2\n" /* Restore LR */
" mov r0, #5\n" /* SYS_signal_handler_return */
" svc #0x900001\n" /* Return from the signal handler */
" svc %0\n" /* Return from the SYSCALL */
::"i"(SYS_syscall)
);
}

View File

@ -27,9 +27,7 @@
#include <nuttx/config.h>
#ifdef CONFIG_LIB_SYSCALL
# include <syscall.h>
#endif
#include <syscall.h>
#ifdef CONFIG_LIB_SYSCALL
@ -73,7 +71,7 @@
* void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function;
*/
#define SYS_context_restore (1)
#define SYS_restore_context (1)
/* SYS call 2:
*

View File

@ -34,10 +34,6 @@
#include <nuttx/sched.h>
#include <nuttx/userspace.h>
#ifdef CONFIG_LIB_SYSCALL
# include <syscall.h>
#endif
#include "signal/signal.h"
#include "svcall.h"
#include "exc_return.h"

View File

@ -70,7 +70,7 @@ arm_fullcontextrestore:
mov r1, r0 /* R1: regs */
mov r0, #SYS_restore_context /* R0: restore context */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* This call should not return */

View File

@ -72,7 +72,7 @@ arm_saveusercontext:
mov r1, r0 /* R1: regs */
mov r0, #SYS_save_context /* R0: save context (also return value) */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* There are two return conditions. On the first return, R0 (the
* return value will be zero. On the second return we need to

View File

@ -94,7 +94,7 @@ up_signal_handler:
/* Execute the SYS_signal_handler_return SVCall (will not return) */
mov r0, #SYS_signal_handler_return
svc 0
svc #SYS_syscall
nop
.size up_signal_handler, .-up_signal_handler

View File

@ -72,7 +72,7 @@ arm_switchcontext:
mov r2, r1 /* R2: restoreregs */
mov r1, r0 /* R1: saveregs */
mov r0, #SYS_switch_context /* R0: context switch */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* We will get here only after the rerturn from the context switch */

View File

@ -70,7 +70,7 @@ arm_fullcontextrestore:
mov r1, r0 /* R1: regs */
mov r0, #SYS_restore_context /* R0: restore context */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* This call should not return */

View File

@ -71,7 +71,7 @@ arm_saveusercontext:
mov r1, r0 /* R1: regs */
mov r0, #SYS_save_context /* R0: save context (also return value) */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* There are two return conditions. On the first return, R0 (the
* return value will be zero. On the second return we need to

View File

@ -72,7 +72,7 @@ arm_switchcontext:
mov r2, r1 /* R2: restoreregs */
mov r1, r0 /* R1: saveregs */
mov r0, #SYS_switch_context /* R0: context switch */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* We will get here only after the rerturn from the context switch */

View File

@ -27,9 +27,7 @@
#include <nuttx/config.h>
#ifdef CONFIG_LIB_SYSCALL
# include <syscall.h>
#endif
#include <syscall.h>
/****************************************************************************
* Pre-processor Definitions

View File

@ -100,11 +100,11 @@ arm_fullcontextrestore:
* to either user or kernel mode.
*/
/* Perform the System call with R0=SYS_context_restore, R1=restoreregs */
/* Perform the System call with R0=1 and R1=regs */
mov r1, r0 /* R1: restoreregs */
mov r0, #SYS_context_restore /* R0: SYS_context_restore syscall */
svc #0x900001 /* Perform the system call */
mov r1, r0 /* R1: regs */
mov r0, #SYS_restore_context /* R0: restore context */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* This call should not return */

View File

@ -95,7 +95,7 @@ up_signal_handler:
/* Execute the SYS_signal_handler_return SVCall (will not return) */
mov r0, #SYS_signal_handler_return
svc 0
svc #SYS_syscall
nop
.size up_signal_handler, .-up_signal_handler

View File

@ -26,7 +26,6 @@
#include <stdint.h>
#include <string.h>
#include <syscall.h>
#include <assert.h>
#include <debug.h>
@ -214,19 +213,19 @@ uint32_t *arm_syscall(uint32_t *regs)
}
break;
/* R0=SYS_context_restore: Restore task context
/* R0=SYS_restore_context: Restore task context
*
* void arm_fullcontextrestore(uint32_t *restoreregs)
* noreturn_function;
*
* At this point, the following values are saved in context:
*
* R0 = SYS_context_restore
* R0 = SYS_restore_context
* R1 = restoreregs
*/
#ifdef CONFIG_BUILD_PROTECTED
case SYS_context_restore:
case SYS_restore_context:
{
/* Replace 'regs' with the pointer to the register set in
* regs[REG_R1]. On return from the system call, that register

View File

@ -27,9 +27,7 @@
#include <nuttx/config.h>
#ifdef CONFIG_LIB_SYSCALL
# include <syscall.h>
#endif
#include <syscall.h>
#ifdef CONFIG_LIB_SYSCALL
@ -74,7 +72,7 @@
* void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function;
*/
#define SYS_context_restore (1)
#define SYS_restore_context (1)
/* SYS call 2:
*

View File

@ -70,7 +70,7 @@ arm_fullcontextrestore:
mov r1, r0 /* R1: regs */
mov r0, #SYS_restore_context /* R0: restore context */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* This call should not return */

View File

@ -72,7 +72,7 @@ arm_saveusercontext:
mov r1, r0 /* R1: regs */
mov r0, #SYS_save_context /* R0: save context (also return value) */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* There are two return conditions. On the first return, R0 (the
* return value will be zero. On the second return we need to

View File

@ -94,7 +94,7 @@ up_signal_handler:
/* Execute the SYS_signal_handler_return SVCall (will not return) */
mov r0, #SYS_signal_handler_return
svc 0
svc #SYS_syscall
nop
.size up_signal_handler, .-up_signal_handler

View File

@ -33,10 +33,6 @@
#include <nuttx/sched.h>
#include <nuttx/userspace.h>
#ifdef CONFIG_LIB_SYSCALL
# include <syscall.h>
#endif
#include "signal/signal.h"
#include "svcall.h"
#include "exc_return.h"

View File

@ -72,7 +72,7 @@ arm_switchcontext:
mov r2, r1 /* R2: restoreregs */
mov r1, r0 /* R1: saveregs */
mov r0, #SYS_switch_context /* R0: context switch */
svc 0 /* Force synchronous SVCall (or Hard Fault) */
svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
/* We will get here only after the rerturn from the context switch */

View File

@ -27,9 +27,7 @@
#include <nuttx/config.h>
#ifdef CONFIG_LIB_SYSCALL
# include <syscall.h>
#endif
#include <syscall.h>
/****************************************************************************
* Pre-processor Definitions