Skip to content

Commit 2642eb2

Browse files
ioannisgnashif
authored andcommitted
arm: cortex_m: force FP context stacking by default
For the standard multi-theading builds, we will enforce FP context stacking only when FPU_SHARING is set. For the single-threading use case we enable context stacking by default. Signed-off-by: Ioannis Glaropoulos <[email protected]>
1 parent 56dd787 commit 2642eb2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/arm/core/aarch32/prep_c.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ static inline void z_arm_floating_point_init(void)
103103
* Upon reset, the FPU Context Control Register is 0xC0000000
104104
* (both Automatic and Lazy state preservation is enabled).
105105
*/
106-
#if !defined(CONFIG_FPU_SHARING)
107-
/* Default mode is Unshared FP registers mode. We disable the
106+
#if defined(CONFIG_MULTITHREADING) && !defined(CONFIG_FPU_SHARING)
107+
/* Unshared FP registers (multithreading) mode. We disable the
108108
* automatic stacking of FP registers (automatic setting of
109109
* FPCA bit in the CONTROL register), upon exception entries,
110110
* as the FP registers are to be used by a single context (and
@@ -116,14 +116,17 @@ static inline void z_arm_floating_point_init(void)
116116
FPU->FPCCR &= (~(FPU_FPCCR_ASPEN_Msk | FPU_FPCCR_LSPEN_Msk));
117117
#else
118118
/*
119+
* FP register sharing (multithreading) mode or single-threading mode.
120+
*
119121
* Enable both automatic and lazy state preservation of the FP context.
120122
* The FPCA bit of the CONTROL register will be automatically set, if
121123
* the thread uses the floating point registers. Because of lazy state
122124
* preservation the volatile FP registers will not be stacked upon
123125
* exception entry, however, the required area in the stack frame will
124126
* be reserved for them. This configuration improves interrupt latency.
125127
* The registers will eventually be stacked when the thread is swapped
126-
* out during context-switch.
128+
* out during context-switch or if an ISR attempts to execute floating
129+
* point instructions.
127130
*/
128131
FPU->FPCCR = FPU_FPCCR_ASPEN_Msk | FPU_FPCCR_LSPEN_Msk;
129132
#endif /* CONFIG_FPU_SHARING */

0 commit comments

Comments
 (0)