aboutsummaryrefslogtreecommitdiff
path: root/src/asm.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2017-12-23 18:48:20 +0100
committerGravatar Jorge Aparicio <jorge@japaric.io> 2017-12-23 18:48:20 +0100
commit875ee38398f62b4c89e97ff891554d6fd5b7fafb (patch)
treeb348726a7dd842a210345b0afc975697ee43765c /src/asm.rs
parent9a80bae79d1eb9111e50406cb7cc088246deb04d (diff)
downloadcortex-m-875ee38398f62b4c89e97ff891554d6fd5b7fafb.tar.gz
cortex-m-875ee38398f62b4c89e97ff891554d6fd5b7fafb.tar.zst
cortex-m-875ee38398f62b4c89e97ff891554d6fd5b7fafb.zip
map asm! ops to unimplemented! on non ARM targets
Diffstat (limited to 'src/asm.rs')
-rw-r--r--src/asm.rs73
1 files changed, 26 insertions, 47 deletions
diff --git a/src/asm.rs b/src/asm.rs
index daa7b55..aab772e 100644
--- a/src/asm.rs
+++ b/src/asm.rs
@@ -7,58 +7,43 @@
/// cause an exception
#[inline(always)]
pub fn bkpt() {
- #[cfg(target_arch = "arm")]
- unsafe {
- asm!("bkpt"
- :
- :
- :
- : "volatile");
+ match () {
+ #[cfg(target_arch = "arm")]
+ () => unsafe { asm!("bkpt" :::: "volatile") },
+ #[cfg(not(target_arch = "arm"))]
+ () => unimplemented!(),
}
}
/// A no-operation. Useful to prevent delay loops from being optimized away.
-#[inline(always)]
+#[inline]
pub fn nop() {
- unsafe {
- asm!("nop"
- :
- :
- :
- : "volatile");
+ match () {
+ #[cfg(target_arch = "arm")]
+ () => unsafe { asm!("nop" :::: "volatile") },
+ #[cfg(not(target_arch = "arm"))]
+ () => unimplemented!(),
}
}
/// Wait For Event
-#[inline(always)]
+#[inline]
pub fn wfe() {
match () {
#[cfg(target_arch = "arm")]
- () => unsafe {
- asm!("wfe"
- :
- :
- :
- : "volatile")
- },
+ () => unsafe { asm!("wfe" :::: "volatile") },
#[cfg(not(target_arch = "arm"))]
- () => {}
+ () => unimplemented!(),
}
}
/// Wait For Interrupt
-#[inline(always)]
+#[inline]
pub fn wfi() {
match () {
#[cfg(target_arch = "arm")]
- () => unsafe{
- asm!("wfi"
- :
- :
- :
- : "volatile")
- },
+ () => unsafe { asm!("wfi" :::: "volatile") },
#[cfg(not(target_arch = "arm"))]
- () => {}
+ () => unimplemented!(),
}
}
@@ -66,15 +51,13 @@ pub fn wfi() {
///
/// Flushes the pipeline in the processor, so that all instructions following the `ISB` are fetched
/// from cache or memory, after the instruction has been completed.
-#[inline(always)]
+#[inline]
pub fn isb() {
match () {
#[cfg(target_arch = "arm")]
- () => unsafe {
- asm!("isb 0xF" : : : "memory" : "volatile");
- },
+ () => unsafe { asm!("isb 0xF" : : : "memory" : "volatile") },
#[cfg(not(target_arch = "arm"))]
- () => {}
+ () => unimplemented!(),
}
}
@@ -86,15 +69,13 @@ pub fn isb() {
///
/// * any explicit memory access made before this instruction is complete
/// * all cache and branch predictor maintenance operations before this instruction complete
-#[inline(always)]
+#[inline]
pub fn dsb() {
match () {
#[cfg(target_arch = "arm")]
- () => unsafe {
- asm!("dsb 0xF" : : : "memory" : "volatile");
- },
+ () => unsafe { asm!("dsb 0xF" : : : "memory" : "volatile") },
#[cfg(not(target_arch = "arm"))]
- () => {}
+ () => unimplemented!(),
}
}
@@ -103,14 +84,12 @@ pub fn dsb() {
/// Ensures that all explicit memory accesses that appear in program order before the `DMB`
/// instruction are observed before any explicit memory accesses that appear in program order
/// after the `DMB` instruction.
-#[inline(always)]
+#[inline]
pub fn dmb() {
match () {
#[cfg(target_arch = "arm")]
- () => unsafe {
- asm!("dmb 0xF" : : : "memory" : "volatile");
- },
+ () => unsafe { asm!("dmb 0xF" : : : "memory" : "volatile") },
#[cfg(not(target_arch = "arm"))]
- () => {}
+ () => unimplemented!(),
}
}