Skip to content

Commit ec3483b

Browse files
adamgreigjonas-schievink
authored andcommitted
Add UDF instruction. Closes #199.
1 parent 1830823 commit ec3483b

9 files changed

+32
-0
lines changed

asm.s

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ __sev:
114114
sev
115115
bx lr
116116

117+
118+
.section .text.__udf
119+
.global __udf
120+
.thumb_func
121+
__udf:
122+
udf
123+
bx lr
124+
117125
.section .text.__wfe
118126
.global __wfe
119127
.thumb_func

bin/thumbv6m-none-eabi.a

118 Bytes
Binary file not shown.

bin/thumbv7em-none-eabi.a

118 Bytes
Binary file not shown.

bin/thumbv7em-none-eabihf.a

118 Bytes
Binary file not shown.

bin/thumbv7m-none-eabi.a

118 Bytes
Binary file not shown.

bin/thumbv8m.base-none-eabi.a

118 Bytes
Binary file not shown.

bin/thumbv8m.main-none-eabi.a

118 Bytes
Binary file not shown.

bin/thumbv8m.main-none-eabihf.a

118 Bytes
Binary file not shown.

src/asm.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,30 @@ pub fn nop() {
8181
}
8282
}
8383

84+
85+
/// Generate an Undefined Instruction exception.
86+
///
87+
/// Can be used as a stable alternative to `core::intrinsics::abort`.
88+
#[inline]
89+
pub fn udf() {
90+
match () {
91+
#[cfg(all(cortex_m, feature = "inline-asm"))]
92+
() => unsafe { asm!("udf" :::: "volatile") },
93+
94+
#[cfg(all(cortex_m, not(feature = "inline-asm")))]
95+
() => unsafe {
96+
extern "C" {
97+
fn __udf();
98+
}
99+
100+
__udf()
101+
},
102+
103+
#[cfg(not(cortex_m))]
104+
() => unimplemented!(),
105+
}
106+
}
107+
84108
/// Wait For Event
85109
#[inline]
86110
pub fn wfe() {

0 commit comments

Comments
 (0)