Skip to content

Commit 66c83bb

Browse files
bors[bot]adamgreig
andauthored
Merge #201
201: Add UDF instruction. Closes #199. r=jonas-schievink a=adamgreig Co-authored-by: Adam Greig <[email protected]>
2 parents 8c5030e + 715e595 commit 66c83bb

9 files changed

+36
-0
lines changed

asm.s

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

117+
118+
.section .text.__udf
119+
.global __udf
120+
.thumb_func
121+
__udf:
122+
udf
123+
117124
.section .text.__wfe
118125
.global __wfe
119126
.thumb_func

bin/thumbv6m-none-eabi.a

114 Bytes
Binary file not shown.

bin/thumbv7em-none-eabi.a

114 Bytes
Binary file not shown.

bin/thumbv7em-none-eabihf.a

114 Bytes
Binary file not shown.

bin/thumbv7m-none-eabi.a

114 Bytes
Binary file not shown.

bin/thumbv8m.base-none-eabi.a

114 Bytes
Binary file not shown.

bin/thumbv8m.main-none-eabi.a

114 Bytes
Binary file not shown.

bin/thumbv8m.main-none-eabihf.a

114 Bytes
Binary file not shown.

src/asm.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,35 @@ 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 {
93+
asm!("udf" :::: "volatile");
94+
core::hint::unreachable_unchecked();
95+
},
96+
97+
#[cfg(all(cortex_m, not(feature = "inline-asm")))]
98+
() => unsafe {
99+
extern "C" {
100+
fn __udf();
101+
}
102+
103+
__udf();
104+
105+
core::hint::unreachable_unchecked();
106+
},
107+
108+
#[cfg(not(cortex_m))]
109+
() => unimplemented!(),
110+
}
111+
}
112+
84113
/// Wait For Event
85114
#[inline]
86115
pub fn wfe() {

0 commit comments

Comments
 (0)