66use core:: arch:: asm;
77#[ cfg( cortex_m) ]
88use core:: sync:: atomic:: { Ordering , compiler_fence} ;
9+ use cortex_m_macros:: asm_cfg;
910
1011/// Puts the processor in Debug state. Debuggers can pick this up as a "breakpoint".
1112///
1213/// **NOTE** calling `bkpt` when the processor is not connected to a debugger will cause an
1314/// exception.
1415#[ inline( always) ]
15- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
16+ #[ asm_cfg( cortex_m) ]
1617pub fn bkpt ( ) {
1718 unsafe { asm ! ( "bkpt" , options( nomem, nostack, preserves_flags) ) } ;
1819}
@@ -32,7 +33,7 @@ pub fn bkpt() {
3233/// initialization of peripherals if and only if accurate timing is not essential. In any other case
3334/// please use a more accurate method to produce a delay.
3435#[ inline]
35- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
36+ #[ asm_cfg( cortex_m) ]
3637pub fn delay ( cycles : u32 ) {
3738 // The loop will normally take 3 to 4 CPU cycles per iteration, but superscalar cores
3839 // (eg. Cortex-M7) can potentially do it in 2, so we use that as the lower bound, since delaying
@@ -57,7 +58,7 @@ pub fn delay(cycles: u32) {
5758
5859/// A no-operation. Useful to prevent delay loops from being optimized away.
5960#[ inline]
60- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
61+ #[ asm_cfg( cortex_m) ]
6162pub fn nop ( ) {
6263 // NOTE: This is a `pure` asm block, but applying that option allows the compiler to eliminate
6364 // the nop entirely (or to collapse multiple subsequent ones). Since the user probably wants N
@@ -69,28 +70,28 @@ pub fn nop() {
6970///
7071/// Can be used as a stable alternative to `core::intrinsics::abort`.
7172#[ inline]
72- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
73+ #[ asm_cfg( cortex_m) ]
7374pub fn udf ( ) -> ! {
7475 unsafe { asm ! ( "udf #0" , options( noreturn, nomem, nostack, preserves_flags) ) } ;
7576}
7677
7778/// Wait For Event
7879#[ inline]
79- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
80+ #[ asm_cfg( cortex_m) ]
8081pub fn wfe ( ) {
8182 unsafe { asm ! ( "wfe" , options( nomem, nostack, preserves_flags) ) } ;
8283}
8384
8485/// Wait For Interrupt
8586#[ inline]
86- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
87+ #[ asm_cfg( cortex_m) ]
8788pub fn wfi ( ) {
8889 unsafe { asm ! ( "wfi" , options( nomem, nostack, preserves_flags) ) } ;
8990}
9091
9192/// Send Event
9293#[ inline]
93- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
94+ #[ asm_cfg( cortex_m) ]
9495pub fn sev ( ) {
9596 unsafe { asm ! ( "sev" , options( nomem, nostack, preserves_flags) ) } ;
9697}
@@ -100,7 +101,7 @@ pub fn sev() {
100101/// Flushes the pipeline in the processor, so that all instructions following the `ISB` are fetched
101102/// from cache or memory, after the instruction has been completed.
102103#[ inline]
103- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
104+ #[ asm_cfg( cortex_m) ]
104105pub fn isb ( ) {
105106 compiler_fence ( Ordering :: SeqCst ) ;
106107 unsafe { asm ! ( "isb" , options( nostack, preserves_flags) ) } ;
@@ -115,7 +116,7 @@ pub fn isb() {
115116/// * any explicit memory access made before this instruction is complete
116117/// * all cache and branch predictor maintenance operations before this instruction complete
117118#[ inline]
118- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
119+ #[ asm_cfg( cortex_m) ]
119120pub fn dsb ( ) {
120121 compiler_fence ( Ordering :: SeqCst ) ;
121122 unsafe { asm ! ( "dsb" , options( nostack, preserves_flags) ) } ;
@@ -128,7 +129,7 @@ pub fn dsb() {
128129/// instruction are observed before any explicit memory accesses that appear in program order
129130/// after the `DMB` instruction.
130131#[ inline]
131- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
132+ #[ asm_cfg( cortex_m) ]
132133pub fn dmb ( ) {
133134 compiler_fence ( Ordering :: SeqCst ) ;
134135 unsafe { asm ! ( "dmb" , options( nostack, preserves_flags) ) } ;
@@ -141,7 +142,7 @@ pub fn dmb() {
141142/// Returns a Test Target Response Payload (cf section D1.2.215 of
142143/// Armv8-M Architecture Reference Manual).
143144#[ inline]
144- #[ cortex_m_macros :: asm_cfg( armv8m) ]
145+ #[ asm_cfg( armv8m) ]
145146// The __tt function does not dereference the pointer received.
146147#[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
147148pub fn tt ( addr : * mut u32 ) -> u32 {
@@ -163,7 +164,7 @@ pub fn tt(addr: *mut u32) -> u32 {
163164/// Returns a Test Target Response Payload (cf section D1.2.215 of
164165/// Armv8-M Architecture Reference Manual).
165166#[ inline]
166- #[ cortex_m_macros :: asm_cfg( armv8m) ]
167+ #[ asm_cfg( armv8m) ]
167168// The __ttt function does not dereference the pointer received.
168169#[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
169170pub fn ttt ( addr : * mut u32 ) -> u32 {
@@ -186,7 +187,7 @@ pub fn ttt(addr: *mut u32) -> u32 {
186187/// Returns a Test Target Response Payload (cf section D1.2.215 of
187188/// Armv8-M Architecture Reference Manual).
188189#[ inline]
189- #[ cortex_m_macros :: asm_cfg( armv8m) ]
190+ #[ asm_cfg( armv8m) ]
190191// The __tta function does not dereference the pointer received.
191192#[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
192193pub fn tta ( addr : * mut u32 ) -> u32 {
@@ -209,7 +210,7 @@ pub fn tta(addr: *mut u32) -> u32 {
209210/// Returns a Test Target Response Payload (cf section D1.2.215 of
210211/// Armv8-M Architecture Reference Manual).
211212#[ inline]
212- #[ cortex_m_macros :: asm_cfg( armv8m) ]
213+ #[ asm_cfg( armv8m) ]
213214// The __ttat function does not dereference the pointer received.
214215#[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
215216pub fn ttat ( addr : * mut u32 ) -> u32 {
@@ -229,7 +230,7 @@ pub fn ttat(addr: *mut u32) -> u32 {
229230/// See section C2.4.26 of Armv8-M Architecture Reference Manual for details.
230231/// Undefined if executed in Non-Secure state.
231232#[ inline]
232- #[ cortex_m_macros :: asm_cfg( armv8m) ]
233+ #[ asm_cfg( armv8m) ]
233234pub unsafe fn bx_ns ( addr : u32 ) {
234235 unsafe { asm ! ( "BXNS {}" , in( reg) addr, options( nomem, nostack, preserves_flags) ) } ;
235236}
@@ -238,7 +239,7 @@ pub unsafe fn bx_ns(addr: u32) {
238239///
239240/// This method is used by cortex-m-semihosting to provide semihosting syscalls.
240241#[ inline]
241- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
242+ #[ asm_cfg( cortex_m) ]
242243pub unsafe fn semihosting_syscall ( mut nr : u32 , arg : u32 ) -> u32 {
243244 unsafe {
244245 asm ! ( "bkpt #0xab" , inout( "r0" ) nr, in( "r1" ) arg, options( nomem, nostack, preserves_flags) )
@@ -263,7 +264,7 @@ pub unsafe fn semihosting_syscall(mut nr: u32, arg: u32) -> u32 {
263264/// program - stack overflows are obviously UB. If your processor supports
264265/// it, you may wish to set the `PSPLIM` register to guard against this.
265266#[ inline( always) ]
266- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
267+ #[ asm_cfg( cortex_m) ]
267268pub unsafe fn enter_unprivileged_psp ( psp : * const u32 , entry : extern "C" fn ( ) -> !) -> ! {
268269 use crate :: register:: control:: { Control , Npriv , Spsel } ;
269270 const CONTROL_FLAGS : u32 = {
@@ -305,7 +306,7 @@ pub unsafe fn enter_unprivileged_psp(psp: *const u32, entry: extern "C" fn() ->
305306/// program - stack overflows are obviously UB. If your processor supports
306307/// it, you may wish to set the `PSPLIM` register to guard against this.
307308#[ inline( always) ]
308- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
309+ #[ asm_cfg( cortex_m) ]
309310pub unsafe fn enter_privileged_psp ( psp : * const u32 , entry : extern "C" fn ( ) -> !) -> ! {
310311 use crate :: register:: control:: { Control , Npriv , Spsel } ;
311312 const CONTROL_FLAGS : u32 = {
@@ -342,7 +343,7 @@ pub unsafe fn enter_privileged_psp(psp: *const u32, entry: extern "C" fn() -> !)
342343/// `msp` and `rv` must point to valid stack memory and executable code,
343344/// respectively.
344345#[ inline]
345- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
346+ #[ asm_cfg( cortex_m) ]
346347pub unsafe fn bootstrap ( msp : * const u32 , rv : * const u32 ) -> ! {
347348 // Ensure thumb mode is set.
348349 let rv = ( rv as u32 ) | 1 ;
@@ -379,7 +380,7 @@ pub unsafe fn bootstrap(msp: *const u32, rv: *const u32) -> ! {
379380/// table, with a valid stack pointer as the first word and
380381/// a valid reset vector as the second word.
381382#[ inline]
382- #[ cortex_m_macros :: asm_cfg( cortex_m) ]
383+ #[ asm_cfg( cortex_m) ]
383384pub unsafe fn bootload ( vector_table : * const u32 ) -> ! {
384385 unsafe {
385386 let msp = core:: ptr:: read_volatile ( vector_table) ;
0 commit comments