[FEATURE/PIC] support PIC cancel (only in debug)
PIC may free because some wrongs in debug. We should remove in PIC list or there are some undefined behavior will happen. Signed-off-by: GuEe-GUI <2991707448@qq.com>
This commit is contained in:
parent
04cdbc647c
commit
94e49755af
|
@ -148,6 +148,7 @@ void rt_pic_default_name(struct rt_pic *pic);
|
||||||
struct rt_pic *rt_pic_dynamic_cast(void *ptr);
|
struct rt_pic *rt_pic_dynamic_cast(void *ptr);
|
||||||
|
|
||||||
rt_err_t rt_pic_linear_irq(struct rt_pic *pic, rt_size_t irq_nr);
|
rt_err_t rt_pic_linear_irq(struct rt_pic *pic, rt_size_t irq_nr);
|
||||||
|
rt_err_t rt_pic_cancel_irq(struct rt_pic *pic);
|
||||||
|
|
||||||
int rt_pic_config_ipi(struct rt_pic *pic, int ipi_index, int hwirq);
|
int rt_pic_config_ipi(struct rt_pic *pic, int ipi_index, int hwirq);
|
||||||
int rt_pic_config_irq(struct rt_pic *pic, int irq_index, int hwirq);
|
int rt_pic_config_irq(struct rt_pic *pic, int irq_index, int hwirq);
|
||||||
|
|
|
@ -173,6 +173,30 @@ rt_err_t rt_pic_linear_irq(struct rt_pic *pic, rt_size_t irq_nr)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rt_err_t rt_pic_cancel_irq(struct rt_pic *pic)
|
||||||
|
{
|
||||||
|
rt_err_t err = RT_EOK;
|
||||||
|
|
||||||
|
if (pic && pic->pirqs)
|
||||||
|
{
|
||||||
|
rt_ubase_t level = rt_spin_lock_irqsave(&_pic_lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is only to make system runtime safely,
|
||||||
|
* we don't recommend PICs to unregister.
|
||||||
|
*/
|
||||||
|
rt_list_remove(&pic->list);
|
||||||
|
|
||||||
|
rt_spin_unlock_irqrestore(&_pic_lock, level);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = -RT_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static void config_pirq(struct rt_pic *pic, struct rt_pic_irq *pirq, int irq, int hwirq)
|
static void config_pirq(struct rt_pic *pic, struct rt_pic_irq *pirq, int irq, int hwirq)
|
||||||
{
|
{
|
||||||
rt_ubase_t level = rt_spin_lock_irqsave(&pirq->rw_lock);
|
rt_ubase_t level = rt_spin_lock_irqsave(&pirq->rw_lock);
|
||||||
|
|
Loading…
Reference in New Issue