2018. 3. 25. 09:09 devel/개념
ARM Cortex-M Programming Guide to Memory Barrier Instructions
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHBFEIB.html
In normal applications there is no need to add any barrier instruction after using a CPS
instruction to enable an interrupt:
_enable_irq(); /* Compiles to “CPSIE I” - Clear PRIMASK */
If an interrupt was already in the pending state, the processor accepts the interrupt after the “CPSIE I
” is executed. However, additional instructions can be executed before the processor enters the exception handler:
for Cortex-M3 or Cortex-M4, the processor can execute up to TWO additional instructions before entering the interrupt service routine
for Cortex-M0, the processor can execute up to ONE additional instruction before entering the interrupt service routine.
Figure 14 shows the implemented interrupt enabling delay in the Cortex-M3 and Cortex-M4 processors.
Figure 14. Implemented interrupt enabling delay in the Cortex-M3 and Cortex-M4 processors
To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.
Figure 15 shows the implemented interrupt enabling delay in the Cortex-M0 and Cortex-M0+ processors.
Figure 15. Implemented interrupt enabling delay in the Cortex-M0 and Cortex-M0+ processors
To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.
ARM recommends that the architectural requirements are adopted.
If it is necessary to ensure a pended interrupt is recognized before subsequent operations, the
ISB
instruction should be used afterCPSIE I
. Figure 16 shows the use of theISB
instruction after enabling interrupts to permit immediate recognition of the pending interrupt.If it is not necessary to ensure that a pended interrupt will be recognized immediately before subsequent operations, it is not necessary to insert a memory barrier instruction.
Between two time critical tasks, if you want to permit a pended interrupt to take place, you can use an
ISB
instruction as follows:__enable_irq(); // CPSIE I : Enable interrupt __ISB(); // Allow pended interrupts to be recognized __disable_irq(); // CPSID I : Disable interrupt
Figure 16 shows the resulting behavior.
Figure 16. Use ISB after enabling interrupts to permit immediate recognition of a pending interrupt
To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.
A suitable architectural coding is:
To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.
Figure 17 shows the resulting behavior.
Figure 17. Architectural interrupt behavior between CSPIE and CPSID
To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.
Note
The same requirement applies when using the MSR
instruction to enable interrupts.
In Cortex-M processors:
If it is necessary to ensure a pended interrupt is recognized before subsequent operations, the
ISB
instruction should be used afterCPSIE I
. This is the same as the architectural requirement, see Figure 16.If it is not necessary to ensure that a pended interrupt is recognized immediately before subsequent operations, it is not necessary to insert a memory barrier instruction.
An exception to this rule is the sequence
CPSIE
followed byCPSID
. In Cortex-M processors, there is no need to insert anISB
betweenCPSIE
andCPSID
.A suitable implementation coding is:
To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.
Figure 18 shows the implemented behavior.
Figure 18. Implemented behavior requires no ISB between CPSIE and CPSID
To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.
Note
As the implementation requirements show, there is no need to add a memory barrier instruction between __enable_irq()
and __disable_irq()
. However, in the architecture, if the interrupt needs to be recognized between the CPSIE
and CPSID
instructions, then an ISB
instruction is needed. The same applies when using the MSR
instruction to enable interrupts.
'devel > 개념' 카테고리의 다른 글
Renesas RH850G3KH core의 barrier에 관해 (0) | 2022.10.10 |
---|---|
RH850G3KH core exception/interrupt 관련 정리 (1) | 2022.10.03 |
아마존 리눅스 서버 최적화 튜닝 (0) | 2017.11.15 |
주소가 주어진 영역 이내인지 확인 하는 방법 (0) | 2017.10.01 |
주소가 aligned 인지 확인하는 방법 (0) | 2017.09.30 |