diff options
| author | GuEe-GUI <[email protected]> | 2025-07-11 09:26:13 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2025-07-12 07:16:25 +0800 |
| commit | 30ab08c7c9f80bca1bd8aa4e5caa6d423b087cc1 (patch) | |
| tree | 981aaacab5a2a10230557b6af8fcf5b0f05e9d4a | |
| parent | 5297c13ab0c9b1386596429d212bf73465a73be9 (diff) | |
[DM/PIC] Config IPI by RT_MAX_IPI
Signed-off-by: GuEe-GUI <[email protected]>
| -rw-r--r-- | components/drivers/include/drivers/core/dm.h | 4 | ||||
| -rw-r--r-- | components/drivers/pic/pic-gic-common.c | 18 | ||||
| -rw-r--r-- | components/drivers/pic/pic.c | 15 |
3 files changed, 14 insertions, 23 deletions
diff --git a/components/drivers/include/drivers/core/dm.h b/components/drivers/include/drivers/core/dm.h index 4c110ca7eb..b6cd70dcba 100644 --- a/components/drivers/include/drivers/core/dm.h +++ b/components/drivers/include/drivers/core/dm.h @@ -27,6 +27,10 @@ extern int rt_hw_cpu_id(void); #endif +#ifndef RT_MAX_IPI +#define RT_MAX_IPI 0 +#endif + void rt_dm_secondary_cpu_init(void); /* ID Allocation */ diff --git a/components/drivers/pic/pic-gic-common.c b/components/drivers/pic/pic-gic-common.c index 69ad804a2a..edfbafd195 100644 --- a/components/drivers/pic/pic-gic-common.c +++ b/components/drivers/pic/pic-gic-common.c @@ -62,20 +62,16 @@ void gic_common_init_quirk_hw(rt_uint32_t iidr, const struct gic_quirk *quirks, void gic_common_sgi_config(void *base, void *data, int irq_base) { #ifdef RT_USING_SMP - if (irq_base < 2) + if (irq_base < RT_MAX_IPI) { struct rt_pic_irq *pirq; -#define DECLARE_GIC_IPI(ipi, hwirq) \ - rt_pic_config_ipi(data, ipi, hwirq); \ - pirq = rt_pic_find_ipi(data, ipi); \ - pirq->mode = RT_IRQ_MODE_EDGE_RISING; \ - - DECLARE_GIC_IPI(RT_SCHEDULE_IPI, RT_SCHEDULE_IPI); - DECLARE_GIC_IPI(RT_STOP_IPI, RT_STOP_IPI); - DECLARE_GIC_IPI(RT_SMP_CALL_IPI, RT_SMP_CALL_IPI); - -#undef DECLARE_GIC_IPI + for (int ipi = 0; ipi < RT_MAX_IPI; ++ipi) + { + rt_pic_config_ipi(data, ipi, ipi); + pirq = rt_pic_find_ipi(data, ipi); + pirq->mode = RT_IRQ_MODE_EDGE_RISING; + } } #endif /* RT_USING_SMP */ } diff --git a/components/drivers/pic/pic.c b/components/drivers/pic/pic.c index 6a611ceab0..10dd948a59 100644 --- a/components/drivers/pic/pic.c +++ b/components/drivers/pic/pic.c @@ -28,17 +28,8 @@ struct irq_traps rt_bool_t (*handler)(void *); }; -static int _ipi_hash[] = -{ -#ifdef RT_USING_SMP - [RT_SCHEDULE_IPI] = RT_SCHEDULE_IPI, - [RT_STOP_IPI] = RT_STOP_IPI, - [RT_SMP_CALL_IPI] = RT_SMP_CALL_IPI, -#endif -}; - /* reserved ipi */ -static int _pirq_hash_idx = RT_ARRAY_SIZE(_ipi_hash); +static int _pirq_hash_idx = RT_MAX_IPI; static struct rt_pic_irq _pirq_hash[MAX_HANDLERS] = { [0 ... MAX_HANDLERS - 1] = @@ -230,7 +221,7 @@ int rt_pic_config_ipi(struct rt_pic *pic, int ipi_index, int hwirq) int ipi = ipi_index; struct rt_pic_irq *pirq; - if (pic && ipi < RT_ARRAY_SIZE(_ipi_hash) && hwirq >= 0 && pic->ops->irq_send_ipi) + if (pic && ipi < RT_MAX_IPI && hwirq >= 0 && pic->ops->irq_send_ipi) { pirq = &_pirq_hash[ipi]; 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) { struct rt_pic_irq *pirq = &_pirq_hash[ipi_index]; - RT_ASSERT(ipi_index < RT_ARRAY_SIZE(_ipi_hash)); + RT_ASSERT(ipi_index < RT_MAX_IPI); RT_ASSERT(pirq->pic == pic); return pirq; |
