diff options
author | 2020-08-31 21:08:05 +0000 | |
---|---|---|
committer | 2020-08-31 21:08:05 +0000 | |
commit | b05a24e6b31e039e059760a4245b378df008faf8 (patch) | |
tree | 50a7ce8ead7bb9ef1f34216e8934988572d442a8 /src/interrupt.rs | |
parent | 3260e397647b5ea4984e8c82cb537f2475da0f5d (diff) | |
parent | c27c8e5b063bd7058ba05dc3a9fa7886a1b1545c (diff) | |
download | cortex-m-b05a24e6b31e039e059760a4245b378df008faf8.tar.gz cortex-m-b05a24e6b31e039e059760a4245b378df008faf8.tar.zst cortex-m-b05a24e6b31e039e059760a4245b378df008faf8.zip |
Merge #262
262: Merge asm implementations r=therealprof a=jonas-schievink
This replaces the implementation of `inline-asm` with the file I wrote in #259 (and some fixes).
All functions that call assembly now do so via a `call_asm!` macro that either dispatches to a call to an `#[inline(always)]` function containing the inline `asm!`, or to the FFI shim. This makes all functions that call into asm significantly shorter.
The FFI shim is now also macro-generated, which makes it very small.
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Diffstat (limited to 'src/interrupt.rs')
-rw-r--r-- | src/interrupt.rs | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/src/interrupt.rs b/src/interrupt.rs index c5da48d..68719ec 100644 --- a/src/interrupt.rs +++ b/src/interrupt.rs @@ -26,25 +26,7 @@ pub unsafe trait InterruptNumber: Copy { /// Disables all interrupts #[inline] pub fn disable() { - match () { - #[cfg(all(cortex_m, feature = "inline-asm"))] - () => unsafe { - llvm_asm!("cpsid i" ::: "memory" : "volatile"); - }, - - #[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!(), - } + call_asm!(__cpsid()); } /// Enables all the interrupts @@ -54,23 +36,7 @@ pub fn disable() { /// - Do not call this function inside an `interrupt::free` critical section #[inline] pub unsafe fn enable() { - match () { - #[cfg(all(cortex_m, feature = "inline-asm"))] - () => llvm_asm!("cpsie i" ::: "memory" : "volatile"), - - #[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!(), - } + call_asm!(__cpsie()); } /// Execute closure `f` in an interrupt-free context. |