[ARM异常]-SPIs(共享中断)routing到指定CPU的方法

273 篇文章 421 订阅
这篇博客深入剖析了ARM架构中的GIC(Generic Interrupt Controller)如何处理SPIs中断,并讲解了`gic_set_affinity`函数的工作原理,涉及中断映射、CPU关联及中断路由设置。
摘要由CSDN通过智能技术生成

快速链接:
.
👉👉👉 个人博客笔记导读目录(全部) 👈👈👈

在这里插入图片描述

原理介绍:

废话不多说,看图,看懂的给赞!
在这里插入图片描述

内核没有提供指定SPIs中断到特定cpu的接口。那代码我们就胡乱的看一下吧

static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
                            bool force)
{
        unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask);
        struct irq_desc *desc = container_of(d, struct irq_desc, irq_data);
        void __iomem *reg;
        int enabled;
        u64 val;

        if (cpu >= nr_cpu_ids)
                return -EINVAL;

        if (gic_irq_in_rdist(d))
                return -EINVAL;

        /* If interrupt was enabled, disable it first */
        enabled = gic_peek_irq(d, GICD_ISENABLER);
        if (enabled)
                gic_mask_irq(d);

        reg = gic_dist_base(d) + GICD_IROUTER + (gic_irq(d) * 8);
        val = gic_mpidr_to_affinity(cpu_logical_map(cpu));

        gic_write_irouter(val, reg);

        /*
         * If the interrupt was enabled, enabled it again. Otherwise,
         * just wait for the distributor to have digested our changes.
         */
        if (enabled)
                gic_unmask_irq(d);
        else
                gic_dist_wait_for_rwp();

        return IRQ_SET_MASK_OK;
}
  • val = gic_mpidr_to_affinity(cpu_logical_map(cpu)); //读出cpu的id值
  • gic_write_irouter(val, reg); //将这个值,写入到GICD寄存器

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代码改变世界ctw

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值