Skip to content

Commit 30ab08c

Browse files
GuEe-GUIRbb666
authored andcommitted
[DM/PIC] Config IPI by RT_MAX_IPI
Signed-off-by: GuEe-GUI <[email protected]>
1 parent 5297c13 commit 30ab08c

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

components/drivers/include/drivers/core/dm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
extern int rt_hw_cpu_id(void);
2828
#endif
2929

30+
#ifndef RT_MAX_IPI
31+
#define RT_MAX_IPI 0
32+
#endif
33+
3034
void rt_dm_secondary_cpu_init(void);
3135

3236
/* ID Allocation */

components/drivers/pic/pic-gic-common.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,16 @@ void gic_common_init_quirk_hw(rt_uint32_t iidr, const struct gic_quirk *quirks,
6262
void gic_common_sgi_config(void *base, void *data, int irq_base)
6363
{
6464
#ifdef RT_USING_SMP
65-
if (irq_base < 2)
65+
if (irq_base < RT_MAX_IPI)
6666
{
6767
struct rt_pic_irq *pirq;
6868

69-
#define DECLARE_GIC_IPI(ipi, hwirq) \
70-
rt_pic_config_ipi(data, ipi, hwirq); \
71-
pirq = rt_pic_find_ipi(data, ipi); \
72-
pirq->mode = RT_IRQ_MODE_EDGE_RISING; \
73-
74-
DECLARE_GIC_IPI(RT_SCHEDULE_IPI, RT_SCHEDULE_IPI);
75-
DECLARE_GIC_IPI(RT_STOP_IPI, RT_STOP_IPI);
76-
DECLARE_GIC_IPI(RT_SMP_CALL_IPI, RT_SMP_CALL_IPI);
77-
78-
#undef DECLARE_GIC_IPI
69+
for (int ipi = 0; ipi < RT_MAX_IPI; ++ipi)
70+
{
71+
rt_pic_config_ipi(data, ipi, ipi);
72+
pirq = rt_pic_find_ipi(data, ipi);
73+
pirq->mode = RT_IRQ_MODE_EDGE_RISING;
74+
}
7975
}
8076
#endif /* RT_USING_SMP */
8177
}

components/drivers/pic/pic.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,8 @@ struct irq_traps
2828
rt_bool_t (*handler)(void *);
2929
};
3030

31-
static int _ipi_hash[] =
32-
{
33-
#ifdef RT_USING_SMP
34-
[RT_SCHEDULE_IPI] = RT_SCHEDULE_IPI,
35-
[RT_STOP_IPI] = RT_STOP_IPI,
36-
[RT_SMP_CALL_IPI] = RT_SMP_CALL_IPI,
37-
#endif
38-
};
39-
4031
/* reserved ipi */
41-
static int _pirq_hash_idx = RT_ARRAY_SIZE(_ipi_hash);
32+
static int _pirq_hash_idx = RT_MAX_IPI;
4233
static struct rt_pic_irq _pirq_hash[MAX_HANDLERS] =
4334
{
4435
[0 ... MAX_HANDLERS - 1] =
@@ -230,7 +221,7 @@ int rt_pic_config_ipi(struct rt_pic *pic, int ipi_index, int hwirq)
230221
int ipi = ipi_index;
231222
struct rt_pic_irq *pirq;
232223

233-
if (pic && ipi < RT_ARRAY_SIZE(_ipi_hash) && hwirq >= 0 && pic->ops->irq_send_ipi)
224+
if (pic && ipi < RT_MAX_IPI && hwirq >= 0 && pic->ops->irq_send_ipi)
234225
{
235226
pirq = &_pirq_hash[ipi];
236227
config_pirq(pic, pirq, ipi, hwirq);
@@ -281,7 +272,7 @@ struct rt_pic_irq *rt_pic_find_ipi(struct rt_pic *pic, int ipi_index)
281272
{
282273
struct rt_pic_irq *pirq = &_pirq_hash[ipi_index];
283274

284-
RT_ASSERT(ipi_index < RT_ARRAY_SIZE(_ipi_hash));
275+
RT_ASSERT(ipi_index < RT_MAX_IPI);
285276
RT_ASSERT(pirq->pic == pic);
286277

287278
return pirq;

0 commit comments

Comments
 (0)