Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ edition = "2018"
[features]
inline-asm = []
jlink-quirks = []
no-semihosting = []

[dependencies]
cortex-m = ">= 0.5.8, < 0.7"
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@
//! latest version 6.48b of J-Link exhibits such behaviour, causing a panic if this feature
//! is not enabled.
//!
//! ## `no-semihosting`
//!
//! When this feature is enabled, the underlying system calls to `bkpt` are patched out.
//!
//! # Reference
//!
//! For documentation about the semihosting operations, check:
Expand Down Expand Up @@ -207,16 +211,21 @@ pub unsafe fn syscall<T>(nr: usize, arg: &T) -> usize {
#[inline(always)]
pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize {
match () {
#[cfg(all(thumb, not(feature = "inline-asm")))]
#[cfg(all(thumb, not(feature = "inline-asm"), not(feature = "no-semihosting")))]
() => __syscall(_nr, _arg),

#[cfg(all(thumb, feature = "inline-asm"))]
#[cfg(all(thumb, feature = "inline-asm", not(feature = "no-semihosting")))]
() => {
let mut nr = _nr;
llvm_asm!("bkpt 0xAB" : "+{r0}"(nr) : "{r1}"(_arg) :: "volatile");
nr
}

#[cfg(all(thumb, feature = "no-semihosting"))]
() => {
0
}

#[cfg(not(thumb))]
() => unimplemented!(),
}
Expand Down