Skip to content

Commit 099e921

Browse files
ioannisgnashif
authored andcommitted
arm: cortex_m: update docs to reflect the lazy stacking functionality
Update the documentation for Lazy Stacking in Cortex-M, to reflect the functionality changes (activate the lazy stacking dynamically when building with MPU stack guards). Make a note that the FP sharing mode is now default in Cortex-M. Signed-off-by: Ioannis Glaropoulos <[email protected]>
1 parent 7328849 commit 099e921

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

doc/reference/kernel/other/float.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ or SSE user are not impacted by the computations performed by the other users.
7575
ARM Cortex-M architecture (with the Floating Point Extension)
7676
-------------------------------------------------------------
7777

78+
.. note::
79+
The Shared FP registers mode is the default Floating Point
80+
Services mode in ARM Cortex-M.
81+
7882
On the ARM Cortex-M architecture with the Floating Point Extension, the kernel
7983
treats *all* threads as FPU users when shared FP registers mode is enabled.
8084
This means that any thread is allowed to access the floating point registers.
@@ -92,7 +96,8 @@ using one of the techniques listed below.
9296

9397
Pretagging a thread with the :c:macro:`K_FP_REGS` option instructs the
9498
MPU-based stack protection mechanism to properly configure the size of
95-
the thread's guard region to always guarantee stack overflow detection.
99+
the thread's guard region to always guarantee stack overflow detection,
100+
and enable lazy stacking for the given thread upon thread creation.
96101

97102
During thread context switching the ARM kernel saves the *callee-saved*
98103
floating point registers, if the switched-out thread has been using them.
@@ -113,6 +118,17 @@ is currently enabled in Zephyr applications on ARM Cortex-M
113118
architecture, minimizing interrupt latency, when the floating
114119
point context is active.
115120

121+
When the MPU-based stack protection mechanism is not enabled, lazy stacking
122+
is always active in the Zephyr application. When the MPU-based stack protection
123+
is enabled, the following rules apply with respect to lazy stacking:
124+
125+
* Lazy stacking is activated by default on threads that are pretagged with
126+
:c:macro:`K_FP_REGS`
127+
* Lazy stacking is activated dynamically on threads that are not pretagged with
128+
:c:macro:`K_FP_REGS`, as soon as the kernel detects that they are using the
129+
floating point registers.
130+
131+
116132
If an ARM thread does not require use of the floating point registers any
117133
more, it can call :c:func:`k_float_disable`. This instructs the kernel
118134
not to save or restore its FP context during thread context switching.

0 commit comments

Comments
 (0)