1

根据 GIC 手册,GICD_ISENABLER

Reads 
0 Forwarding of the corresponding interrupt is disabled. 
1 Forwarding of the corresponding interrupt is enabled.
Writes 
0 Has no effect.
1 Enables the forwarding of the corresponding interrupt.

GICD_ICENABLER

Reads 
0 Forwarding of the corresponding interrupt is disabled.
1 Forwarding of the corresponding interrupt is enabled.
Writes 
0 Has No Effect
1 Disables the forwarding of the corresponding interrupt

需要2个寄存器吗?目的可以通过1来解决吗?

4

1 回答 1

0

作为背景知识,您可以阅读ARM Appnote 179的第 2.5 章,了解Cortex-M 的位带功能。问题是避免读取-修改-写入循环。假设您有一些希望禁用中断#X的主线代码。在此过程中,会发生不相关的中断#Y并禁用该中断。CPU进程可能如下顺序,

  1. 主线读取中断掩码,清除#X、#Y 。
  2. 发生中断
  3. 中断禁用 int #Y
  4. 主线恢复,设置 int #X掩码
  5. 没有设置#Y的主线写中断掩码

虽然从这些寄存器中读取是等效的,但写入非常重要,并且如上所述的竞争条件在中断中很常见。您可以在irq 服务例程中禁止屏蔽中断。但是,通常有硬件不会关闭,并且经常需要进行这种屏蔽。

在屏蔽中断位时,您当然可以屏蔽主线中的所有中断。但是,这会增加中断延迟并且通常对系统不利。使用双寄存器结构,可以避免读取-修改-写入并原子地屏蔽中断位。

于 2013-10-29T14:03:25.263 回答