shced/irq: Add up_irq_to_ndx interface

Use architecture-specific up_irq_to_ndx() interface to map IRQ numbers to vector table indices

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
This commit is contained in:
liwenxiang1
2025-08-13 17:31:45 +08:00
committed by Donny(董九柱)
parent d483364481
commit 6d9ed4217a
7 changed files with 96 additions and 14 deletions
+54 -1
View File
@@ -32,6 +32,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "tricore_internal.h"
@@ -69,6 +70,13 @@ static inline void tricore_color_intstack(void)
# define tricore_color_intstack()
#endif
/****************************************************************************
* Private Data
****************************************************************************/
static spinlock_t g_irqlock = SP_UNLOCKED;
static int g_irqmap_count = 1;
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -156,8 +164,16 @@ void up_irqinitialize(void)
void up_disable_irq(int irq)
{
volatile Ifx_SRC_SRCR *src = &SRC_CPU_CPU0_SB + irq;
Ifx_SRC_SRCR srctmp;
IfxSrc_disable(src);
/* Clear, keep SRPN */
srctmp.U = 0U;
srctmp.B.TOS = ~0;
srctmp.B.SRPN = src->B.SRPN;
src->U = srctmp.U;
}
/****************************************************************************
@@ -232,4 +248,41 @@ void up_trigger_irq(int irq, cpu_set_t cpuset)
volatile Ifx_INT_SRB *srb = &INT_SRB0 + up_cpu_index();
srb->U = cpuset;
}
#endif
#endif
/****************************************************************************
* Name: up_irq_to_ndx
*
* Description:
* Irq to ndx
*
****************************************************************************/
int up_irq_to_ndx(int irq)
{
volatile Ifx_SRC_SRCR *src = &SRC_CPU_CPU0_SB + irq;
Ifx_SRC_SRCR srctmp;
irqstate_t flags;
int ndx;
ndx = src->B.SRPN;
if (ndx != 0)
{
return ndx;
}
flags = spin_lock_irqsave(&g_irqlock);
ndx = src->B.SRPN;
if (ndx == 0)
{
ndx = g_irqmap_count++;
g_irqrevmap[ndx] = irq;
srctmp.U = src->U;
srctmp.B.SRPN = ndx;
src->U = srctmp.U;
}
spin_unlock_irqrestore(&g_irqlock, flags);
return ndx;
}