编辑
2025-04-21
记录知识
0
请注意,本文编写于 66 天前,最后修改于 52 天前,其中某些信息可能已经过时。

目录

整体划分
总结

根据《GICv3中断简介》我们简单了解了gicv3中断控制器,这里根据《GICv3_Software_Overview_Official_Release_B.pdf》的Programmers’ model 来介绍一下gicv3的组成

整体划分

gicv3主要由三大部分组成,如下

  • Distributor interface
  • Redistributor interface
  • CPU interface

这里

  • Distributor:它检查中断源的状态,将SGI和SPI这类中断最终派发到到Redistributor上去,因为每个CPU都连接一个Redistributor,所以最终会派发到对应的CPU interface上
  • Redistributor:接收Distributor,然后最终将中断发送给CPU Interface
  • CPU interface: 就是我们常规理解的中断,它将中断发给CPU,让CPU响应中断

这里Distributor派发到Redistributor是根据优先级的,所以gicv3的affinity hierarchy 图如下

image.png

所以,我们知道了gicv3的整体框图如下

image.png

对于寄存器标识,如下

  • GICD_* : Distributor,也就是SGI/SPI的分发
  • GICR_* : Redistributor,接收中断发给GICC_* ,注意PPI的中断是直接给到GICR_* 不通过GICD_*
  • GICC_* : CPU interface, 发送给CPU,响应中断

根据上面的介绍,其实总结一下流程就是如下

  1. 外设发起中断,发送给distributor
  2. Distributor将该中断,然后根据优先等级分发给合适的Redistributor
  3. Redistributor将中断发送给CPU interface。
  4. CPU interface产生合适的中断异常给处理器
  5. CPU接收该异常,并且软件处理该中断

其中断状态机如下

image.png

  • Inactive: 不活跃状态
  • Pending:中断触发了,还没到CPU Interface,还没响应
  • Active:被CPU响应和处理
  • Active & Pending: (An instance of the interrupt has been acknowledged, and another instance is now pending. )当前有一个中断正在响应,此时有一个相同优先级的中断触发了

不过LPI中断没有active 或 active and pending 状态,也就是上面的中断状态机只针对SPI,SGI,PPI的。所以LPI的状态机如下

image.png

总结

根据上面的信息,我们中间gic-v3的寄存器调用如下图

image.png