This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 30b1e49aff45af0dace8de443039a7c90a407d95
Author: buxiasen <[email protected]>
AuthorDate: Fri Dec 19 20:40:30 2025 +0800

    arch/arm_m: merge v6/7/8-m svcall.c
    
    We should reduce the dup of code.
    
    Signed-off-by: buxiasen <[email protected]>
---
 arch/arm/src/arm_m/CMakeLists.txt            |   1 +
 arch/arm/src/arm_m/Make.defs                 |   2 +-
 arch/arm/src/{armv8-m => arm_m}/arm_svcall.c |   2 +-
 arch/arm/src/armv6-m/CMakeLists.txt          |   2 +-
 arch/arm/src/armv6-m/Make.defs               |   1 -
 arch/arm/src/armv6-m/arm_svcall.c            | 379 --------------------------
 arch/arm/src/armv7-m/CMakeLists.txt          |   3 +-
 arch/arm/src/armv7-m/Make.defs               |   3 +-
 arch/arm/src/armv7-m/arm_svcall.c            | 381 ---------------------------
 arch/arm/src/armv8-m/CMakeLists.txt          |   3 +-
 arch/arm/src/armv8-m/Make.defs               |   2 +-
 11 files changed, 8 insertions(+), 771 deletions(-)

diff --git a/arch/arm/src/arm_m/CMakeLists.txt 
b/arch/arm/src/arm_m/CMakeLists.txt
index d3af7e57ee9..b78671c8e7e 100644
--- a/arch/arm/src/arm_m/CMakeLists.txt
+++ b/arch/arm/src/arm_m/CMakeLists.txt
@@ -27,6 +27,7 @@ list(
   arm_busfault.c
   arm_hardfault.c
   arm_systemreset.c
+  arm_svcall.c
   arm_trigger_irq.c)
 
 if(NOT CONFIG_ARCH_ARMV6M)
diff --git a/arch/arm/src/arm_m/Make.defs b/arch/arm/src/arm_m/Make.defs
index 7c3c4147792..e3f1355604b 100644
--- a/arch/arm/src/arm_m/Make.defs
+++ b/arch/arm/src/arm_m/Make.defs
@@ -31,7 +31,7 @@ ifeq ($(CONFIG_LIB_SYSCALL),y)
 endif
 
 CMN_CSRCS += arm_tcbinfo.c arm_busfault.c arm_hardfault.c
-CMN_CSRCS += arm_systemreset.c arm_trigger_irq.c
+CMN_CSRCS += arm_systemreset.c arm_trigger_irq.c arm_svcall.c
 
 ifneq ($(CONFIG_ARCH_ARMV6M),y)
   CMN_CSRCS += arm_usagefault.c arm_memfault.c
diff --git a/arch/arm/src/armv8-m/arm_svcall.c b/arch/arm/src/arm_m/arm_svcall.c
similarity index 99%
rename from arch/arm/src/armv8-m/arm_svcall.c
rename to arch/arm/src/arm_m/arm_svcall.c
index 6e8204c0016..575764d3e69 100644
--- a/arch/arm/src/armv8-m/arm_svcall.c
+++ b/arch/arm/src/arm_m/arm_svcall.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm/src/armv8-m/arm_svcall.c
+ * arch/arm/src/arm_m/arm_svcall.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
diff --git a/arch/arm/src/armv6-m/CMakeLists.txt 
b/arch/arm/src/armv6-m/CMakeLists.txt
index cff43f8e9ef..e7c68a3128f 100644
--- a/arch/arm/src/armv6-m/CMakeLists.txt
+++ b/arch/arm/src/armv6-m/CMakeLists.txt
@@ -20,6 +20,6 @@
 #
 # 
##############################################################################
 
-set(SRCS arm_cpuinfo.c arm_doirq.c arm_initialstate.c arm_svcall.c)
+set(SRCS arm_doirq.c arm_initialstate.c arm_cpuinfo.c)
 
 target_sources(arch PRIVATE ${SRCS})
diff --git a/arch/arm/src/armv6-m/Make.defs b/arch/arm/src/armv6-m/Make.defs
index 3575f41d7d7..05b0e845c31 100644
--- a/arch/arm/src/armv6-m/Make.defs
+++ b/arch/arm/src/armv6-m/Make.defs
@@ -26,6 +26,5 @@ include common/Make.defs
 include arm_m/Make.defs
 
 CMN_CSRCS += arm_cpuinfo.c arm_doirq.c arm_initialstate.c
