zyfeier commented on code in PR #19041:
URL: https://github.com/apache/nuttx/pull/19041#discussion_r3367098725


##########
arch/tricore/src/common/tricore_doirq.c:
##########
@@ -44,45 +42,50 @@
  * Public Functions
  ****************************************************************************/
 
-IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255)
+void __attribute__((interrupt_handler)) tricore_isr_handler(int irq)
 {
-  struct tcb_s **running_task = &g_running_tasks[this_cpu()];
-  struct tcb_s *tcb = this_task();
+  struct tcb_s *running_task = g_running_tasks[this_cpu()];
+  struct tcb_s *tcb;
 
 #ifdef CONFIG_SUPPRESS_INTERRUPTS
   PANIC();
 #else
-  Ifx_CPU_ICR icr;
   uintptr_t *regs;
 
-  icr.U = __mfcr(CPU_ICR);
-  regs = tricore_csa2addr(__mfcr(CPU_PCXI));
+  TRICORE_MFCR(TRICORE_CPU_PCXI, regs);
 
-  if (*running_task != NULL)
+  if (running_task != NULL)
     {
-      (*running_task)->xcp.regs = regs;
+      running_task->xcp.regs = regs;
     }
 
   board_autoled_on(LED_INIRQ);
 
   /* Nested interrupts are not supported */
 
-  DEBUGASSERT(!up_interrupt_context());
+  DEBUGASSERT(up_current_regs() == NULL);
 
-  /* Set irq flag */
+  /* Current regs non-zero indicates that we are processing an interrupt;
+   * current_regs is also used to manage interrupt level context switches.
+   */
 
-  up_set_interrupt_context(true);
+  up_set_current_regs(regs);
 
   /* Deliver the IRQ */
 
-  tricore_ack_irq(NDX_TO_IRQ(icr.B.CCPN));
+  irq_dispatch(irq, regs);
 
-  irq_dispatch(NDX_TO_IRQ(icr.B.CCPN), regs);
-
-  /* Check for a context switch. */
+  /* Check for a context switch.  If a context switch occurred, then
+   * g_current_regs will have a different value than it did on entry.  If an
+   * interrupt level context switch has occurred, then restore the floating
+   * point state and the establish the correct address environment before
+   * returning from the interrupt.
+   */
 
-  if (*running_task != tcb)

Review Comment:
   Why not use tcb directly for the comparison? It would be more 
straightforward.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to