diff options
author | 2020-03-15 23:32:44 +0000 | |
---|---|---|
committer | 2020-03-15 23:32:44 +0000 | |
commit | 66c83bb0342833394aa7a1a63a0987aa7cb72938 (patch) | |
tree | 97f3d745015a6841abc305e2296a5e4096d29a8c /src | |
parent | 8c5030ebcaf26af6f3882221670a4aaa2eb48fab (diff) | |
parent | 715e59506e3a4482500f252270b42f12e2498849 (diff) | |
download | cortex-m-66c83bb0342833394aa7a1a63a0987aa7cb72938.tar.gz cortex-m-66c83bb0342833394aa7a1a63a0987aa7cb72938.tar.zst cortex-m-66c83bb0342833394aa7a1a63a0987aa7cb72938.zip |
Merge #201
201: Add UDF instruction. Closes #199. r=jonas-schievink a=adamgreig
Co-authored-by: Adam Greig <adam@adamgreig.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/asm.rs | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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() { |