aboutsummaryrefslogtreecommitdiff
path: root/src/interrupt.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2018-04-26 01:52:07 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2018-04-26 01:52:07 +0200
commitbff66f8fa796e305df93f28d9a5e352eb51596e5 (patch)
treec6878210d90f8e7e8029a36cf8ebf23326c4f592 /src/interrupt.rs
parent00d6faae149c062e79a822b8d46b6b5e7e972f57 (diff)
downloadcortex-m-bff66f8fa796e305df93f28d9a5e352eb51596e5.tar.gz
cortex-m-bff66f8fa796e305df93f28d9a5e352eb51596e5.tar.zst
cortex-m-bff66f8fa796e305df93f28d9a5e352eb51596e5.zip
make compilable on stable
Diffstat (limited to 'src/interrupt.rs')
-rw-r--r--src/interrupt.rs32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/interrupt.rs b/src/interrupt.rs
index 5880dd4..b57cc80 100644
--- a/src/interrupt.rs
+++ b/src/interrupt.rs
@@ -1,16 +1,29 @@
//! Interrupts
+// use core::sync::atomic::{self, Ordering};
+
pub use bare_metal::{CriticalSection, Mutex, Nr};
/// Disables all interrupts
#[inline]
pub fn disable() {
match () {
- #[cfg(target_arch = "arm")]
+ #[cfg(all(cortex_m, feature = "inline-asm"))]
() => unsafe {
asm!("cpsid i" ::: "memory" : "volatile");
},
- #[cfg(not(target_arch = "arm"))]
+
+ #[cfg(all(cortex_m, not(feature = "inline-asm")))]
+ () => unsafe {
+ extern "C" {
+ fn __cpsid();
+ }
+
+ // XXX do we need a explicit compiler barrier here?
+ __cpsid();
+ },
+
+ #[cfg(not(cortex_m))]
() => unimplemented!(),
}
}
@@ -23,9 +36,20 @@ pub fn disable() {
#[inline]
pub unsafe fn enable() {
match () {
- #[cfg(target_arch = "arm")]
+ #[cfg(all(cortex_m, feature = "inline-asm"))]
() => asm!("cpsie i" ::: "memory" : "volatile"),
- #[cfg(not(target_arch = "arm"))]
+
+ #[cfg(all(cortex_m, not(feature = "inline-asm")))]
+ () => {
+ extern "C" {
+ fn __cpsie();
+ }
+
+ // XXX do we need a explicit compiler barrier here?
+ __cpsie();
+ }
+
+ #[cfg(not(cortex_m))]
() => unimplemented!(),
}
}