Skip to content

Commit c963d24

Browse files
Add support for vApplicationFPUSafeIRQHandler (#1113)
This PR adds support for vApplicationFPUSafeIRQHandler. The application writer needs to name their IRQ handler as: 1. vApplicationIRQHandler if the IRQ handler does not use FPU registers. 2. vApplicationFPUSafeIRQHandler is the IRQ handler uses FPU registers. When the application uses vApplicationFPUSafeIRQHandler, a default implementation of vApplicationIRQHandler is used which stores FPU registers and then calls vApplicationFPUSafeIRQHandler.
1 parent 53c7e7c commit c963d24

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

portable/GCC/ARM_CRx_No_GIC/portASM.S

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
.extern pxCurrentTCB
4040
.extern vTaskSwitchContext
4141
.extern vApplicationIRQHandler
42+
.extern vApplicationFPUSafeIRQHandler
4243
.extern ulPortInterruptNesting
4344
.extern ulPortTaskHasFPUContext
4445
.extern ulICCEOIR
@@ -237,6 +238,50 @@ vApplicationSVCHandler:
237238

238239
/*-----------------------------------------------------------*/
239240

241+
/* If the application provides an implementation of vApplicationIRQHandler(),
242+
* then it will get called directly without saving the FPU registers on
243+
* interrupt entry, and this weak implementation of vApplicationIRQHandler()
244+
* will not get called.
245+
*
246+
* If the application provides its own implementation of
247+
* vApplicationFPUSafeIRQHandler() then this implementation of
248+
* vApplicationIRQHandler() will be called, save the FPU registers, and then
249+
* call vApplicationFPUSafeIRQHandler().
250+
*
251+
* Therefore, if the application writer wants FPU registers to be saved on
252+
* interrupt entry, their IRQ handler must be called
253+
* vApplicationFPUSafeIRQHandler(), and if the application writer does not want
254+
* FPU registers to be saved on interrupt entry their IRQ handler must be
255+
* called vApplicationIRQHandler().
256+
*/
257+
.align 4
258+
.weak vApplicationIRQHandler
259+
.type vApplicationIRQHandler, %function
260+
vApplicationIRQHandler:
261+
PUSH {LR}
262+
263+
VMRS R1, FPSCR
264+
VPUSH {D0-D7}
265+
PUSH {R1}
266+
267+
BLX vApplicationFPUSafeIRQHandler
268+
269+
POP {R0}
270+
VPOP {D0-D7}
271+
VMSR FPSCR, R0
272+
273+
POP {PC}
274+
275+
/*-----------------------------------------------------------*/
276+
277+
.align 4
278+
.weak vApplicationFPUSafeIRQHandler
279+
.type vApplicationFPUSafeIRQHandler, %function
280+
vApplicationFPUSafeIRQHandler:
281+
B vApplicationFPUSafeIRQHandler
282+
283+
/*-----------------------------------------------------------*/
284+
240285
/*
241286
* UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );
242287
*

0 commit comments

Comments
 (0)