zhangyu-duck commented on code in PR #21355:
URL: https://github.com/apache/nuttx/pull/21355#discussion_r4522181067


##########
arch/tricore/include/irq.h:
##########
@@ -236,51 +233,74 @@ noinstrument_function static inline_function uintptr_t 
up_getsp(void)
  * Name: up_irq_save
  *
  * Description:
- *   Disable interrupts and return the previous value of the mstatus register
+ *   Disable interrupts and return the previous interrupt state.
+ *
+ *   When CONFIG_ARCH_HIPRI_INTERRUPT is enabled, this raises ICR.CCPN
+ *   to TRICORE_IRQ_DISABLE_PRIORITY so that high-priority interrupts
+ *   (SRPN > TRICORE_IRQ_DISABLE_PRIORITY) remain unmasked. up_irq_save
+ *   only raises CCPN, up_irq_restore only lowers it. This prevents the
+ *   masking level from being accidentally lowered.
+ *
+ *   Otherwise, uses the hardware disable instruction (ICR.IE = 0)
+ *   for minimal overhead.
  *
  ****************************************************************************/
 
 noinstrument_function static inline_function irqstate_t up_irq_save(void)
 {
+#ifdef CONFIG_ARCH_HIPRI_INTERRUPT
+  Ifx_CPU_ICR icr;
+  irqstate_t ccpn;
+
+  icr.U = tricore_mfcr(CPU_ICR);
+  ccpn  = icr.B.CCPN;
+
+  if (TRICORE_IRQ_DISABLE_PRIORITY > ccpn)

Review Comment:
   done, thanks



-- 
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