ARM 系统模式在嵌套中断中如何有用? [英] How ARM system mode is useful in nested interrupt?

查看:20
本文介绍了ARM 系统模式在嵌套中断中如何有用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下,当我们嵌套中断时,系统模式究竟是如何工作的?

Can someone explain me, how exactly system mode works when we have nested interrupt ?

根据 ARM 网站

ARMv4 和更高版本的体系结构包含一个称为系统模式的特权模式,以克服这个问题.系统模式与用户模式共享相同的寄存器,可以运行需要特权访问的任务,并且异常不再覆盖链接寄存器.

ARMv4 and later architectures include a privileged mode called System mode, to overcome this problem. System mode shares the same registers as User mode, it can run tasks that require privileged access, and exceptions no longer overwrite the link register.

那么系统模式如何使用用户模式的寄存器?

So how system mode make use of registers of User mode ?

最多可以处理什么层次的嵌套中断?

And upto what hierarchy level nested interrupts can be handled?

推荐答案

尝试在 IRQ 模式下处理嵌套中断:

Trying to handle nested interrupts in IRQ mode:

  • (USER) 您处于用户模式,您的 PC 寄存器会显示您的位置.

  • (USER) You are in user mode, your PC register tells where you are.

(用户)你被打断了.

(IRQ) 内核切换到中断模式,禁用中断(屏蔽通过cpsr.i) 将 PC 从用户模式保存到 IRQ 模式下的 LR.

(IRQ) Core switches to interrupt mode, disables interrupts (mask via cpsr.i) saves PC from user mode to LR in IRQ mode.

(IRQ) 这个时候你不能得到更多的中断,因为中断是已禁用.

(IRQ) At this moment you can't get more interrupts because interrupts are disabled.

(IRQ) 您处于 IRQ 模式并且您确实启用了中断.

(IRQ) You are in IRQ mode and you do enable interrupts.

(IRQ) 你调用一个函数来处理相关的中断.在函数调用 LR 包含后,将地址返回到顶级 IRQ 处理程序中.

(IRQ) You call a function to handle related interrupt. After function call LR contains, return address into top level IRQ handler.

(IRQ) 另一个中断发生,LR 被函数处理中断覆盖.此时你不能有一个稳定的状态,仅仅是因为你不能在IRQ模式下将LR用于你自己的目的,并且启用了中断以支持嵌套中断.您认为您可以将 LR 保存到堆栈中,但这会导致竞争条件,从而导致无限循环.

(IRQ) Another interrupt happens, LR gets overwritten with function handling interrupt. At this moment you can't have a stable state, simply because you can't use LR for your own purposes in IRQ mode and have interrupts enabled to support nested interrupts. You think you may save LR to stack, but that would be open to a race condition which would lead to inifinitive loops.

通过系统模式处理嵌套中断:

Handling nested interrupts via System mode:

  • (USER) 您处于用户模式,您的 PC 寄存器会显示您的位置.

  • (USER) You are in user mode, your PC register tells where you are.

(用户)你被打断了.

(IRQ) 内核切换到中断模式,禁用中断(屏蔽通过cpsr.i) 将 PC 从用户模式保存到 IRQ 模式下的 LR.

(IRQ) Core switches to interrupt mode, disables interrupts (mask via cpsr.i) saves PC from user mode to LR in IRQ mode.

(IRQ) 这个时候你不能得到更多的中断,因为中断是已禁用.

(IRQ) At this moment you can't get more interrupts because interrupts are disabled.

(IRQ) 您切换到系统模式,启用 IRQ.

(IRQ) You switch to system mode, enable IRQs.

(SYSTEM) 另一个中断发生了,但一切正常,因为你没有用硬件来保持你的 LR 理智.

(SYSTEM) Another interrupt happens but things work just because you don't race with hardware to keep your LR sane.

往下看,看看哪些寄存器被存入哪些州.

Look below to see which registers gets banked in which states.

这篇关于ARM 系统模式在嵌套中断中如何有用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