http://infocenter.arm.com/help/index.js ... index.html
When dealing with systems where the FPU is used by multiple tasks, the context switching code can be designed in either of the following ways:
- The context of the FPU is always saved and restored.
- The context of the FPU is saved and restored only if the associated EXC_RETURN value is 0. This means the value of CONTROL.FPCA was 1 when the task was running, before entering the context switching code.
Looking at _port_switch in ChibiOS/os/common/ports/ARMCMx/compilers/GCC/chcoreasm_v7m.S, it seems that the floating point registers s16-s31 are always pushed/pop'd from the stack. What happens to s0-s15? What is the strategy used in ChibiOS when floating point is enabled? Also, if the FPU context is always saved and restored, doesn't that add to the context switch time if most of the threads are not using floating point (which is typically the case)? If so, any plans to make improvements in this regard? Not conditionally saving FPU context could also be beneficial in the context switching routine as that would likely necessitate the use of one or more branch instructions - so I could see why that would be preferred for some. Perhaps having a #define to choose behavior would be the best route.