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

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

commit bba6fbab9db8e9057be8f11f8ab5e2a6a9c3606e
Author: zhangyu117 <[email protected]>
AuthorDate: Tue Aug 26 20:07:24 2025 +0800

    arch/tricore: return from trapcall by jump since it is entered by jump
    
    The current trapcall function comes in through the jump instruction, so
    the return method needs to be modified.
    
    Signed-off-by: zhangyu117 <[email protected]>
---
 arch/tricore/src/common/Ifx_Cfg_Trap.h     | 32 ++++++++++++++++++++++--------
 arch/tricore/src/common/tricore_trapcall.c | 17 +++++++---------
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/arch/tricore/src/common/Ifx_Cfg_Trap.h 
b/arch/tricore/src/common/Ifx_Cfg_Trap.h
index 15a22d3db4a..b014457689d 100644
--- a/arch/tricore/src/common/Ifx_Cfg_Trap.h
+++ b/arch/tricore/src/common/Ifx_Cfg_Trap.h
@@ -41,14 +41,13 @@
 
 /* Trap Call */
 
-#define IFX_CFG_CPU_TRAP_TSR_HOOK(trapInfo)             
tricore_trapcall(&trapInfo)
-#define IFX_CFG_CPU_TRAP_NMI_HOOK(trapInfo)             
tricore_trapcall(&trapInfo)
-#define IFX_CFG_CPU_TRAP_MME_HOOK(trapInfo)             
tricore_trapcall(&trapInfo)
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(trapInfo)             
tricore_trapcall(&trapInfo)
-#define IFX_CFG_CPU_TRAP_IE_HOOK(trapInfo)              
tricore_trapcall(&trapInfo)
-#define IFX_CFG_CPU_TRAP_CME_HOOK(trapInfo)             
tricore_trapcall(&trapInfo)
-#define IFX_CFG_CPU_TRAP_BE_HOOK(trapInfo)              
tricore_trapcall(&trapInfo)
-#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapInfo)          
tricore_trapcall(&trapInfo)
+#define IFX_CFG_CPU_TRAP_COMMON_HOOK(trapWatch)        \
+  do                                                   \
+    {                                                  \
+      Ifx__moveToAddrParam0((void *)&trapWatch);       \
+      Ifx__jumpToFunctionWithLink(tricore_trapcall);   \
+    }                                                  \
+  while (0)
 
 #define IFX_CFG_CPU_TRAP_SYSCALL_HOOK(trapWatch)       \
   do                                                   \
@@ -58,6 +57,23 @@
     }                                                  \
   while (0)
 
+#define IFX_CFG_CPU_TRAP_TSR_HOOK(trapWatch)           \
+  IFX_CFG_CPU_TRAP_COMMON_HOOK(trapWatch)
+#define IFX_CFG_CPU_TRAP_NMI_HOOK(trapWatch)           \
+  IFX_CFG_CPU_TRAP_COMMON_HOOK(trapWatch)
+#define IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch)           \
+  IFX_CFG_CPU_TRAP_COMMON_HOOK(trapWatch)
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(trapWatch)           \
+  IFX_CFG_CPU_TRAP_COMMON_HOOK(trapWatch)
+#define IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch)            \
+  IFX_CFG_CPU_TRAP_COMMON_HOOK(trapWatch)
+#define IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch)           \
+  IFX_CFG_CPU_TRAP_COMMON_HOOK(trapWatch)
+#define IFX_CFG_CPU_TRAP_BE_HOOK(trapWatch)            \
+  IFX_CFG_CPU_TRAP_COMMON_HOOK(trapWatch)
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch)        \
+  IFX_CFG_CPU_TRAP_COMMON_HOOK(trapWatch)
+
 #define IFX_CFG_CPU_TRAP_SYSCALL_CPU0_HOOK(trapWatch)  \
   IFX_CFG_CPU_TRAP_SYSCALL_HOOK(trapWatch)
 #define IFX_CFG_CPU_TRAP_SYSCALL_CPU1_HOOK(trapWatch)  \
diff --git a/arch/tricore/src/common/tricore_trapcall.c 
b/arch/tricore/src/common/tricore_trapcall.c
index 5dbb91c4c3e..589647088c7 100644
--- a/arch/tricore/src/common/tricore_trapcall.c
+++ b/arch/tricore/src/common/tricore_trapcall.c
@@ -333,7 +333,6 @@ int tricore_assertiontrap(uint32_t tid, void *context, void 
*arg)
 void tricore_trapcall(volatile void *trap)
 {
   uintptr_t *regs;
-  uintptr_t pcxi;
 
   IfxCpu_Trap *ctrap = (IfxCpu_Trap *)trap;
   IfxCpu_Trap_Class tclass = (IfxCpu_Trap_Class)ctrap->tClass;
@@ -342,8 +341,6 @@ void tricore_trapcall(volatile void *trap)
   tricore_trapinfo(trap);
 
   regs = tricore_csa2addr(tricore_mfcr(CPU_PCXI));
-  pcxi = regs[REG_UPCXI];
-  regs = tricore_csa2addr(pcxi);
 
   if (!up_interrupt_context())
     {
@@ -358,43 +355,43 @@ void tricore_trapcall(volatile void *trap)
     {
       tricore_nmitrap(tid, regs, NULL);
       up_set_interrupt_context(false);
-      return;
+      __jumpBackToLink();
     }
 
   if (tclass == IfxCpu_Trap_Class_memoryManagement)
     {
       tricore_mmutrap(tid, regs, NULL);
-      return;
+      __jumpBackToLink();
     }
 
   if (tclass == IfxCpu_Trap_Class_internalProtection)
     {
       tricore_internalprotrape(tid, regs, NULL);
-      return;
+      __jumpBackToLink();
     }
 
   if (tclass == IfxCpu_Trap_Class_instructionErrors)
     {
       tricore_insterrorstrap(tid, regs, NULL);
-      return;
+      __jumpBackToLink();
     }
 
   if (tclass == IfxCpu_Trap_Class_contextManagement)
     {
       tricore_contexmnttrap(tid, regs, NULL);
-      return;
+      __jumpBackToLink();
     }
 
   if (tclass == IfxCpu_Trap_Class_bus)
     {
       tricore_bustrap(tid, regs, NULL);
-      return;
+      __jumpBackToLink();
     }
 
   if (tclass == IfxCpu_Trap_Class_assertion)
     {
       tricore_assertiontrap(tid, regs, NULL);
-      return;
+      __jumpBackToLink();
     }
 
   up_irq_save();

Reply via email to