Skip to content

Commit 93c32ab

Browse files
committed
Move other uses of asm::inner to modules using them.
This removes the inner module entirely.
1 parent 5aeb8d5 commit 93c32ab

18 files changed

Lines changed: 210 additions & 398 deletions

File tree

cortex-m/src/asm.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ use core::arch::asm;
77
#[cfg(cortex_m)]
88
use core::sync::atomic::{Ordering, compiler_fence};
99

10-
pub mod inner;
11-
1210
/// Puts the processor in Debug state. Debuggers can pick this up as a "breakpoint".
1311
///
1412
/// **NOTE** calling `bkpt` when the processor is not connected to a debugger will cause an

cortex-m/src/asm/inner.rs

Lines changed: 0 additions & 347 deletions
This file was deleted.

cortex-m/src/interrupt.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Interrupts
22
3+
use core::arch::asm;
4+
use core::sync::atomic::{Ordering, compiler_fence};
5+
36
pub use bare_metal::{CriticalSection, Mutex, Nr};
47

58
/// Trait for enums of external interrupt numbers.
@@ -35,7 +38,10 @@ unsafe impl<T: Nr + Copy> InterruptNumber for T {
3538
/// Disables all interrupts
3639
#[inline]
3740
pub fn disable() {
38-
unsafe { crate::asm::inner::__cpsid() };
41+
unsafe { asm!("cpsid i", options(nomem, nostack, preserves_flags)) };
42+
43+
// Ensure no subsequent memory accesses are reordered to before interrupts are disabled.
44+
compiler_fence(Ordering::SeqCst);
3945
}
4046

4147
/// Enables all the interrupts
@@ -44,8 +50,12 @@ pub fn disable() {
4450
///
4551
/// - Do not call this function inside an `interrupt::free` critical section
4652
#[inline]
53+
#[cortex_m_macros::asm_wrapper(any(armv6m, armv7m, armv7em, armv8m))]
4754
pub unsafe fn enable() {
48-
unsafe { crate::asm::inner::__cpsie() };
55+
// Ensure no preceeding memory accesses are reordered to after interrupts are enabled.
56+
compiler_fence(Ordering::SeqCst);
57+
58+
unsafe { asm!("cpsie i", options(nomem, nostack, preserves_flags)) };
4959
}
5060

5161
/// Execute closure `f` in an interrupt-free context.

0 commit comments

Comments
 (0)