-CMN_CSRCS += arm_svcall.c
 
 VPATH += arm_m
diff --git a/arch/arm/src/armv6-m/arm_svcall.c 
b/arch/arm/src/armv6-m/arm_svcall.c
deleted file mode 100644
index 2d6a4b12011..00000000000
--- a/arch/arm/src/armv6-m/arm_svcall.c
+++ /dev/null
@@ -1,379 +0,0 @@
-/****************************************************************************
- * arch/arm/src/armv6-m/arm_svcall.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <inttypes.h>
-#include <stdint.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-#include <nuttx/debug.h>
-#include <syscall.h>
-
-#include <arch/irq.h>
-#include <nuttx/macro.h>
-#include <nuttx/sched.h>
-
-#include "sched/sched.h"
-#include "signal/signal.h"
-#include "exc_return.h"
-#include "arm_internal.h"
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: arm_svcall
- *
- * Description:
- *   This is SVCall exception handler that performs context switching
- *
- ****************************************************************************/
-
-int arm_svcall(int irq, void *context, void *arg)
-{
-  uint32_t *regs = (uint32_t *)context;
-  struct tcb_s *tcb;
-  uint32_t cmd;
-
-  cmd = regs[REG_R0];
-
-  /* The SVCall software interrupt is called with R0 = system call command
-   * and R1..R7 =  variable number of arguments depending on the system call.
-   */
-
-#ifdef CONFIG_DEBUG_SYSCALL_INFO
-#  ifndef CONFIG_DEBUG_SVCALL
-  if (cmd > SYS_switch_context)
-#  endif
-    {
-      svcinfo("SVCALL Entry: regs: %p cmd: %d\n", regs, cmd);
-      svcinfo("  R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
-              regs[REG_R0],  regs[REG_R1],  regs[REG_R2],  regs[REG_R3],
-              regs[REG_R4],  regs[REG_R5],  regs[REG_R6],  regs[REG_R7]);
-      svcinfo("  R8: %08x %08x %08x %08x %08x %08x %08x %08x\n",
-              regs[REG_R8],  regs[REG_R9],  regs[REG_R10], regs[REG_R11],
-              regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]);
-      svcinfo(" PSR: %08x PRIMASK: %08x EXC_RETURN: %08x\n",
-              regs[REG_XPSR], regs[REG_PRIMASK], regs[REG_EXC_RETURN]);
-    }
-#endif
-
-  /* Handle the SVCall according to the command in R0 */
-
-  switch (cmd)
-    {
-      case SYS_restore_context:
-      case SYS_switch_context:
-        {
-          tcb = this_task();
-          restore_critical_section(tcb, this_cpu());
-
-#ifdef CONFIG_DEBUG_SYSCALL_INFO
-          regs = tcb->xcp.regs;
-#endif
-        }
-        break;
-
-      /* R0=SYS_syscall_return:  This a syscall return command:
-       *
-       *   void arm_syscall_return(void);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_syscall_return
-       *
-       * We need to restore the saved return address and return in
-       * unprivileged thread mode.
-       */
-
-#ifdef CONFIG_LIB_SYSCALL
-      case SYS_syscall_return:
-        {
-          struct tcb_s *rtcb = this_task();
-          int index = (int)rtcb->xcp.nsyscalls - 1;
-
-          /* Make sure that there is a saved syscall return address. */
-
-          DEBUGASSERT(index >= 0);
-
-          /* Setup to return to the saved syscall return address in
-           * the original mode.
-           */
-
-          regs[REG_PC]         = rtcb->xcp.syscall[index].sysreturn;
-          regs[REG_EXC_RETURN] = rtcb->xcp.syscall[index].excreturn;
-          regs[REG_CONTROL]    = rtcb->xcp.syscall[index].ctrlreturn;
-          rtcb->xcp.nsyscalls  = index;
-
-          /* The return value must be in R0-R1.  arm_dispatch_syscall()
-           * temporarily moved the value for R0 into R2.
-           */
-
-          regs[REG_R0]         = regs[REG_R2];
-
-          /* Handle any signal actions that were deferred while processing
-           * the system call.
-           */
-
-          rtcb->flags          &= ~TCB_FLAG_SYSCALL;
-          nxsig_unmask_pendingsignal();
-        }
-        break;
-#endif
-
-      /* R0=SYS_task_start:  This a user task start
-       *
-       *   void up_task_start(main_t taskentry, int argc, char *argv[])
-       *     noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_task_start
-       *   R1 = taskentry
-       *   R2 = argc
-       *   R3 = argv
-       */
-
-#ifdef CONFIG_BUILD_PROTECTED
-      case SYS_task_start:
-        {
-          /* Set up to return to the user-space task start-up function in
-           * unprivileged mode.
-           */
-
-          regs[REG_PC]         = (uint32_t)USERSPACE->task_startup;
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return unprivileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() | CONTROL_NPRIV;
-
-          /* Change the parameter ordering to match the expectation of struct
-           * userpace_s task_startup:
-           */
-
-          regs[REG_R0]         = regs[REG_R1]; /* Task entry */
-          regs[REG_R1]         = regs[REG_R2]; /* argc */
-          regs[REG_R2]         = regs[REG_R3]; /* argv */
-        }
-        break;
-#endif
-
-      /* R0=SYS_pthread_start:  This a user pthread start
-       *
-       *   void up_pthread_start(pthread_startroutine_t entrypt,
-       *                         pthread_addr_t arg) noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_pthread_start
-       *   R1 = entrypt
-       *   R2 = arg
-       */
-
-#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
-      case SYS_pthread_start:
-        {
-          /* Set up to return to the user-space pthread start-up function in
-           * unprivileged mode.
-           */
-
-          regs[REG_PC]         = (uint32_t)regs[REG_R1]; /* startup */
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return unprivileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() | CONTROL_NPRIV;
-
-          /* Change the parameter ordering to match the expectation of the
-           * user space pthread_startup:
-           */
-
-          regs[REG_R0]         = regs[REG_R2]; /* pthread entry */
-          regs[REG_R1]         = regs[REG_R3]; /* arg */
-        }
-        break;
-#endif
-
-      /* R0=SYS_signal_handler:  This a user signal handler callback
-       *
-       * void signal_handler(_sa_sigaction_t sighand, int signo,
-       *                     siginfo_t *info, void *ucontext);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_signal_handler
-       *   R1 = sighand
-       *   R2 = signo
-       *   R3 = info
-       *   R4 = ucontext
-       */
-
-#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
-      case SYS_signal_handler:
-        {
-          struct tcb_s *rtcb   = this_task();
-
-          /* Remember the caller's return address */
-
-          DEBUGASSERT(rtcb->xcp.sigreturn == 0);
-          rtcb->xcp.sigreturn  = regs[REG_PC];
-
-          /* Set up to return to the user-space trampoline function in
-           * unprivileged mode.
-           */
-
-          regs[REG_PC]         = (uint32_t)USERSPACE->signal_handler;
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return unprivileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() | CONTROL_NPRIV;
-
-          /* Change the parameter ordering to match the expectation of struct
-           * userpace_s signal_handler.
-           */
-
-          regs[REG_R0]         = regs[REG_R1]; /* sighand */
-          regs[REG_R1]         = regs[REG_R2]; /* signal */
-          regs[REG_R2]         = regs[REG_R3]; /* info */
-          regs[REG_R3]         = regs[REG_R4]; /* ucontext */
-        }
-        break;
-#endif
-
-      /* R0=SYS_signal_handler_return:  This a user signal handler callback
-       *
-       *   void signal_handler_return(void);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_signal_handler_return
-       */
-
-#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
-      case SYS_signal_handler_return:
-        {
-          struct tcb_s *rtcb   = this_task();
-
-          /* Set up to return to the kernel-mode signal dispatching logic. */
-
-          DEBUGASSERT(rtcb->xcp.sigreturn != 0);
-
-          regs[REG_PC]         = rtcb->xcp.sigreturn;
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return privileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() & ~CONTROL_NPRIV;
-          rtcb->xcp.sigreturn  = 0;
-        }
-        break;
-#endif
-
-      /* This is not an architecture-specific system call.  If NuttX is built
-       * as a standalone kernel with a system call interface, then all of the
-       * additional system calls must be handled as in the default case.
-       */
-
-      default:
-        {
-#ifdef CONFIG_LIB_SYSCALL
-          struct tcb_s *rtcb = this_task();
-          int index = rtcb->xcp.nsyscalls;
-
-          if (cmd < CONFIG_SYS_RESERVED || cmd >= SYS_maxsyscall ||
-              index >= CONFIG_SYS_NNEST)
-            {
-              regs[REG_R0] = -ENOSYS;
-              break;
-            }
-
-          /* Use ip to create a debug frame.
-           * we can use gdb backtrace from syscall to user space.
-           */
-
-          regs[REG_IP] = regs[REG_PC];
-
-          /* Setup to return to arm_dispatch_syscall in privileged mode. */
-
-          rtcb->xcp.syscall[index].sysreturn  = regs[REG_PC];
-          rtcb->xcp.syscall[index].excreturn  = regs[REG_EXC_RETURN];
-          rtcb->xcp.syscall[index].ctrlreturn = regs[REG_CONTROL];
-          rtcb->xcp.nsyscalls  = index + 1;
-
-          regs[REG_PC]         = (uint32_t)arm_dispatch_syscall;
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return privileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() & ~CONTROL_NPRIV;
-
-          /* Offset R0 to account for the reserved values */
-
-          regs[REG_R0]        -= CONFIG_SYS_RESERVED;
-
-          /* Indicate that we are in a syscall handler. */
-
-          rtcb->flags         |= TCB_FLAG_SYSCALL;
-#else
-          svcerr("ERROR: Bad SYS call: %" PRId32 "\n", regs[REG_R0]);
-#endif
-        }
-        break;
-    }
-
-  /* Report what happened.  That might difficult in the case of a context
-   * switch.
-   */
-
-#ifdef CONFIG_DEBUG_SYSCALL_INFO
-#  ifndef CONFIG_DEBUG_SVCALL
-  if (cmd > SYS_switch_context)
-#  endif
-    {
-      svcinfo("SVCall Return:\n");
-      svcinfo("  R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
-              regs[REG_R0],  regs[REG_R1], regs[REG_R2],  regs[REG_R3],
-              regs[REG_R4],  regs[REG_R5], regs[REG_R6],  regs[REG_R7]);
-      svcinfo("  R8: %08x %08x %08x %08x %08x %08x %08x %08x\n",
-              regs[REG_R8],  regs[REG_R9], regs[REG_R10], regs[REG_R11],
-              regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]);
-      svcinfo(" PSR: %08x EXC_RETURN: %08x CONTROL: %08x\n",
-              regs[REG_XPSR], regs[REG_EXC_RETURN], regs[REG_CONTROL]);
-    }
-#endif
-
-  UNUSED(tcb);
-  return OK;
-}
diff --git a/arch/arm/src/armv7-m/CMakeLists.txt 
b/arch/arm/src/armv7-m/CMakeLists.txt
index 0dd3c810c96..951f991398c 100644
--- a/arch/arm/src/armv7-m/CMakeLists.txt
+++ b/arch/arm/src/armv7-m/CMakeLists.txt
@@ -29,8 +29,7 @@ set(SRCS
     arm_doirq.c
     arm_initialstate.c
     arm_itm.c
-    arm_perf.c
-    arm_svcall.c)
+    arm_perf.c)
 
 if(CONFIG_ARMV7M_ITMSYSLOG)
   list(APPEND SRCS arm_itm_syslog.c)
