FIQ와 IRQ 인터럽트 시스템의 차이점은 무엇입니까?
모든 마이크로 프로세서 (예 : ARM926EJ)에서 FIQ와 IRQ 인터럽트 시스템의 차이점을 알고 싶습니다.
최신 ARM CPU (및 일부 기타)의 기능입니다.
특허에서 :
하나 이상의 인터럽트를 처리 할 수있는 디지털 데이터 프로세서에서 고속 인터럽트를 수행하는 방법이 제공된다. 빠른 인터럽트 요청이 수신되면 플래그가 설정되고 프로그램 카운터 및 조건 코드 레지스터가 스택에 저장됩니다. 인터럽트 서비스 루틴이 끝날 때 인터럽트 명령으로부터의 복귀는 디지털 데이터 프로세서의 상태를 포함하는 조건 코드 레지스터를 검색하고 플래그가 설정되었는지 여부를 확인합니다. 플래그가 설정되면 빠른 인터럽트가 서비스되었으므로 프로그램 카운터 만 스택 해제되었음을 나타냅니다.
즉, FIQ는 요청 서비스 중에 IRQ 및 기타 FIQ 처리기를 비활성화하여 우선 순위가 지정된 더 높은 우선 순위 인터럽트 요청입니다. 따라서 활성 FIQ 인터럽트를 처리하는 동안 다른 인터럽트가 발생할 수 없습니다.
ARM 은 보통 우선 순위를 의미하는 빠른 인터럽트를 호출 FIQ
합니다 . 실제 시스템에는 두 개의 장치보다 더 많은 인터럽트 소스가 있으므로 이러한 여러 소스의 마스킹, 우선 순위 지정 등을 허용하고 인터럽트 요청 라인을 프로세서로 유도하는 외부 하드웨어 인터럽트 컨트롤러가 있습니다.IRQ
어느 정도까지는 두 인터럽트 모드가 중복되고 많은 시스템이 전혀 사용하지 않거나 다른 프로세서에서 발견되는 nFIQ
마스킹 불가능 ( NMI
) 인터럽트 와 유사한 방식으로 사용합니다 ( FIQ
대부분의 ARM에서 소프트웨어 마스킹 가능 하지만 ). 프로세서).
그렇다면 ARM은 왜 FIQ를 "fast"라고 부릅니까?
- FIQ 모드에는 전용 뱅크 레지스터 인
r8-r14
. R14는 FIQ에서 반환 주소 (+4)를 보유하는 링크 레지스터입니다. 그러나 FIQ 핸들러가를 사용하도록 작성 될 수있는 경우 다음r8-r13
두 가지 방법으로 이러한 뱅크 레지스터를 활용할 수 있습니다.- 하나는 ISR (인터럽트 서비스 루틴)에서 사용하는 레지스터를 푸시하고 팝하는 오버 헤드가 발생하지 않는다는 것입니다. 이것은 ISR 로의 진입과 퇴장 모두에서 상당한 수의 사이클을 절약 할 수 있습니다.
- 또한 핸들러는 한 호출에서 다음 호출까지 레지스터에 지속되는 값에 의존 할 수 있으므로 예를 들어
r8
하드웨어 장치에 대한 포인터로 사용될 수 있고 핸들러는r8
다음에 호출 될 때 동일한 값에 의존 할 수 있습니다 .
- 예외 벡터 테이블 (
0x1C
) 의 끝에있는 FIQ 위치 는 FIQ 핸들러 코드가 벡터 테이블의 끝에 직접 배치되는 경우 분기가 필요하지 않음을 의미합니다. 코드는에서 직접 실행할 수 있습니다0x1C
. 이렇게하면 ISR에 들어갈 때 몇주기가 절약됩니다. - FIQ는 IRQ보다 우선 순위가 높습니다. 즉, 코어가 FIQ 예외를 받으면 IRQ를 자동으로 마스킹합니다. IRQ는 FIQ 처리기를 중단 할 수 없습니다. 그 반대는 사실이 아닙니다. IRQ는 FIQ를 마스킹하지 않으므로 FIQ 핸들러 (사용되는 경우)가 IRQ를 중단 할 수 있습니다. 또한 IRQ 및 FIQ 요청이 동시에 발생하면 코어가 먼저 FIQ를 처리합니다.
그렇다면 왜 많은 시스템이 FIQ를 사용하지 않습니까?
- FIQ 핸들러 코드는 일반적으로 C로 작성할 수 없습니다. 어셈블리 언어로 직접 작성해야합니다. FIQ를 사용하기 위해 ISR 성능에 충분히 관심이 있다면 어떤 경우에도 C로 코딩하여 테이블에 몇주기를 남기고 싶지 않을 것입니다. 그러나 더 중요한 것은 C 컴파일러가 레지스터 만 사용합니다
r8-r13
. ARM의ATPCS
프로 시저 호출 표준을 준수하는 C 컴파일러에 의해 생성 된 코드는r0-r3
스크래치 값에 레지스터 를 대신 사용cpsr
하며 함수 끝에 올바른 복원 반환 코드를 생성하지 않습니다 . - 모든 인터럽트 컨트롤러 하드웨어는 일반적으로 IRQ 핀에 있습니다. FIQ를 사용하는 것은 nFIQ 입력에 가장 높은 우선 순위의 인터럽트 소스가 연결되어 있고 많은 시스템에 영구적으로 가장 높은 우선 순위의 소스가없는 경우에만 의미가 있습니다. 여러 소스를 FIQ에 연결 한 다음 소프트웨어가 이들 사이에 우선 순위를두면 FIQ가 IRQ에 비해 갖는 거의 모든 이점이 제거되므로 가치가 없습니다.
FIQ 또는 빠른 인터럽트 는 일부 ARM 참조에서 종종 Soft DMA 라고합니다 . FIQ의
특징은 다음 과 같습니다.
- 스택, 링크 레지스터 및 R8-R12를 포함한 뱅크 레지스터가있는 분리 모드.
- 별도의 FIQ 활성화 / 비활성화 비트.
- 벡터 테이블의 꼬리 (항상 캐시에 있으며 MMU에 의해 매핑 됨).
마지막 기능 은 분기해야하는 IRQ에 비해 약간의 이점을 제공 합니다.
'C'의 속도 데모
일부는 FIQ를 처리하기 위해 어셈블러에서 코딩의 어려움을 인용했습니다. FIQ 핸들러 gcc
를 코딩하는 주석이 있습니다 . 여기에 예가 있습니다.
void __attribute__ ((interrupt ("FIQ"))) fiq_handler(void)
{
/* registers set previously by FIQ setup. */
register volatile char *src asm ("r8"); /* A source buffer to transfer. */
register char *uart asm ("r9"); /* pointer to uart tx register. */
register int size asm ("r10"); /* Size of buffer remaining. */
if(size--) {
*uart = *src++;
}
}
이것은 거의 다음과 같은 어셈블러로 해석됩니다.
00000000 <fiq_handler>:
0: e35a0000 cmp sl, #0
4: e52d3004 push {r3} ; use r11, r12, etc as scratch.
8: 15d83000 ldrbne r3, [r8]
c: 15c93000 strbne r3, [r9]
10: e49d3004 pop {r3} ; same thing.
14: e25ef004 subs pc, lr, #4
의 어셈블러 루틴 0x1c
은 다음과 같습니다.
tst r10, #0 ; counter zero?
ldrbne r11, [r8] ; get character.
subne r10, #1 ; decrement count
strbne r11, [r9] ; write to uart
subs pc, lr, #4 ; return from FIQ.
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 the msr
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.
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.
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 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.
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.
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.
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.
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.
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.
'Development Tip' 카테고리의 다른 글
Ruby 배열에서 동일한 문자열 요소를 계산하는 방법 (0) | 2020.11.02 |
---|---|
.htaccess 리디렉션 http를 https로 (0) | 2020.11.02 |
angular.js 배열에서 요소 / 노드를 제거하는 방법 (0) | 2020.11.02 |
클릭시 EditText를 지우는 방법은 무엇입니까? (0) | 2020.11.02 |
실행 중 오류가 발생했습니다 (도메인 = LaunchServicesError, 코드 = 0). (0) | 2020.11.02 |