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 3fd185111fdb47b8bae0ea452f8b0e13ab9d579e
Author: Saravanan Sekar <[email protected]>
AuthorDate: Fri Nov 6 15:45:47 2026 +0530

    arch/tricore: Share the return of the handlers entered with jli.
    
    tricore_svcall, tricore_trapcall and tricore_doirq are entered from the
    vectors with jli and return with ji a11, and each spells that out with
    the same TASKING and GCC variants.  Add tricore_jump_backto_link to
    arch/arch.h and use it in all three.
    
    Signed-off-by: Saravanan Sekar <[email protected]>
---
 arch/tricore/include/arch.h                | 10 ++++++++++
 arch/tricore/src/common/tricore_doirq.c    | 14 +-------------
 arch/tricore/src/common/tricore_svcall.c   |  6 +-----
 arch/tricore/src/common/tricore_trapcall.c | 12 ++----------
 4 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/arch/tricore/include/arch.h b/arch/tricore/include/arch.h
index 1230a616792..7076edb0ff2 100644
--- a/arch/tricore/include/arch.h
+++ b/arch/tricore/include/arch.h
@@ -59,6 +59,16 @@
     __val;                                                             \
   })
 
+/* Return from a handler that the trap or interrupt vector entered with
+ * jli, to the vector code at A11.
+ */
+
+#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
+#  define tricore_jump_backto_link() __asm__ volatile ("ji a11" : : : "a11")
+#else
+#  define tricore_jump_backto_link() __asm__ volatile ("ji %a11")
+#endif
+
 /****************************************************************************
  * Public Types
  ****************************************************************************/
diff --git a/arch/tricore/src/common/tricore_doirq.c 
b/arch/tricore/src/common/tricore_doirq.c
index b4c7148afc6..a834a4df734 100644
--- a/arch/tricore/src/common/tricore_doirq.c
+++ b/arch/tricore/src/common/tricore_doirq.c
@@ -41,18 +41,6 @@
 
 #include "tricore_internal.h"
 
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/* The interrupt vector enters tricore_doirq with jli, return with ji */
-
-#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
-#  define tricore_irq_return() __asm__ volatile ("ji a11" : : : "a11")
-#else
-#  define tricore_irq_return() __asm__ volatile ("ji %a11")
-#endif
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -141,5 +129,5 @@ void tricore_doirq(void)
   board_autoled_off(LED_INIRQ);
 #endif
 
-  tricore_irq_return();
+  tricore_jump_backto_link();
 }
diff --git a/arch/tricore/src/common/tricore_svcall.c 
b/arch/tricore/src/common/tricore_svcall.c
index 42685a23690..aca3c516edf 100644
--- a/arch/tricore/src/common/tricore_svcall.c
+++ b/arch/tricore/src/common/tricore_svcall.c
@@ -109,9 +109,5 @@ void tricore_svcall(volatile void *trap)
 
   /* Return to the caller, tricore_svcall is entered by a jump */
 
-#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
-  __asm__ volatile ("ji a11" : : : "a11");
-#else
-  __asm__ volatile ("ji %a11");
-#endif
+  tricore_jump_backto_link();
 }
diff --git a/arch/tricore/src/common/tricore_trapcall.c 
b/arch/tricore/src/common/tricore_trapcall.c
index 2ca7145b83d..f9380931f99 100644
--- a/arch/tricore/src/common/tricore_trapcall.c
+++ b/arch/tricore/src/common/tricore_trapcall.c
@@ -93,14 +93,6 @@
 #define TRICORE_TIN_OVF           1  /* Class 5: arithmetic overflow */
 #define TRICORE_TIN_SOVF          2  /* Class 5: sticky overflow */
 
-/* The trap vectors enter tricore_trapcall with jli, return with ji */
-
-#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
-#  define tricore_trap_return() __asm__ volatile ("ji a11" : : : "a11")
-#else
-#  define tricore_trap_return() __asm__ volatile ("ji %a11")
-#endif
-
 /* Panic message of a trap, "Trap c=<class> t=<TIN>" */
 
 #define TRICORE_TRAP_MSG_LEN      24
@@ -338,7 +330,7 @@ void tricore_trapcall(volatile void *trap)
     {
       tricore_nmitrap(tid, regs, NULL);
       up_set_interrupt_context(false);
-      tricore_trap_return();
+      tricore_jump_backto_link();
     }
 
   /* A bus trap hook of a safety test module (e.g., BusMonTst) may handle
@@ -359,7 +351,7 @@ void tricore_trapcall(volatile void *trap)
           g_running_tasks[this_cpu()]->xcp.regs = NULL;
         }
 
-      tricore_trap_return();
+      tricore_jump_backto_link();
     }
 
   tricore_trap_fpu(tclass, tid);

Reply via email to