diff --git a/arch/arm/src/armv7-m/Make.defs b/arch/arm/src/armv7-m/Make.defs
index 2e8605d5ead..a05521d409a 100644
--- a/arch/arm/src/armv7-m/Make.defs
+++ b/arch/arm/src/armv7-m/Make.defs
@@ -26,8 +26,7 @@ include common/Make.defs
 include arm_m/Make.defs
 
 CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_doirq.c arm_initialstate.c
-CMN_CSRCS += arm_itm.c arm_perf.c arm_svcall.c
-CMN_CSRCS += arm_dbgmonitor.c
+CMN_CSRCS += arm_itm.c arm_perf.c arm_dbgmonitor.c
 
 ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y)
   CMN_CSRCS += arm_itm_syslog.c
diff --git a/arch/arm/src/armv7-m/arm_svcall.c 
b/arch/arm/src/armv7-m/arm_svcall.c
deleted file mode 100644
index ac1ff9deb50..00000000000
--- a/arch/arm/src/armv7-m/arm_svcall.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/****************************************************************************
- * arch/arm/src/armv7-m/arm_svcall.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <inttypes.h>
-#include <stdint.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-#include <nuttx/debug.h>
-#include <syscall.h>
-
-#include <arch/irq.h>
-#include <nuttx/macro.h>
-#include <nuttx/sched.h>
-#include <nuttx/userspace.h>
-
-#include "sched/sched.h"
-#include "signal/signal.h"
-#include "exc_return.h"
-#include "arm_internal.h"
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: arm_svcall
- *
- * Description:
- *   This is SVCall exception handler that performs context switching
- *
- ****************************************************************************/
-
-int arm_svcall(int irq, void *context, void *arg)
-{
-  uint32_t *regs = (uint32_t *)context;
-  struct tcb_s *tcb;
-  uint32_t cmd;
-
-  cmd = regs[REG_R0];
-
-  /* The SVCall software interrupt is called with R0 = system call command
-   * and R1..R7 =  variable number of arguments depending on the system call.
-   */
-
-#ifdef CONFIG_DEBUG_SYSCALL_INFO
-#  ifndef CONFIG_DEBUG_SVCALL
-  if (cmd > SYS_switch_context)
-#  endif
-    {
-      svcinfo("SVCALL Entry: regs: %p cmd: %d\n", regs, cmd);
-      svcinfo("  R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
-              regs[REG_R0],  regs[REG_R1],  regs[REG_R2],  regs[REG_R3],
-              regs[REG_R4],  regs[REG_R5],  regs[REG_R6],  regs[REG_R7]);
-      svcinfo("  R8: %08x %08x %08x %08x %08x %08x %08x %08x\n",
-              regs[REG_R8],  regs[REG_R9],  regs[REG_R10], regs[REG_R11],
-              regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]);
-      svcinfo(" PSR: %08x EXC_RETURN: %08x CONTROL: %08x\n",
-              regs[REG_XPSR], regs[REG_EXC_RETURN], regs[REG_CONTROL]);
-    }
-#endif
-
-  /* Handle the SVCall according to the command in R0 */
-
-  switch (cmd)
-    {
-      case SYS_restore_context:
-      case SYS_switch_context:
-        {
-          tcb = this_task();
-          restore_critical_section(tcb, this_cpu());
-
-#ifdef CONFIG_DEBUG_SYSCALL_INFO
-          regs = tcb->xcp.regs;
-#endif
-        }
-        break;
-
-      /* R0=SYS_syscall_return:  This a syscall return command:
-       *
-       *   void arm_syscall_return(void);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_syscall_return
-       *
-       * We need to restore the saved return address and return in
-       * unprivileged thread mode.
-       */
-
-#ifdef CONFIG_LIB_SYSCALL
-      case SYS_syscall_return:
-        {
-          struct tcb_s *rtcb = this_task();
-          int index = (int)rtcb->xcp.nsyscalls - 1;
-
-          /* Make sure that there is a saved syscall return address. */
-
-          DEBUGASSERT(index >= 0);
-
-          /* Setup to return to the saved syscall return address in
-           * the original mode.
-           */
-
-          regs[REG_PC]         = rtcb->xcp.syscall[index].sysreturn;
-          regs[REG_EXC_RETURN] = rtcb->xcp.syscall[index].excreturn;
-          regs[REG_CONTROL]    = rtcb->xcp.syscall[index].ctrlreturn;
-          rtcb->xcp.nsyscalls  = index;
-
-          /* The return value must be in R0-R1.  arm_dispatch_syscall()
-           * temporarily moved the value for R0 into R2.
-           */
-
-          regs[REG_R0]         = regs[REG_R2];
-
-          /* Handle any signal actions that were deferred while processing
-           * the system call.
-           */
-
-          rtcb->flags          &= ~TCB_FLAG_SYSCALL;
-          nxsig_unmask_pendingsignal();
-        }
-        break;
-#endif
-
-      /* R0=SYS_task_start:  This a user task start
-       *
-       *   void up_task_start(main_t taskentry, int argc, char *argv[])
-       *          noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_task_start
-       *   R1 = taskentry
-       *   R2 = argc
-       *   R3 = argv
-       */
-
-#ifdef CONFIG_BUILD_PROTECTED
-      case SYS_task_start:
-        {
-          /* Set up to return to the user-space task start-up function in
-           * unprivileged mode.
-           */
-
-          regs[REG_PC]         = (uint32_t)USERSPACE->task_startup & ~1;
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return unprivileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() | CONTROL_NPRIV;
-
-          /* Change the parameter ordering to match the expectation of struct
-           * userpace_s task_startup:
-           */
-
-          regs[REG_R0]         = regs[REG_R1]; /* Task entry */
-          regs[REG_R1]         = regs[REG_R2]; /* argc */
-          regs[REG_R2]         = regs[REG_R3]; /* argv */
-        }
-        break;
-#endif
-
-      /* R0=SYS_pthread_start:  This a user pthread start
-       *
-       *   void up_pthread_start(pthread_startroutine_t entrypt,
-       *                         pthread_addr_t arg) noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_pthread_start
-       *   R1 = startup (trampoline)
-       *   R2 = entrypt
-       *   R3 = arg
-       */
-
-#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
-      case SYS_pthread_start:
-        {
-          /* Set up to return to the user-space pthread start-up function in
-           * unprivileged mode.
-           */
-
-          regs[REG_PC]         = (uint32_t)regs[REG_R1] & ~1;  /* startup */
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return unprivileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() | CONTROL_NPRIV;
-
-          /* Change the parameter ordering to match the expectation of the
-           * user space pthread_startup:
-           */
-
-          regs[REG_R0]         = regs[REG_R2]; /* pthread entry */
-          regs[REG_R1]         = regs[REG_R3]; /* arg */
-        }
-        break;
-#endif
-
-      /* R0=SYS_signal_handler:  This a user signal handler callback
-       *
-       * void signal_handler(_sa_sigaction_t sighand, int signo,
-       *                     siginfo_t *info, void *ucontext);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_signal_handler
-       *   R1 = sighand
-       *   R2 = signo
-       *   R3 = info
-       *   R4 = ucontext
-       */
-
-#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
-      case SYS_signal_handler:
-        {
-          struct tcb_s *rtcb   = this_task();
-
-          /* Remember the caller's return address */
-
-          DEBUGASSERT(rtcb->xcp.sigreturn == 0);
-          rtcb->xcp.sigreturn  = regs[REG_PC];
-
-          /* Set up to return to the user-space trampoline function in
-           * unprivileged mode.
-           */
-
-          regs[REG_PC]         = (uint32_t)USERSPACE->signal_handler & ~1;
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return unprivileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() | CONTROL_NPRIV;
-
-          /* Change the parameter ordering to match the expectation of struct
-           * userpace_s signal_handler.
-           */
-
-          regs[REG_R0]         = regs[REG_R1]; /* sighand */
-          regs[REG_R1]         = regs[REG_R2]; /* signal */
-          regs[REG_R2]         = regs[REG_R3]; /* info */
-          regs[REG_R3]         = regs[REG_R4]; /* ucontext */
-        }
-        break;
-#endif
-
-      /* R0=SYS_signal_handler_return:  This a user signal handler callback
-       *
-       *   void signal_handler_return(void);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_signal_handler_return
-       */
-
-#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
-      case SYS_signal_handler_return:
-        {
-          struct tcb_s *rtcb   = this_task();
-
-          /* Set up to return to the kernel-mode signal dispatching logic. */
-
-          DEBUGASSERT(rtcb->xcp.sigreturn != 0);
-
-          regs[REG_PC]         = rtcb->xcp.sigreturn & ~1;
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return privileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() & ~CONTROL_NPRIV;
-          rtcb->xcp.sigreturn  = 0;
-        }
-        break;
-#endif
-
-      /* This is not an architecture-specific system call.  If NuttX is built
-       * as a standalone kernel with a system call interface, then all of the
-       * additional system calls must be handled as in the default case.
-       */
-
-      default:
-        {
-#ifdef CONFIG_LIB_SYSCALL
-          struct tcb_s *rtcb = this_task();
-          int index = rtcb->xcp.nsyscalls;
-
-          if (cmd < CONFIG_SYS_RESERVED || cmd >= SYS_maxsyscall ||
-              index >= CONFIG_SYS_NNEST)
-            {
-              regs[REG_R0] = -ENOSYS;
-              break;
-            }
-
-          /* Use ip to create a debug frame.
-           * we can use gdb backtrace from syscall to user space.
-           */
-
-          regs[REG_IP] = regs[REG_PC];
-
-          /* Setup to return to arm_dispatch_syscall in privileged mode. */
-
-          rtcb->xcp.syscall[index].sysreturn  = regs[REG_PC];
-          rtcb->xcp.syscall[index].excreturn  = regs[REG_EXC_RETURN];
-          rtcb->xcp.syscall[index].ctrlreturn = regs[REG_CONTROL];
-          rtcb->xcp.nsyscalls  = index + 1;
-
-          regs[REG_PC]         = (uint32_t)arm_dispatch_syscall & ~1;
-          regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-          /* Return privileged mode */
-
-          regs[REG_CONTROL]    = getcontrol() & ~CONTROL_NPRIV;
-
-          /* Offset R0 to account for the reserved values */
-
-          regs[REG_R0]        -= CONFIG_SYS_RESERVED;
-
-          /* Indicate that we are in a syscall handler. */
-
-          rtcb->flags         |= TCB_FLAG_SYSCALL;
-#else
-          svcerr("ERROR: Bad SYS call: %" PRId32 "\n", regs[REG_R0]);
-#endif
-        }
-        break;
-    }
-
-  /* Report what happened.  That might difficult in the case of a context
-   * switch.
-   */
-
-#ifdef CONFIG_DEBUG_SYSCALL_INFO
-#  ifndef CONFIG_DEBUG_SVCALL
-  if (cmd > SYS_switch_context)
-#  endif
-    {
-      svcinfo("SVCall Return:\n");
-      svcinfo("  R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
-              regs[REG_R0],  regs[REG_R1], regs[REG_R2],  regs[REG_R3],
-              regs[REG_R4],  regs[REG_R5], regs[REG_R6],  regs[REG_R7]);
-      svcinfo("  R8: %08x %08x %08x %08x %08x %08x %08x %08x\n",
-              regs[REG_R8],  regs[REG_R9], regs[REG_R10], regs[REG_R11],
-              regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]);
-      svcinfo(" PSR: %08x EXC_RETURN: %08x CONTROL: %08x\n",
-              regs[REG_XPSR], regs[REG_EXC_RETURN], regs[REG_CONTROL]);
-    }
-#endif
-
-  UNUSED(tcb);
-  return OK;
-}
diff --git a/arch/arm/src/armv8-m/CMakeLists.txt 
b/arch/arm/src/armv8-m/CMakeLists.txt
index 926cd7530da..1f2843369b2 100644
--- a/arch/arm/src/armv8-m/CMakeLists.txt
+++ b/arch/arm/src/armv8-m/CMakeLists.txt
@@ -29,8 +29,7 @@ set(SRCS
     arm_itm.c
     arm_perf.c
     arm_sau.c
-    arm_secure_irq.c
-    arm_svcall.c)
+    arm_secure_irq.c)
 
 if(CONFIG_ARMV8M_ITMSYSLOG)
   list(APPEND SRCS arm_itm_syslog.c)
diff --git a/arch/arm/src/armv8-m/Make.defs b/arch/arm/src/armv8-m/Make.defs
index 6230cd197e5..d01f70fcc9a 100644
--- a/arch/arm/src/armv8-m/Make.defs
+++ b/arch/arm/src/armv8-m/Make.defs
@@ -26,7 +26,7 @@ include common/Make.defs
 include arm_m/Make.defs
 
 CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_doirq.c arm_initialstate.c
-CMN_CSRCS += arm_itm.c arm_perf.c arm_sau.c arm_secure_irq.c arm_svcall.c
+CMN_CSRCS += arm_itm.c arm_perf.c arm_sau.c arm_secure_irq.c
 CMN_CSRCS += arm_dbgmonitor.c
 
 ifeq ($(CONFIG_ARMV8M_ITMSYSLOG),y)

Reply via email to