1- //! Simple assembly routines
1+ //! Simple assembly routines for ARMv7
22
33/// Data Memory Barrier
44///
55/// Ensures that all explicit memory accesses that appear in program order before the `DMB`
66/// instruction are observed before any explicit memory accesses that appear in program order
77/// after the `DMB` instruction.
88#[ cfg_attr( not( feature = "check-asm" ) , inline) ]
9- #[ cfg( any(
10- arm_architecture = "v7-r" ,
11- arm_architecture = "v7-a" ,
12- arm_architecture = "v8-r"
13- ) ) ]
149pub fn dmb ( ) {
1510 use core:: sync:: atomic:: { compiler_fence, Ordering } ;
1611 compiler_fence ( Ordering :: SeqCst ) ;
@@ -28,11 +23,6 @@ pub fn dmb() {
2823/// * any explicit memory access made before this instruction is complete
2924/// * all cache and branch predictor maintenance operations before this instruction complete
3025#[ cfg_attr( not( feature = "check-asm" ) , inline) ]
31- #[ cfg( any(
32- arm_architecture = "v7-r" ,
33- arm_architecture = "v7-a" ,
34- arm_architecture = "v8-r"
35- ) ) ]
3626pub fn dsb ( ) {
3727 use core:: sync:: atomic:: { compiler_fence, Ordering } ;
3828 compiler_fence ( Ordering :: SeqCst ) ;
@@ -47,11 +37,6 @@ pub fn dsb() {
4737/// Flushes the pipeline in the processor, so that all instructions following the `ISB` are fetched
4838/// from cache or memory, after the instruction has been completed.
4939#[ cfg_attr( not( feature = "check-asm" ) , inline) ]
50- #[ cfg( any(
51- arm_architecture = "v7-r" ,
52- arm_architecture = "v7-a" ,
53- arm_architecture = "v8-r"
54- ) ) ]
5540pub fn isb ( ) {
5641 use core:: sync:: atomic:: { compiler_fence, Ordering } ;
5742 compiler_fence ( Ordering :: SeqCst ) ;
@@ -69,39 +54,40 @@ pub fn nop() {
6954
7055/// Emit an WFI instruction
7156#[ cfg_attr( not( feature = "check-asm" ) , inline) ]
72- #[ cfg( any(
73- arm_architecture = "v7-r" ,
74- arm_architecture = "v7-a" ,
75- arm_architecture = "v8-r"
76- ) ) ]
7757pub fn wfi ( ) {
7858 unsafe { core:: arch:: asm!( "wfi" , options( nomem, nostack, preserves_flags) ) }
7959}
8060
8161/// Emit an WFE instruction
8262#[ cfg_attr( not( feature = "check-asm" ) , inline) ]
83- #[ cfg( any(
84- arm_architecture = "v7-r" ,
85- arm_architecture = "v7-a" ,
86- arm_architecture = "v8-r"
87- ) ) ]
8863pub fn wfe ( ) {
8964 unsafe { core:: arch:: asm!( "wfe" , options( nomem, nostack, preserves_flags) ) }
9065}
9166
9267/// Emit an SEV instruction
9368#[ cfg_attr( not( feature = "check-asm" ) , inline) ]
94- #[ cfg( any(
95- arm_architecture = "v7-r" ,
96- arm_architecture = "v7-a" ,
97- arm_architecture = "v8-r"
98- ) ) ]
9969pub fn sev ( ) {
10070 unsafe {
10171 core:: arch:: asm!( "sev" ) ;
10272 }
10373}
10474
75+ /// Mask IRQ
76+ #[ cfg_attr( not( feature = "check-asm" ) , inline) ]
77+ pub fn irq_disable ( ) {
78+ unsafe {
79+ core:: arch:: asm!( "cpsid i" ) ;
80+ }
81+ }
82+
83+ /// Unmask IRQ
84+ #[ cfg_attr( not( feature = "check-asm" ) , inline) ]
85+ pub fn irq_enable ( ) {
86+ unsafe {
87+ core:: arch:: asm!( "cpsie i" ) ;
88+ }
89+ }
90+
10591/// Which core are we?
10692///
10793/// Return the bottom 24-bits of the MPIDR
@@ -113,12 +99,3 @@ pub fn core_id() -> u32 {
11399 }
114100 r & 0x00FF_FFFF
115101}
116-
117- #[ cfg( any( arm_architecture = "v4t" , arm_architecture = "v5te" ) ) ]
118- #[ no_mangle]
119- pub extern "C" fn __sync_synchronize ( ) {
120- // we don't have a barrier instruction - the linux kernel just uses an empty inline asm block
121- unsafe {
122- core:: arch:: asm!( "" ) ;
123- }
124- }
0 commit comments