Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions asm.s
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ __sev:
sev
bx lr


.section .text.__udf
.global __udf
.thumb_func
__udf:
udf

.section .text.__wfe
.global __wfe
.thumb_func
Expand Down
Binary file modified bin/thumbv6m-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv7em-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv7em-none-eabihf.a
Binary file not shown.
Binary file modified bin/thumbv7m-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv8m.base-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv8m.main-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv8m.main-none-eabihf.a
Binary file not shown.
29 changes: 29 additions & 0 deletions src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,35 @@ pub fn nop() {
}
}


/// Generate an Undefined Instruction exception.
///
/// Can be used as a stable alternative to `core::intrinsics::abort`.
#[inline]
pub fn udf() -> ! {
match () {
#[cfg(all(cortex_m, feature = "inline-asm"))]
() => unsafe {
asm!("udf" :::: "volatile");
core::hint::unreachable_unchecked();
},

#[cfg(all(cortex_m, not(feature = "inline-asm")))]
() => unsafe {
extern "C" {
fn __udf();
}

__udf();

core::hint::unreachable_unchecked();
},

#[cfg(not(cortex_m))]
() => unimplemented!(),
}
}

/// Wait For Event
#[inline]
pub fn wfe() {
Expand Down