Add more memory barriers to avoid code re-ordering issues with DMA (#155)

* Add more memory barriers to avoid code re-ordering issues with DMA

* Comment typos

* Fix Wstrict-prototype on __compiler_memory_barrier

* Remove now-redundant __compiler_barrier macro from hardware_flash

Co-authored-by: Luke Wren <wren6991@gmail.com>
This commit is contained in:
Graham Sanderson
2021-02-19 07:11:56 -06:00
committed by graham sanderson
parent 4b7ffd71f0
commit 0732d0c2a3
5 changed files with 100 additions and 28 deletions

View File

@ -111,7 +111,18 @@ inline static void __wfi(void) {
* instruction will be observed before any explicit access after the instruction.
*/
inline static void __dmb(void) {
__asm volatile ("dmb");
__asm volatile ("dmb" : : : "memory");
}
/*! \brief Insert a DSB instruction in to the code path.
* \ingroup hardware_sync
*
* The DSB (data synchronization barrier) acts as a special kind of data
* memory barrier (DMB). The DSB operation completes when all explicit memory
* accesses before this instruction complete.
*/
inline static void __dsb(void) {
__asm volatile ("dsb" : : : "memory");
}
/*! \brief Insert a ISB instruction in to the code path.