4242#include "tricore_internal.h"
4343
4444#include "IfxCpu.h"
45+ #include "IfxInt_reg.h"
46+
47+ /****************************************************************************
48+ * Pre-processor Definitions
49+ ****************************************************************************/
50+
51+ #define TRICORE_INT_LASR0_ADDR ((uintptr_t)&INT_LASR0)
52+ #define TRICORE_INT_LASR_SPACING ((uintptr_t)&INT_LASR1 - \
53+ (uintptr_t)&INT_LASR0)
4554
4655/****************************************************************************
4756 * Private Functions
4857 ****************************************************************************/
4958
59+ /****************************************************************************
60+ * Name: tricore_irq_from_lasr
61+ *
62+ * Description:
63+ * Get irq number from ICU's last acknowledged SRN register
64+ *
65+ ****************************************************************************/
66+
67+ static inline_function int tricore_irq_from_lasr (void )
68+ {
69+ uintptr_t addr = TRICORE_INT_LASR0_ADDR +
70+ up_cpu_index () * TRICORE_INT_LASR_SPACING ;
71+
72+ return (getreg32 (addr ) >> 16 ) & 0x7ff ;
73+ }
74+
5075#ifdef CONFIG_ARCH_IRQPRIO
5176
5277/****************************************************************************
6085 *
6186 ****************************************************************************/
6287
63- static void tricore_irq_direct (uintptr_t * regs , int ccpn )
88+ static void tricore_irq_direct (uintptr_t * regs )
6489{
6590 struct tcb_s * * running_task = & g_running_tasks [this_cpu ()];
66- int irq ;
91+ int irq = tricore_irq_from_lasr () ;
6792
6893 up_irq_enable ();
6994
70- irq = tricore_srpn_to_irq (ccpn );
7195 tricore_ack_irq (irq );
7296 irq_dispatch (irq , regs );
7397
@@ -99,12 +123,12 @@ static void tricore_irq_direct(uintptr_t *regs, int ccpn)
99123 *
100124 ****************************************************************************/
101125
102- static void tricore_irq_sched (uintptr_t * regs , int ccpn )
126+ static void tricore_irq_sched (uintptr_t * regs )
103127{
104128 struct tcb_s * * running_task = & g_running_tasks [this_cpu ()];
105129 struct tcb_s * tcb ;
106130#ifndef CONFIG_ARCH_IRQPRIO
107- int irq ;
131+ int irq = tricore_irq_from_lasr () ;
108132#endif
109133
110134#ifdef CONFIG_ARCH_IRQPRIO
@@ -119,11 +143,8 @@ static void tricore_irq_sched(uintptr_t *regs, int ccpn)
119143 board_autoled_on (LED_INIRQ );
120144
121145#ifndef CONFIG_ARCH_IRQPRIO
122- irq = tricore_srpn_to_irq (ccpn );
123146 tricore_ack_irq (irq );
124147 irq_dispatch (irq , regs );
125- #else
126- UNUSED (ccpn );
127148#endif
128149
129150 tcb = this_task ();
@@ -172,19 +193,18 @@ static void tricore_irq_sched(uintptr_t *regs, int ccpn)
172193
173194IFX_INTERRUPT_INTERNAL (tricore_doirq , 0 , 255 )
174195{
196+ uintptr_t * regs = tricore_csa2addr (tricore_mfcr (CPU_PCXI ));
197+
198+ #ifdef CONFIG_ARCH_IRQPRIO
175199 Ifx_CPU_ICR icr ;
176- uintptr_t * regs ;
177200
178201 icr .U = tricore_mfcr (CPU_ICR );
179- regs = tricore_csa2addr (tricore_mfcr (CPU_PCXI ));
180-
181- #ifdef CONFIG_ARCH_IRQPRIO
182202 if (icr .B .CCPN != TRICORE_IRQ_MIN_PRIORITY )
183203 {
184- tricore_irq_direct (regs , icr . B . CCPN );
204+ tricore_irq_direct (regs );
185205 return ;
186206 }
187207#endif
188208
189- tricore_irq_sched (regs , icr . B . CCPN );
209+ tricore_irq_sched (regs );
190210}
0 commit comments