aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-semihosting
diff options
context:
space:
mode:
Diffstat (limited to 'cortex-m-semihosting')
-rw-r--r--cortex-m-semihosting/CHANGELOG.md8
-rw-r--r--cortex-m-semihosting/Cargo.toml7
-rw-r--r--cortex-m-semihosting/README.md2
l---------cortex-m-semihosting/bin1
-rw-r--r--cortex-m-semihosting/build.rs16
-rw-r--r--cortex-m-semihosting/src/export.rs10
-rw-r--r--cortex-m-semihosting/src/lib.rs33
7 files changed, 23 insertions, 54 deletions
diff --git a/cortex-m-semihosting/CHANGELOG.md b/cortex-m-semihosting/CHANGELOG.md
index 0a942cf..76f0694 100644
--- a/cortex-m-semihosting/CHANGELOG.md
+++ b/cortex-m-semihosting/CHANGELOG.md
@@ -5,6 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
+## [v0.5.0] - 2022-03-01
+
+- Always use inline-asm, requiring Rust 1.59.
+- Removed inline-asm feature.
+
## [v0.4.1] - 2020-10-20
0.4.1 was yanked because the pre-built binaries contain conflicting symbols
@@ -141,7 +146,8 @@ change.
- Initial release
-[Unreleased]: https://github.com/rust-embedded/cortex-m/compare/c-m-sh-v0.4.1...HEAD
+[Unreleased]: https://github.com/rust-embedded/cortex-m/compare/c-m-sh-v0.5.0...HEAD
+[v0.5.0]: https://github.com/rust-embedded/cortex-m/compare/c-m-sh-v0.4.1...c-m-sh-v0.5.0
[v0.4.1]: https://github.com/rust-embedded/cortex-m/compare/c-m-sh-v0.4.0...c-m-sh-v0.4.1
[v0.4.0]: https://github.com/rust-embedded/cortex-m/compare/c-m-sh-v0.3.5...c-m-sh-v0.4.0
[v0.3.7]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.6...v0.3.7
diff --git a/cortex-m-semihosting/Cargo.toml b/cortex-m-semihosting/Cargo.toml
index 5894029..ac0afa5 100644
--- a/cortex-m-semihosting/Cargo.toml
+++ b/cortex-m-semihosting/Cargo.toml
@@ -11,13 +11,14 @@ license = "MIT OR Apache-2.0"
name = "cortex-m-semihosting"
readme = "README.md"
repository = "https://github.com/rust-embedded/cortex-m"
-version = "0.4.1"
-edition = "2018"
+version = "0.5.0"
+edition = "2021"
+rust-version = "1.59"
[features]
-inline-asm = []
jlink-quirks = []
no-semihosting = []
[dependencies]
cortex-m = { path = "..", version = ">= 0.5.8, < 0.8" }
+critical-section = "1.0.0"
diff --git a/cortex-m-semihosting/README.md b/cortex-m-semihosting/README.md
index bfbfb44..6036d4e 100644
--- a/cortex-m-semihosting/README.md
+++ b/cortex-m-semihosting/README.md
@@ -11,7 +11,7 @@ This project is developed and maintained by the [Cortex-M team][team].
# Minimum Supported Rust Version (MSRV)
-This crate is guaranteed to compile on stable Rust 1.33.0 and up. It *might*
+This crate is guaranteed to compile on stable Rust 1.59.0 and up. It *might*
compile with older versions but that may change in any new patch release.
## License
diff --git a/cortex-m-semihosting/bin b/cortex-m-semihosting/bin
deleted file mode 120000
index 19f285a..0000000
--- a/cortex-m-semihosting/bin
+++ /dev/null
@@ -1 +0,0 @@
-../bin \ No newline at end of file
diff --git a/cortex-m-semihosting/build.rs b/cortex-m-semihosting/build.rs
index 315035e..ed0d069 100644
--- a/cortex-m-semihosting/build.rs
+++ b/cortex-m-semihosting/build.rs
@@ -1,23 +1,9 @@
-use std::path::PathBuf;
-use std::{env, fs};
+use std::env;
fn main() {
let target = env::var("TARGET").unwrap();
- let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
- let name = env::var("CARGO_PKG_NAME").unwrap();
if target.starts_with("thumbv") {
- if env::var_os("CARGO_FEATURE_INLINE_ASM").is_none() {
- fs::copy(
- format!("bin/{}.a", target),
- out_dir.join(format!("lib{}.a", name)),
- )
- .unwrap();
-
- println!("cargo:rustc-link-lib=static={}", name);
- println!("cargo:rustc-link-search={}", out_dir.display());
- }
-
println!("cargo:rustc-cfg=thumb");
}
}
diff --git a/cortex-m-semihosting/src/export.rs b/cortex-m-semihosting/src/export.rs
index 0bbd09f..46e70e7 100644
--- a/cortex-m-semihosting/src/export.rs
+++ b/cortex-m-semihosting/src/export.rs
@@ -2,14 +2,12 @@
use core::fmt::{self, Write};
-use cortex_m::interrupt;
-
use crate::hio::{self, HostStream};
static mut HSTDOUT: Option<HostStream> = None;
pub fn hstdout_str(s: &str) {
- let _result = interrupt::free(|_| unsafe {
+ let _result = critical_section::with(|_| unsafe {
if HSTDOUT.is_none() {
HSTDOUT = Some(hio::hstdout()?);
}
@@ -19,7 +17,7 @@ pub fn hstdout_str(s: &str) {
}
pub fn hstdout_fmt(args: fmt::Arguments) {
- let _result = interrupt::free(|_| unsafe {
+ let _result = critical_section::with(|_| unsafe {
if HSTDOUT.is_none() {
HSTDOUT = Some(hio::hstdout()?);
}
@@ -31,7 +29,7 @@ pub fn hstdout_fmt(args: fmt::Arguments) {
static mut HSTDERR: Option<HostStream> = None;
pub fn hstderr_str(s: &str) {
- let _result = interrupt::free(|_| unsafe {
+ let _result = critical_section::with(|_| unsafe {
if HSTDERR.is_none() {
HSTDERR = Some(hio::hstderr()?);
}
@@ -41,7 +39,7 @@ pub fn hstderr_str(s: &str) {
}
pub fn hstderr_fmt(args: fmt::Arguments) {
- let _result = interrupt::free(|_| unsafe {
+ let _result = critical_section::with(|_| unsafe {
if HSTDERR.is_none() {
HSTDERR = Some(hio::hstderr()?);
}
diff --git a/cortex-m-semihosting/src/lib.rs b/cortex-m-semihosting/src/lib.rs
index 3bc23ea..8306307 100644
--- a/cortex-m-semihosting/src/lib.rs
+++ b/cortex-m-semihosting/src/lib.rs
@@ -151,14 +151,6 @@
//!
//! # Optional features
//!
-//! ## `inline-asm`
-//!
-//! When this feature is enabled semihosting is implemented using inline assembly and
-//! compiling this crate requires nightly.
-//!
-//! When this feature is disabled semihosting is implemented using FFI calls into an external
-//! assembly file and compiling this crate works on stable and beta.
-//!
//! ## `jlink-quirks`
//!
//! When this feature is enabled, return values above `0xfffffff0` from semihosting operation
@@ -191,11 +183,6 @@ pub mod export;
pub mod hio;
pub mod nr;
-#[cfg(all(thumb, not(feature = "inline-asm")))]
-extern "C" {
- fn __sh_syscall(nr: usize, arg: usize) -> usize;
-}
-
/// Performs a semihosting operation, takes a pointer to an argument block
#[inline(always)]
pub unsafe fn syscall<T>(nr: usize, arg: &T) -> usize {
@@ -206,24 +193,16 @@ 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"), not(feature = "no-semihosting")))]
- () => __sh_syscall(_nr, _arg),
-
- #[cfg(all(thumb, feature = "inline-asm", not(feature = "no-semihosting")))]
+ #[cfg(all(thumb, not(feature = "no-semihosting")))]
() => {
- let mut nr = _nr;
- core::arch::asm!(
- "bkpt #0xab",
- inout("r0") nr,
- in("r1") _arg,
- options(nomem, nostack, preserves_flags)
- );
- nr
+ use core::arch::asm;
+ let mut nr = _nr as u32;
+ let arg = _arg as u32;
+ asm!("bkpt #0xab", inout("r0") nr, in("r1") arg, options(nostack, preserves_flags));
+ nr as usize
}
-
#[cfg(all(thumb, feature = "no-semihosting"))]
() => 0,
-
#[cfg(not(thumb))]
() => unimplemented!(),
}