Skip to content

Commit cdf224f

Browse files
authored
Merge pull request #38 from rust-embedded/add-dmb-instruction
add DMB function in ASM module
2 parents 7da1135 + 7f9385d commit cdf224f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

cortex-ar/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- `dmb` data memory barrier in ASM module.
13+
1014
## [v0.2.0]
1115

1216
### Added

cortex-ar/src/asm.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
33
use core::sync::atomic::{compiler_fence, Ordering};
44

5+
/// Data Memory Barrier
6+
///
7+
/// Ensures that all explicit memory accesses that appear in program order before the `DMB`
8+
/// instruction are observed before any explicit memory accesses that appear in program order
9+
/// after the `DMB` instruction.
10+
#[inline]
11+
pub fn dmb() {
12+
compiler_fence(Ordering::SeqCst);
13+
unsafe {
14+
core::arch::asm!("dmb", options(nostack, preserves_flags));
15+
}
16+
compiler_fence(Ordering::SeqCst);
17+
}
18+
519
/// Data Synchronization Barrier
620
///
721
/// Acts as a special kind of memory barrier. No instruction in program order after this instruction

0 commit comments

Comments
 (0)