Skip to content

Commit

Permalink
Enable access to FPU registers only if FPU is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristosZosi authored and paulbartell committed Nov 25, 2022
1 parent ed1f4e6 commit 11ff2e3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion portable/GCC/ARM_CR5/portASM.S
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
LDR R1, [R2]
PUSH {R1}

#ifdef __ARM_FP
/* Does the task have a floating point context that needs saving? If
ulPortTaskHasFPUContext is 0 then no. */
LDR R2, ulPortTaskHasFPUContextConst
Expand All @@ -78,6 +79,7 @@

/* Save ulPortTaskHasFPUContext itself. */
PUSH {R3}
#endif /* __ARM_FP */

/* Save the stack pointer in the TCB. */
LDR R0, pxCurrentTCBConst
Expand All @@ -95,6 +97,7 @@
LDR R1, [R0]
LDR SP, [R1]

#ifdef __ARM_FP
/* Is there a floating point context to restore? If the restored
ulPortTaskHasFPUContext is zero then no. */
LDR R0, ulPortTaskHasFPUContextConst
Expand All @@ -107,6 +110,7 @@
/*VPOPNE {D16-D31}*/
VPOPNE {D0-D15}
VMSRNE FPSCR, R0
#endif /* __ARM_FP */

/* Restore the critical section nesting depth. */
LDR R0, ulCriticalNestingConst
Expand Down Expand Up @@ -279,22 +283,27 @@ switch_before_exit:
* FPU registers to be saved on interrupt entry their IRQ handler must be
* called vApplicationIRQHandler().
*****************************************************************************/

.align 4
.weak vApplicationIRQHandler
.type vApplicationIRQHandler, %function
vApplicationIRQHandler:

PUSH {LR}

#ifdef __ARM_FP
FMRX R1, FPSCR
VPUSH {D0-D15}
PUSH {R1}
#endif /* __ARM_FP */

LDR r1, vApplicationFPUSafeIRQHandlerConst
BLX r1

#ifdef __ARM_FP
POP {R0}
VPOP {D0-D15}
VMSR FPSCR, R0
#endif /* __ARM_FP */

POP {PC}

Expand Down

0 comments on commit 11ff2e3

Please sign in to comment.