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

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

commit b8fd06cf0eb329f883eec6e62ef7a533d2077269
Author: zhangyu117 <[email protected]>
AuthorDate: Thu Dec 12 11:18:57 2024 +0800

    arch/tricore: Inline up_switch_context
    
    inline up_switch_context, avoid function call burden.
    
    Signed-off-by: zhangyu117 <[email protected]>
---
 arch/tricore/include/irq.h                 | 15 +++++++++++++++
 arch/tricore/src/common/CMakeLists.txt     |  1 -
 arch/tricore/src/common/Make.defs          |  1 -
 arch/tricore/src/common/tricore_internal.h | 16 ++--------------
 4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/arch/tricore/include/irq.h b/arch/tricore/include/irq.h
index e472dddd863..0c1178673d6 100644
--- a/arch/tricore/include/irq.h
+++ b/arch/tricore/include/irq.h
@@ -34,6 +34,7 @@
 #include <sys/types.h>
 #ifndef __ASSEMBLY__
 #  include <stdbool.h>
+#  include <syscall.h>
 #endif
 
 /* Include NuttX-specific IRQ definitions */
@@ -211,6 +212,20 @@ static inline_function uintptr_t up_getusrsp(void *regs)
 
 #endif /* __ASSEMBLY__ */
 
+/****************************************************************************
+ * Name: up_switch_context
+ ****************************************************************************/
+
+#define up_switch_context(tcb, rtcb)                              \
+  do {                                                            \
+    if (!up_interrupt_context())                                  \
+      {                                                           \
+        nxsched_switch_context(rtcb, tcb);                        \
+        sys_call2(SYS_switch_context, (uintptr_t)&rtcb->xcp.regs, \
+                  (uintptr_t)tcb->xcp.regs);                      \
+      }                                                           \
+  } while (0)
+
 /****************************************************************************
  * Name: up_getusrpc
  ****************************************************************************/
diff --git a/arch/tricore/src/common/CMakeLists.txt 
b/arch/tricore/src/common/CMakeLists.txt
index 1183ed621e9..c0f55332edb 100644
--- a/arch/tricore/src/common/CMakeLists.txt
+++ b/arch/tricore/src/common/CMakeLists.txt
@@ -40,7 +40,6 @@ set(SRCS
     tricore_sigdeliver.c
     tricore_stackframe.c
     tricore_svcall.c
-    tricore_switchcontext.c
     tricore_tcbinfo.c
     tricore_trapcall.c
     tricore_systimer.c
diff --git a/arch/tricore/src/common/Make.defs 
b/arch/tricore/src/common/Make.defs
index c3e9c77dd30..8dbfbffd427 100644
--- a/arch/tricore/src/common/Make.defs
+++ b/arch/tricore/src/common/Make.defs
@@ -41,7 +41,6 @@ CMN_CSRCS += tricore_schedulesigaction.c
 CMN_CSRCS += tricore_sigdeliver.c
 CMN_CSRCS += tricore_stackframe.c
 CMN_CSRCS += tricore_svcall.c
-CMN_CSRCS += tricore_switchcontext.c
 CMN_CSRCS += tricore_tcbinfo.c
 CMN_CSRCS += tricore_trapcall.c
 CMN_CSRCS += tricore_systimer.c
diff --git a/arch/tricore/src/common/tricore_internal.h 
b/arch/tricore/src/common/tricore_internal.h
index ca1cf3a1512..e75faf4d551 100644
--- a/arch/tricore/src/common/tricore_internal.h
+++ b/arch/tricore/src/common/tricore_internal.h
@@ -131,20 +131,8 @@
 
 /* Context switching */
 
-#ifndef tricore_fullcontextrestore
-#  define tricore_fullcontextrestore(restoreregs) \
-    sys_call1(SYS_restore_context, (uintptr_t)restoreregs);
-#else
-extern void tricore_fullcontextrestore(uintptr_t *restoreregs);
-#endif
-
-#ifndef tricore_switchcontext
-#  define tricore_switchcontext(saveregs, restoreregs) \
-    sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs);
-#else
-extern void tricore_switchcontext(uintptr_t **saveregs,
-                                  uintptr_t *restoreregs);
-#endif
+#define tricore_fullcontextrestore(restoreregs) \
+  sys_call1(SYS_restore_context, (uintptr_t)restoreregs);
 
 /****************************************************************************
  * Public Types

Reply via email to