您的位置:首页 > 产品设计 > UI/UE

Chapter9-3.Interrupt handling schemes 《ARM system developer's guide》

2016-01-15 10:21 477 查看

Interrupt Handling Schemes

1.Nonnested Interrupt Handling



2.Nested Interrupt Handler



进行一次context转换需要清空IRQ栈(因为handler无法在IRQ栈有数据的时候执行context switch),所有保存在IRQ栈中的寄存器都需要被转移到任务的栈中,典型的是是在SVC stack。剩余的寄存器必须要被转移到任务栈中一段内存地址中,该段被称为a stack frame

其余还有一些需要被转移到stack frame的寄存器,具体的取决于被使用的操作系统或者应用程序。例如:

r13_sur, r14_usr, 需要在支持user、SVC模式的操作系统中被保存

Floating-point register需要在系统使用hardware floating-point的时候被保存

summary

在没有优先级分配的情况下处理多个中断

中到高的中断延时

优势:在单个中断服务完成前enable interrupts能减少interrupt latency

劣势:不能处理优先级中断,所以低优先级中断会block高优先级中断

3.Reentrant Interrupt Handler

这是一种能处理多重中断的方法,这些中断按照优先级过滤-高优先级有着低中断延时,但是常规的nested interrupt handler达不到这种效果。

3和2类handler的区别在于,reentrant的reenable interrupt要更早一些,这样可以降低中断延迟。

所有的在reentrant interrupt handler的中断必须是SVC,system,undefined instruction,or abort mode 之一。

如果中断在中断模式的时候reenable并且执行了BL调用了子函数,子函数的返回地址会保存到r14_irq中,如果再发生中断会覆盖r14_irq,为了避免覆盖,所以所有的中断需要进入SVC或者system模式。BL指令可以使用r14_svc去保存子流程的返回地址。在reenable中断之前必须要通过cpsr屏蔽掉中断。

自从中断在SVC模式服务的时候,中断栈就没有用了,相替代的使用了IRQ的r13去指向一个12-byte的结构。该结构用于在中断进入的时候临时保存一些寄存器的值。

1.流程图



2.summary

1.Handles multiple interrupts that can be prioritized

2. Low Interrupt latency

3. Advantages: handles interrupts with differing prorities

4. Disadvantages: tends to be more complex

4.Prioritized Simple Interrupt Handler



summary

Handles prioritized interrupts

Low interrupt latency

Advantages: deterministic interrupt latency since the priority level is identified first and then the service is called after the lower-priority interrupts are masked

Disadvantage: the time taken to get to a low-priority service routine is the same as for a high-priority routine.

5.Prioritized Standard Interrupt handler



summary

Handles higher-priority interrupts in a shorter time than low-priority interrupts.

Low interrupts latancy

Advantages: Higher-priority interrupts treated with greater urgency with no duplication of code to set external interrupt masks

Disadvantages: there is a time penalty since this handler requires two jumps, resulting in the pipeline being flushed each time a jump occurs.

6. Prioritized Direct interrupt handler

优先级直接中断和优先级标准中断不同之处在两方面:

第一:handler中一些处理的代码被移到了ISR中。这些代码就是mask out 这些lower-priority interrupts的。

第二:优先级直接中断的handler会直接调转到合适的ISR中。

summary

Handles higher-priority interrupts in a shorter time,Goes directly to the specific ISR

Low Interrupt latancy

Advantages: uses a single jump and saves valuable cycles to go to th ISR

Disadvantages: each ISR has a mechanism to set the external interrupt mask to stop lower-priority interrupts from halting the current ISR, which adds extra code to each ISR

7.Prioritized Grouped Interrupt Handler

summary

Mechanism for handling interrupts that are grouped into different priority levels

Low Interrupt latancy

Advantages: useful when the embeded system has to handle a large number of interrupts, and also reduces the response time since the determining of the priority level is shorter

Disadvantages: determing how the interrupts are grouped together

8.VIC PL 190 Based Interrupt Service Routine

VIC-vector interrupt controller

VIC是一个典型的hardware interrupt handler

9.Summary

异常会改变通常指令执行的序列。一共有7种异常:Data abort, Prefecth abort, Fast Interrupt Request, Interrupt Request, Undefined Intsruction, Software Interrupt, Reset.每一种异常都有相应的ARM处理器模式。当一个异常产生的时候,处理器会跳转到特殊的模式,并且branch到Vector table上相应的entry中。每一种异常都有优先级。

中断是一种由外设引发的特殊异常。IRQ异常用于通用的操作系统活动,FIQ通常用于某一种中断源。中断延时是从一个外部中断请求信号发出到ISR第一个指令被取出的间隔。

我们涉及到了8中interrupt scheme。从简单的无嵌套中断,到高级的优先级分组中断。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: