arch/tricore: support minimal vectortalbe in tricore

The SRN number in TriCore far exceeds the PN number.
Using IRQ as the PN number would result in an overflow.
Therefore, MINIMAL_VECTORTABLE is used to ensure that
the PN number does not overflow.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
This commit is contained in:
zhangyuan29
2024-12-09 16:54:20 +08:00
committed by Xiang Xiao
parent f40dfc7234
commit f44060ca9f
9 changed files with 76 additions and 81 deletions
-34
View File
@@ -37,24 +37,6 @@
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if defined(CONFIG_ARCH_MINIMAL_VECTORTABLE) && \
!defined(CONFIG_ARCH_NUSER_INTERRUPTS)
# error CONFIG_ARCH_NUSER_INTERRUPTS is not defined
#endif
#if defined(CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC)
# define IRQ_TO_NDX(irq) (g_irqmap[irq] ? g_irqmap[irq] : irq_to_ndx(irq))
#elif defined(CONFIG_ARCH_MINIMAL_VECTORTABLE)
# define IRQ_TO_NDX(irq) \
(g_irqmap[(irq)] < CONFIG_ARCH_NUSER_INTERRUPTS ? g_irqmap[(irq)] : -EINVAL)
#else
# define IRQ_TO_NDX(irq) (irq)
#endif
/****************************************************************************
* Public Types
****************************************************************************/
@@ -98,22 +80,6 @@ extern struct irq_info_s g_irqvector[CONFIG_ARCH_NUSER_INTERRUPTS];
extern struct irq_info_s g_irqvector[NR_IRQS];
#endif
/* This is the interrupt vector mapping table. This must be provided by
* architecture specific logic if CONFIG_ARCH_MINIMAL_VECTORTABLE is define
* in the configuration.
*
* REVISIT: This should be declared in include/nuttx/irq.h. The declaration
* at that location, however, introduces a circular include dependency so the
* declaration is here for the time being.
*/
#if defined(CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC)
extern irq_mapped_t g_irqmap[NR_IRQS];
int irq_to_ndx(int irq);
#elif defined(CONFIG_ARCH_MINIMAL_VECTORTABLE)
extern const irq_mapped_t g_irqmap[NR_IRQS];
#endif
#ifdef CONFIG_SMP
/* This is the spinlock that enforces critical sections when interrupts are
* disabled.
+19 -1
View File
@@ -57,6 +57,7 @@ static int g_irqmap_count = 1;
*/
irq_mapped_t g_irqmap[NR_IRQS];
int g_irqrevmap[CONFIG_ARCH_NUSER_INTERRUPTS];
#endif
/****************************************************************************
@@ -71,12 +72,29 @@ int irq_to_ndx(int irq)
irqstate_t flags = spin_lock_irqsave(&g_irqlock);
if (g_irqmap[irq] == 0)
{
g_irqmap[irq] = g_irqmap_count++;
int ndx = g_irqmap_count++;
g_irqmap[irq] = ndx;
g_irqrevmap[ndx] = irq;
}
spin_unlock_irqrestore(&g_irqlock, flags);
return g_irqmap[irq];
}
#elif defined(CONFIG_ARCH_MINIMAL_VECTORTABLE)
int ndx_to_irq(int ndx)
{
int i;
for (i = 0; i < NR_IRQS; i++)
{
if (g_irqmap[i] == ndx)
{
return i;
}
}
return -EINVAL;
}
#endif
/****************************************************************************