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 69ed5f54f304cc0323c21aa576f858bfdab37c12 Author: zhangyu117 <[email protected]> AuthorDate: Tue Dec 10 16:59:10 2024 +0800 tricore: remove up_set_current_regs/up_current_regs add g_interrupt_context to to identify interruption context Signed-off-by: zhangyu117 <[email protected]> --- arch/tricore/include/irq.h | 45 +++++++++------------- arch/tricore/src/common/tricore_doirq.c | 21 +++------- arch/tricore/src/common/tricore_initialize.c | 4 +- .../tricore/src/common/tricore_schedulesigaction.c | 2 +- arch/tricore/src/common/tricore_svcall.c | 8 +++- arch/tricore/src/common/tricore_switchcontext.c | 2 +- arch/tricore/src/common/tricore_trapcall.c | 4 +- tools/nxstyle.c | 2 + 8 files changed, 39 insertions(+), 49 deletions(-) diff --git a/arch/tricore/include/irq.h b/arch/tricore/include/irq.h index 592ba712561..e472dddd863 100644 --- a/arch/tricore/include/irq.h +++ b/arch/tricore/include/irq.h @@ -73,17 +73,9 @@ extern "C" * Public Data ****************************************************************************/ -/* g_current_regs[] holds a references to the current interrupt level - * register storage structure. If is non-NULL only during interrupt - * processing. Access to g_current_regs[] must be through the macro - * g_current_regs for portability. - */ - -/* For the case of architectures with multiple CPUs, then there must be one - * such value for each processor that can receive an interrupt. - */ +/* g_interrupt_context store irq status */ -EXTERN volatile uintptr_t *g_current_regs[CONFIG_SMP_NCPUS]; +EXTERN volatile bool g_interrupt_context[CONFIG_SMP_NCPUS]; /**************************************************************************** * Public Function Prototypes @@ -155,21 +147,21 @@ void up_irq_restore(irqstate_t flags) * Inline Functions ****************************************************************************/ -static inline_function uintptr_t *up_current_regs(void) -{ -#ifdef CONFIG_SMP - return (uintptr_t *)g_current_regs[up_cpu_index()]; -#else - return (uintptr_t *)g_current_regs[0]; -#endif -} +/**************************************************************************** + * Name: up_set_interrupt_context + * + * Description: + * Set the interrupt handler context. + * + ****************************************************************************/ -static inline_function void up_set_current_regs(uintptr_t *regs) +noinstrument_function +static inline_function void up_set_interrupt_context(bool flag) { #ifdef CONFIG_SMP - g_current_regs[up_cpu_index()] = regs; + g_interrupt_context[up_this_cpu()] = flag; #else - g_current_regs[0] = regs; + g_interrupt_context[0] = flag; #endif } @@ -187,15 +179,14 @@ static inline_function bool up_interrupt_context(void) { #ifdef CONFIG_SMP irqstate_t flags = up_irq_save(); -#endif + bool ret = g_interrupt_context[up_this_cpu()]; - bool ret = up_current_regs() != NULL; - -#ifdef CONFIG_SMP up_irq_restore(flags); -#endif return ret; +#else + return g_interrupt_context[0]; +#endif } /**************************************************************************** @@ -225,7 +216,7 @@ static inline_function uintptr_t up_getusrsp(void *regs) ****************************************************************************/ #define up_getusrpc(regs) \ - (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_UPC]) + (((uint32_t *)((regs) ? (regs) : running_regs()))[REG_UPC]) #undef EXTERN #ifdef __cplusplus diff --git a/arch/tricore/src/common/tricore_doirq.c b/arch/tricore/src/common/tricore_doirq.c index 7d5a7278cc6..228cb2de744 100644 --- a/arch/tricore/src/common/tricore_doirq.c +++ b/arch/tricore/src/common/tricore_doirq.c @@ -67,13 +67,11 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255) /* Nested interrupts are not supported */ - DEBUGASSERT(up_current_regs() == NULL); + DEBUGASSERT(!up_interrupt_context()); - /* Current regs non-zero indicates that we are processing an interrupt; - * current_regs is also used to manage interrupt level context switches. - */ + /* Set irq flag */ - up_set_current_regs(regs); + up_set_interrupt_context(true); /* Deliver the IRQ */ @@ -81,12 +79,7 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255) tcb = this_task(); - /* 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. - */ + /* Check for a context switch. */ if (regs != tcb->xcp.regs) { @@ -116,11 +109,9 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255) __isync(); } - /* Set current_regs to NULL to indicate that we are no longer in an - * interrupt handler. - */ + /* Set irq flag */ - up_set_current_regs(NULL); + up_set_interrupt_context(false); /* running_task->xcp.regs is about to become invalid * and will be marked as NULL to avoid misusage. diff --git a/arch/tricore/src/common/tricore_initialize.c b/arch/tricore/src/common/tricore_initialize.c index 9fa6ac84468..ec8377cbcb5 100644 --- a/arch/tricore/src/common/tricore_initialize.c +++ b/arch/tricore/src/common/tricore_initialize.c @@ -34,7 +34,9 @@ * Public Data ****************************************************************************/ -volatile uintptr_t *g_current_regs[CONFIG_SMP_NCPUS]; +/* g_interrupt_context store irq status */ + +volatile bool g_interrupt_context[CONFIG_SMP_NCPUS]; /**************************************************************************** * Public Functions diff --git a/arch/tricore/src/common/tricore_schedulesigaction.c b/arch/tricore/src/common/tricore_schedulesigaction.c index 4eb548b284d..3f4662077cb 100644 --- a/arch/tricore/src/common/tricore_schedulesigaction.c +++ b/arch/tricore/src/common/tricore_schedulesigaction.c @@ -90,7 +90,7 @@ void up_schedule_sigaction(struct tcb_s *tcb) * a task is signalling itself for some reason. */ - if (up_current_regs() == NULL) + if (!up_interrupt_context()) { /* In this case just deliver the signal now. */ diff --git a/arch/tricore/src/common/tricore_svcall.c b/arch/tricore/src/common/tricore_svcall.c index 67164a08882..601f754da15 100644 --- a/arch/tricore/src/common/tricore_svcall.c +++ b/arch/tricore/src/common/tricore_svcall.c @@ -72,7 +72,9 @@ void tricore_svcall(volatile void *trap) regs = tricore_csa2addr((uintptr_t)regs); - up_set_current_regs(regs); + /* Set irq flag */ + + up_set_interrupt_context(true); cmd = regs[REG_D8]; @@ -136,5 +138,7 @@ void tricore_svcall(volatile void *trap) __isync(); } - up_set_current_regs(NULL); + /* Set irq flag */ + + up_set_interrupt_context(false); } diff --git a/arch/tricore/src/common/tricore_switchcontext.c b/arch/tricore/src/common/tricore_switchcontext.c index 9e399cd1028..532fe248a3a 100644 --- a/arch/tricore/src/common/tricore_switchcontext.c +++ b/arch/tricore/src/common/tricore_switchcontext.c @@ -59,7 +59,7 @@ void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb) { - if (!up_current_regs()) + if (!up_interrupt_context()) { /* Then switch contexts */ diff --git a/arch/tricore/src/common/tricore_trapcall.c b/arch/tricore/src/common/tricore_trapcall.c index a83bcb21a4a..0f3b6ff0f13 100644 --- a/arch/tricore/src/common/tricore_trapcall.c +++ b/arch/tricore/src/common/tricore_trapcall.c @@ -62,8 +62,8 @@ void tricore_trapcall(volatile void *trap) regs = tricore_csa2addr(__mfcr(CPU_PCXI)); - up_set_current_regs(regs); + up_set_interrupt_context(true); up_irq_save(); - PANIC_WITH_REGS("Trap", up_current_regs()); + PANIC_WITH_REGS("Trap", regs); } diff --git a/tools/nxstyle.c b/tools/nxstyle.c index 58094557a1e..4b58da91cf9 100644 --- a/tools/nxstyle.c +++ b/tools/nxstyle.c @@ -223,6 +223,8 @@ static const char *g_white_prefix[] = "Http", /* Ref: apps/netutils/xedge/BAS/examples/xedge/src/xedge.h */ "Disk", /* Ref: apps/netutils/xedge/BAS/examples/xedge/src/xedge.h */ "Xedge", /* Ref: apps/netutils/xedge/BAS/examples/xedge/src/xedge.h */ + "tClass", /* Ref: arch/tricore/src */ + "tId", /* Ref: arch/tricore/src */ NULL };
