FIQ和IRQ中断系统有什么区别?
我想知道FIQ和IRQ中断系统的区别 任何微处理器,例如:ARM926EJ。
I want to know the difference between FIQ and IRQ interrupt system in
any microprocessor, e.g: ARM926EJ.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
ARM 将
FIQ
称为快速中断,暗示IRQ
是正常优先级。 在任何实际系统中,都会有比两个设备更多的中断源,因此会有一些外部硬件中断控制器,它允许对这些多个源进行屏蔽、优先级排序等,并将中断请求线驱动到处理器。在某种程度上,这使得两种中断模式之间的区别变得多余,并且许多系统根本不使用nFIQ,或者以类似于不可屏蔽(NMI)的方式使用它code>)在其他处理器上发现的中断(尽管
FIQ
在大多数 ARM 处理器上是可软件屏蔽的)。r8-r14
。 R14 是链接寄存器,保存来自 FIQ 的返回地址(+4)。 但是,如果您的 FIQ 处理程序能够编写为仅使用 r8-r13,则它可以通过两种方式利用这些存储寄存器:r8
可以用作指向硬件设备的指针,并且处理程序可以依赖于下次调用时,r8
中的值相同。0x1C
) 意味着如果将 FIQ 处理程序代码直接放置在向量表的末尾,则不需要分支 - 代码可以直接从 <代码>0x1C。 这节省了进入 ISR 的几个周期。r8-r13
。 由符合 ARM 的ATPCS
过程调用标准的 C 编译器生成的代码将使用寄存器r0-r3
作为临时值,并且不会生成正确的cpsr
在函数末尾恢复返回代码。ARM calls
FIQ
the fast interrupt, with the implication thatIRQ
is normal priority. In any real system, there will be many more sources of interrupts than just two devices and there will therefore be some external hardware interrupt controller which allows masking, prioritization etc. of these multiple sources and which drives the interrupt request lines to the processor.To some extent, this makes the distinction between the two interrupt modes redundant and many systems do not use
nFIQ
at all, or use it in a way analogous to the non-maskable (NMI
) interrupt found on other processors (althoughFIQ
is software maskable on most ARM processors).r8-r14
. R14 is the link register which holds the return address(+4) from the FIQ. But if your FIQ handler is able to be written such that it only usesr8-r13
, it can take advantage of these banked registers in two ways:r8
may be used as a pointer to a hardware device and the handler can rely on the same value being inr8
the next time it is called.0x1C
) means that if the FIQ handler code is placed directly at the end of the vector table, no branch is required - the code can execute directly from0x1C
. This saves a few cycles on entry to the ISR.r8-r13
. Code produced by a C compiler compliant with ARM'sATPCS
procedure call standard will instead use registersr0-r3
for scratch values and will not produce the correctcpsr
restoring return code at the end of the function.FIQ 或快速中断 在某些 ARM 参考文献中通常称为软 DMA。
FIQ 的功能> 是,
最后一个功能还比必须分支的IRQ稍有优势。
“C”速度演示
有些人提到了用汇编程序编码来处理 FIQ 的困难。
gcc
有注释来编码 FIQ 处理程序。 这是一个例子,这转换为以下几乎很好的汇编程序,
0x1c
处的汇编程序例程可能看起来像,一个真正的 UART 可能有一个就绪位,但是代码使用 FIQ 制作高速软 DMA 只需要 10-20 条指令。 主代码需要轮询 FIQ
r10
以确定缓冲区何时完成。 主(非中断代码)可以通过使用msr
指令来传输和设置存储的FIQ寄存器,以切换到FIQ模式并传输非中断分组 R0-R7 到分组 R8-R13 寄存器。通常 RTOS 中断延迟为 500-1000 条指令。 对于Linux,可能有2000-10000条指令。 真正的 DMA 总是更可取,但是,对于高频简单中断(如缓冲区传输),FIQ 可以提供解决方案。
由于FIQ与速度有关,因此如果您在汇编程序中编码不安全(或愿意投入时间),则不应考虑它。 由无限运行的程序员编写的汇编器将比编译器更快。 有 GCC 的帮助可以帮助新手。
延迟
由于FIQ有一个单独的掩码位,因此它几乎无处不在。 在早期的ARM CPU(例如ARM926EJ)上,一些原子操作必须通过屏蔽中断来实现。 即使使用最先进的 Cortex CPU,操作系统有时也会屏蔽中断。 通常,服务时间对于中断并不重要,重要的是发信号和服务之间的时间。 在这里,FIQ也有优势。
缺点
FIQ 不可扩展。 为了使用多个
FIQ
源,存储的寄存器必须在中断例程之间共享。 此外,还必须添加代码来确定导致中断/FIQ 的原因。 FIQ 通常是一招小马。如果您的中断非常复杂(网络驱动程序、USB 等),那么 FIQ 可能没有什么意义。 这与多路复用中断基本上是相同的语句。 存储寄存器提供 6 个自由变量供使用,永远不会从内存加载。 寄存器比内存快。 寄存器比二级缓存更快。 寄存器比 L1 缓存更快。 寄存器速度很快。 如果您无法编写使用 6 个变量运行的例程,则 FIQ 不适合。 注意:如果您使用 16 位值,您可以使用 shifts 和 rotates 来双重使用某些寄存器,这些寄存器在 ARM 上是免费的。
显然FIQ更为复杂。 操作系统开发人员希望支持多个中断源。 客户对FIQ的要求会有所不同,他们常常意识到他们应该让客户自行部署。 通常对FIQ的支持是有限的,因为任何支持都可能会损害主要好处,速度。
摘要
不要攻击我的朋友FIQ。 这是系统程序员对抗愚蠢硬件的一个技巧。 它并不适合所有人,但它有它的位置。 当所有其他减少延迟和增加 ISR 服务频率的尝试都失败时,FIQ 可能是您唯一的选择(或更好的硬件团队)。
它还可以在某些安全关键型应用中用作紧急中断。
FIQ or fast interrupt is often referred to as Soft DMA in some ARM references.
Features of the FIQ are,
The last feature also gives a slight advantage over an IRQ which must branch.
A speed demo in 'C'
Some have quoted the difficulty of coding in assembler to handle the FIQ.
gcc
has annotations to code a FIQ handler. Here is an example,This translates to the following almost good assembler,
The assembler routine at
0x1c
might look like,A real UART probably has a ready bit, but the code to make a high speed soft DMA with the FIQ would only be 10-20 instructions. The main code needs to poll the FIQ
r10
to determine when the buffer is finished. Main (non-interrupt code) may transfer and setup the banked FIQ registers by using themsr
instruction to switch to FIQ mode and transfer non-banked R0-R7 to the banked R8-R13 registers.Typically RTOS interrupt latency will be 500-1000 instructions. For Linux, it maybe 2000-10000 instructions. Real DMA is always preferable, however, for high frequency simple interrupts (like a buffer transfer), the FIQ can provide a solution.
As the FIQ is about speed, you shouldn't consider it if you aren't secure in coding in assembler (or willing to dedicate the time). Assembler written by an infinitely running programmer will be faster than a compiler. Having GCC assist can help a novice.
Latency
As the FIQ has a separate mask bit it is almost ubiquitously enabled. On earlier ARM CPUs (such as the ARM926EJ), some atomic operations had to be implemented by masking interrupts. Still even with the most advanced Cortex CPUs, there are occasions where an OS will mask interrupts. Often the service time is not critical for an interrupt, but the time between signalling and servicing. Here, the FIQ also has an advantage.
Weakness
The FIQ is not scalable. In order to use multiple
FIQ
sources, the banked registers must be shared among interrupt routines. Also, code must be added to determine what caused the interrupt/FIQ. The FIQ is generally a one trick pony.If your interrupt is highly complex (network driver, USB, etc), then the FIQ probably makes little sense. This is basically the same statement as multiplexing the interrupts. The banked registers give 6 free variables to use which never load from memory. Register are faster than memory. Registers are faster than L2-cache. Registers are faster than L1-cache. Registers are fast. If you can not write a routine that runs with 6 variables, then the FIQ is not suitable. Note: You can double duty some register with shifts and rotates which are free on the ARM, if you use 16 bit values.
Obviously the FIQ is more complex. OS developers want to support multiple interrupt sources. Customer requirements for a FIQ will vary and often they realize they should just let the customer roll their own. Usually support for a FIQ is limited as any support is likely to detract from the main benefit, SPEED.
Summary
Don't bash my friend the FIQ. It is a system programers one trick against stupid hardware. It is not for everyone, but it has its place. When all other attempts to reduce latency and increase ISR service frequency has failed, the FIQ can be your only choice (or a better hardware team).
It also possible to use as a panic interrupt in some safety critical applications.
现代 ARM CPU(以及其他一些 CPU)的一项功能。
来自专利:
换句话说,FIQ 只是一个较高优先级的中断请求,通过在请求服务期间禁用 IRQ 和其他 FIQ 处理程序来确定优先级。 因此,在处理活动的 FIQ 中断期间不会发生其他中断。
A feature of modern ARM CPUs (and some others).
From the patent:
In other words, an FIQ is just a higher priority interrupt request, that is prioritized by disabling IRQ and other FIQ handlers during request servicing. Therefore, no other interrupts can occur during the processing of the active FIQ interrupt.
Chaos 已经给出了很好的答案,但到目前为止尚未涵盖的另一点是 FIQ 位于向量表的末尾,因此通常/传统上只是在那里启动例程,而 IRQ 向量通常就是这样。 (即跳转到其他地方)。 在完整的存储和上下文切换之后立即避免额外的分支可以稍微提高速度。
Chaos has already answered well, but an additional point not covered so far is that FIQ is at the end of the vector table and so it's common/traditional to just start the routine right there, whereas the IRQ vector is usually just that. (ie a jump to somewhere else). Avoiding that extra branch immediately after a full stash and context switch is a slight speed gain.
另一个原因是在 FIQ 的情况下,需要较少数量的寄存器压入堆栈,FIQ 模式有 R8 到 R14_fiq 寄存器
another reason is in case of FIQ, lesser number of register is needed to push in the stack, FIQ mode has R8 to R14_fiq registers
FIQ 具有更高的优先级,可以在处理另一个 IRQ 时引入。 最关键的资源由 FIQ 处理,其余资源由 IRQ 处理。
FIQ is higher priority, and can be introduced while another IRQ is being handled. The most critical resource(s) are handled by FIQ's, the rest are handled by IRQ's.
我相信这就是您正在寻找的:
http://newsgroups.derkeiler.com/Archive/Comp/comp.sys.arm/2005-09/msg00084.html
本质上,FIQ 将具有多个优先级较低的 IRQ 源的最高优先级。
I believe this is what you are looking for:
http://newsgroups.derkeiler.com/Archive/Comp/comp.sys.arm/2005-09/msg00084.html
Essentially, FIQ will be of the highest priority with multiple, lower priority IRQ sources.
毫无疑问,FIQ 的优先级更高,剩下的点我不确定..... FIQ 将支持高速数据传输(或)通道处理,在需要高速数据处理的情况下,我们使用 FIQ,并且通常使用 IRQ 进行正常中断处理。
FIQs are higher priority, no doubt, remaining points i am not sure..... FIQs will support high speed data transfer (or) channel processing, where high speed data processes is required we use FIQs and generally IRQs are used normal interrupt handlling.
FIQ 没有任何魔力。 FIQ 只能中断正在服务的任何其他 IRQ,这就是它被称为“快速”的原因。 系统对这些中断的反应更快,但其余部分是相同的。
No any magic about FIQ. FIQ just can interrupt any other IRQ which is being served,this is why it is called 'fast'. The system reacts faster on these interrupts but the rest is the same.
这取决于我们如何设计中断处理程序,因为 FIQ 最终可能不需要一个分支指令,而且它有一组独特的 r8-r14 寄存器,因此下次我们回到 FIQ 中断时,我们不需要推送/弹出堆。 当然,它节省了一些周期,但是让更多的处理程序服务于一个 FIQ 并不是明智之举,是的,FIQ 具有更高的优先级,但没有任何理由说它处理中断速度更快,IRQ/FIQ 都以相同的 CPU 频率运行,所以它们必须以相同的速度运行。
It Depends how we design interrupt handlers, as FIQ is at last it may not need one branch instruction, also it has unique set of r8-r14 registers so next time we come back to FIQ interrupt we do not need to push/pop up the stack. Ofcourse it saves some cycles, but again it is not wise to have more handlers serving one FIQ and yes FIQ is having more priority but it is not any reason to say it handles the interrupt faster, both IRQ/FIQ run at same CPU frequency, So they must be running at same speed.
如果您的用例不是关于执行速度而是关于延迟,那么将 FIQ 与用 C* 而不是汇编程序编写的服务例程 (ISR) 结合使用可能会产生比标准方法更精简的代码。 考虑一个需要以比其他几个不频繁任务的执行时间更低的延迟来执行的任务。
标准方法:不频繁任务的 IRQ 仅设置通知标志并返回,以便可以以低延迟服务频繁任务的 ISR。 在任何 ISR 之外,每当设置相应的标志时,就会完成不频繁任务的工作。
使用 FIQ,您不需要通知,但每个任务都将完全作为 ISR 运行。
*) 鉴于您的 C 编译器知道如何实现 FIQ ISR。 例如,引用 ARM 优化 C/C++ 编译器 v18.1.0.LTS 用户指南(修订版 R):
If your use case is not about speed of execution but latency, using FIQ with the servicing routine (ISR) written in C* instead of assembler may result in leaner code than the standard approach. Think of one task that needs to be executed with a lower latency than the execution time of each of several other infrequent tasks.
The standard approach: The IRQs for the infrequent tasks would only set notification flags and return, so that the frequent task's ISR can be served with low latency. Outside of any ISR, the work of the infrequent tasks is done whenever the corresponding flag is set.
Using FIQ, you would not need notifications, but each task would run fully as ISR.
*) Given that your C compiler knows how to implement FIQ ISRs. Citing, for example, ARM Optimizing C/C++ Compiler v18.1.0.LTS User's Guide (Rev. R):
这可能是错误的。 我所知道的是 FIQ 代表快速中断请求,IRQ 代表中断请求。 从这些名称来看,我猜测 FIQ 的处理(抛出?)会比 IRQ 更快。 这可能与处理器的设计有关,其中 FIQ 会比 IRQ 更快地中断进程。 如果我错了,我很抱歉,但我通常会进行更高级别的编程,我现在只是猜测。
This may be wrong. All I know is that FIQ stands for Fast Interrupt Request and that IRQ stands for Interrupt Request. Judging from these names, I will guess that a FIQ will be handled(thrown?) faster than an IRQ. It probably has something to do with the design of the processor where an FIQ will interrupt the process faster than an IRQ. I apologize if I'm wrong, but I normally do higher level programming, I'm just guessing right now.