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 98639aaa7570658e3f2110944b67642025f8d743 Author: Saravanan Sekar <[email protected]> AuthorDate: Thu Nov 5 22:22:22 2026 +0530 arch/tricore: Replace the iLLD interrupt vector. The interrupt vector comes from the iLLD IFX_INTERRUPT_INTERNAL macro, which on GCC also makes tricore_doirq an interrupt_handler, and on TASKING from the compiler __interrupt and __vector_table keywords. Add a native vector next to the trap vectors, which saves the lower context and enters tricore_doirq with jli, and make tricore_doirq a plain function that returns with ji. An image runs on a single core, so one vector section is enough, and the linker scripts place it at INTTAB + 0x1FE0 as they did the iLLD one. Co-authored-by: Parthiban Nallathambi <[email protected]> Signed-off-by: Saravanan Sekar <[email protected]> --- arch/tricore/src/common/gnu/tricore_vectors.S | 19 ++++++++++ .../tricore/src/common/tasking/tricore_vectors.asm | 16 +++++++++ arch/tricore/src/common/tricore_doirq.c | 42 ++++++++++++++-------- arch/tricore/src/common/tricore_internal.h | 1 + .../scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel | 2 +- .../scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel | 2 +- .../scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel | 2 +- .../scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel | 2 +- 8 files changed, 68 insertions(+), 18 deletions(-) diff --git a/arch/tricore/src/common/gnu/tricore_vectors.S b/arch/tricore/src/common/gnu/tricore_vectors.S index df9be09084f..534652697db 100644 --- a/arch/tricore/src/common/gnu/tricore_vectors.S +++ b/arch/tricore/src/common/gnu/tricore_vectors.S @@ -40,6 +40,10 @@ * so is %sp when the trap switched to the interrupt stack. Without a pool * the core stops in tricore_fcu_entry. * + * The interrupt vector saves the lower context and enters + * tricore_doirq the same way. The startup code sets the priority bits + * of BIV, so every interrupt priority enters this one vector. + * * tasking/tricore_vectors.asm is the same code in the TASKING syntax. ****************************************************************************/ @@ -79,6 +83,13 @@ tricore_trap_vectors_cpu\cpu: TRAPTAB 4 TRAPTAB 5 + .section .intvec, "ax", %progbits + .p2align 5 + .global tricore_int_vector +tricore_int_vector: + svlcx + j tricore_int_entry + /* struct tricore_trap_s: taddr at 0, tid at 4, tclass at 5, tcpu at 6 */ .macro TRAPENTRY name, handler @@ -107,6 +118,14 @@ tricore_trap_vectors_cpu\cpu: TRAPENTRY tricore_trap_entry, tricore_trapcall TRAPENTRY tricore_syscall_entry, tricore_svcall + .type tricore_int_entry, %function +tricore_int_entry: + movh.a %a2, hi:tricore_doirq + lea %a2, [%a2]lo:tricore_doirq + jli %a2 + rslcx + rfe + .type tricore_ctx_entry, %function tricore_ctx_entry: jeq %d15, 4, tricore_fcu_entry diff --git a/arch/tricore/src/common/tasking/tricore_vectors.asm b/arch/tricore/src/common/tasking/tricore_vectors.asm index 3a9a3439f43..c72232dfd12 100644 --- a/arch/tricore/src/common/tasking/tricore_vectors.asm +++ b/arch/tricore/src/common/tasking/tricore_vectors.asm @@ -29,6 +29,7 @@ .extern tricore_trapcall .extern tricore_svcall + .extern tricore_doirq .extern tricore_fcu_recover .extern g_tricore_fcu_pool @@ -67,6 +68,14 @@ label: TRAPTAB 4, tricore_trap_vectors_cpu4 TRAPTAB 5, tricore_trap_vectors_cpu5 + .sdecl ".text.intvec",code,protect + .sect ".text.intvec" + .align 32 + .global tricore_int_vector +tricore_int_vector: + svlcx + j tricore_int_entry + ; struct tricore_trap_s: taddr at 0, tid at 4, tclass at 5, tcpu at 6 TRAPENTRY .macro name, handler @@ -94,6 +103,13 @@ name: TRAPENTRY tricore_trap_entry, tricore_trapcall TRAPENTRY tricore_syscall_entry, tricore_svcall +tricore_int_entry: + movh.a a2, #@HIS(tricore_doirq) + lea a2, [a2]@LOS(tricore_doirq) + jli a2 + rslcx + rfe + tricore_ctx_entry: jeq d15, #4, tricore_fcu_entry svlcx diff --git a/arch/tricore/src/common/tricore_doirq.c b/arch/tricore/src/common/tricore_doirq.c index b0388f80b1d..b4c7148afc6 100644 --- a/arch/tricore/src/common/tricore_doirq.c +++ b/arch/tricore/src/common/tricore_doirq.c @@ -41,18 +41,32 @@ #include "tricore_internal.h" -/* The interrupt entry still uses the iLLD until it is native */ +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The interrupt vector enters tricore_doirq with jli, return with ji */ -#include <IfxCpu_reg.h> -#include <Ifx_Ssw_Compilers.h> -#include <Compilers/Compilers.h> -#include <IfxCpu_Intrinsics.h> +#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 ****************************************************************************/ -IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255) +/**************************************************************************** + * Name: tricore_doirq + * + * Description: + * Common interrupt handler, entered from the interrupt vector in + * tricore_vectors.S/.asm with the lower context saved. + * + ****************************************************************************/ + +void tricore_doirq(void) { struct tcb_s **running_task = &g_running_tasks[this_cpu()]; struct tcb_s *tcb = this_task(); @@ -60,11 +74,9 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255) #ifdef CONFIG_SUPPRESS_INTERRUPTS PANIC(); #else - Ifx_CPU_ICR icr; - uintptr_t *regs; - - icr.U = tricore_mfcr(CPU_ICR); - regs = tricore_csa2addr(tricore_mfcr(CPU_PCXI)); + int irq = NDX_TO_IRQ(tricore_mfcr(TRICORE_CPU_ICR) & + TRICORE_ICR_CCPN_MASK); + uintptr_t *regs = tricore_csa2addr(tricore_mfcr(TRICORE_CPU_PCXI)); if (*running_task != NULL) { @@ -83,9 +95,9 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255) /* Deliver the IRQ */ - tricore_ack_irq(NDX_TO_IRQ(icr.B.CCPN)); + tricore_ack_irq(irq); - irq_dispatch(NDX_TO_IRQ(icr.B.CCPN), regs); + irq_dispatch(irq, regs); /* Check for a context switch. */ @@ -113,7 +125,7 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255) *running_task = tcb; - tricore_mtcr(CPU_PCXI, tricore_addr2csa(tcb->xcp.regs)); + tricore_mtcr(TRICORE_CPU_PCXI, tricore_addr2csa(tcb->xcp.regs)); UP_ISB(); } @@ -128,4 +140,6 @@ IFX_INTERRUPT_INTERNAL(tricore_doirq, 0, 255) (*running_task)->xcp.regs = NULL; board_autoled_off(LED_INIRQ); #endif + + tricore_irq_return(); } diff --git a/arch/tricore/src/common/tricore_internal.h b/arch/tricore/src/common/tricore_internal.h index 11d4fbfaea8..8559036cd29 100644 --- a/arch/tricore/src/common/tricore_internal.h +++ b/arch/tricore/src/common/tricore_internal.h @@ -190,6 +190,7 @@ extern uintptr_t _eheap[]; /* End+1 of .heap */ /* Interrupt ****************************************************************/ void tricore_ack_irq(int irq); +void tricore_doirq(void); /* Signal handling **********************************************************/ diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel b/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel index 81a9918393b..28bb7c178ba 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel +++ b/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel @@ -180,7 +180,7 @@ SECTIONS .COREID_MID(inttab_tc, _0FF) (COREID_LST(__INTTAB_CPU) + 0x1FE0) : { . = ALIGN(8); - KEEP (*(.COREID_MID(intvec_tc, _255))); + KEEP (*(.intvec)); . = ALIGN(0x2000); } > pfls } diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel b/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel index 53053ee03d5..9548e61b687 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel +++ b/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel @@ -347,7 +347,7 @@ derivative tc39 { group int_tab_tc (ordered) { - group (run_addr=(INTTAB)+0x1FE0) select ".text.inttab0.intvec.0ff"; + group (run_addr=(INTTAB)+0x1FE0) select ".text.intvec"; } "_lc_u_int_tab" = (LCF_INTVEC_START); "__INTTAB_CPU0" = (LCF_INTVEC_START); diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel b/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel index f27afd54bc0..004dba06454 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel +++ b/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.kernel @@ -190,7 +190,7 @@ SECTIONS .COREID_MID(inttab_tc, _0FF) (COREID_LST(__INTTAB_CPU) + 0x1FE0) : { . = ALIGN(8); - KEEP (*(.COREID_MID(intvec_tc, _255))); + KEEP (*(.intvec)); . = ALIGN(0x2000); } > pfls } diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel b/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel index 61c7f589d37..756f979c636 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel +++ b/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.kernel @@ -362,7 +362,7 @@ derivative tc4D { group int_tab_tc (ordered) { - group (run_addr=(INTTAB)+0x1FE0) select ".text.inttab0.intvec.0ff"; + group (run_addr=(INTTAB)+0x1FE0) select ".text.intvec"; } "_lc_u_int_tab" = (LCF_INTVEC_START); "__INTTAB_CPU0" = (LCF_INTVEC_START);
