]> begriffs open source - cmsis/commit
GCC: add WFI/WFE compiler barriers
authorKevin Bracey <kevin.bracey@arm.com>
Wed, 9 Jan 2019 12:22:32 +0000 (14:22 +0200)
committerJonatan Antoni <jonatan.antoni@arm.com>
Tue, 30 Jul 2019 14:52:01 +0000 (16:52 +0200)
commitdb746d66cda089f1f5acd86a07b4f469bc6f2aad
tree6b726056bd4571f6d8edfc153802d8b3c86b4aa4
parente047ca44962ea7320d6807113d4cc5e4b228a49b
GCC: add WFI/WFE compiler barriers

Add "memory" clobber to __WFI and __WFE. Architecturally these should
always be immediately preceded by a __DSB (eg to ensure the write buffer
is drained). Without a barrier on WFI, the following compiler reordering
would be permitted:

     __DSB();             __DSB();
     __WFI();       ->    val_in_ram = 3;
     val_in_ram = 3;      __WFI();

This could cause some power issues with the external bus not being
idle.

The added barrier should have no impact on code size, assuming these
instructions are always accompanied by DSB, as DSB does have its own
memory clobber already.

SEV not modified as there are no issues with the equivalent reordering;
we only need the SEV to not be reordered before the DSB, which is
ensured by volatile.
CMSIS/Core/Include/cmsis_gcc.h
CMSIS/Core_A/Include/cmsis_gcc.h