Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 94b5e12

Browse files
bors[bot]japaric
andcommitted
Merge #17
17: make the "inline-asm" feature opt-in r=japaric a=japaric Co-authored-by: Jorge Aparicio <[email protected]>
2 parents 1ad22c0 + eea0b09 commit 94b5e12

File tree

5 files changed

+48
-16
lines changed

5 files changed

+48
-16
lines changed

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,31 @@ language: rust
33
matrix:
44
include:
55
- env: TARGET=x86_64-unknown-linux-gnu
6+
7+
- env: TARGET=thumbv6m-none-eabi
8+
rust: beta
9+
addons:
10+
apt:
11+
packages:
12+
- gcc-arm-none-eabi
13+
14+
- env: TARGET=thumbv7m-none-eabi
15+
rust: beta
16+
addons:
17+
apt:
18+
packages:
19+
- gcc-arm-none-eabi
20+
621
- env: TARGET=x86_64-unknown-linux-gnu
722
rust: nightly
23+
824
- env: TARGET=thumbv6m-none-eabi
925
rust: nightly
1026
addons:
1127
apt:
1228
packages:
1329
- gcc-arm-none-eabi
30+
1431
- env: TARGET=thumbv7m-none-eabi
1532
rust: nightly
1633
addons:

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8+
## [v0.3.0] - 2018-05-10
9+
10+
### Changed
11+
12+
- [breaking-change] `inline-asm` is no longer a default feature (i.e. a feature that's enabled by
13+
default). The consequence is that this crate now compiles on 1.27 (beta) by default, and opting
14+
into `inline-asm` requires nightly.
15+
816
## [v0.2.1] - 2018-04-25
917

1018
### Added
@@ -64,7 +72,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6472

6573
- Initial release
6674

67-
[Unreleased]: https://github.com/japaric/cortex-m-semihosting/compare/v0.2.0...HEAD
75+
[Unreleased]: https://github.com/japaric/cortex-m-semihosting/compare/v0.3.0...HEAD
76+
[v0.3.0]: https://github.com/japaric/cortex-m-semihosting/compare/v0.2.1...v0.3.0
77+
[v0.2.1]: https://github.com/japaric/cortex-m-semihosting/compare/v0.2.0...v0.2.1
6878
[v0.2.0]: https://github.com/japaric/cortex-m-semihosting/compare/v0.1.3...v0.2.0
6979
[v0.1.3]: https://github.com/japaric/cortex-m-semihosting/compare/v0.1.2...v0.1.3
7080
[v0.1.2]: https://github.com/japaric/cortex-m-semihosting/compare/v0.1.1...v0.1.2

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ keywords = ["semihosting", "arm", "cortex-m"]
66
license = "MIT OR Apache-2.0"
77
name = "cortex-m-semihosting"
88
repository = "https://github.com/japaric/cortex-m-semihosting"
9-
version = "0.2.1"
9+
version = "0.3.0"
1010

1111
[build-dependencies]
1212
cc = "1.0.10"
1313

1414
[features]
15-
inline-asm = []
16-
default = ["inline-asm"]
15+
inline-asm = []

ci/script.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
set -euxo pipefail
22

33
main() {
4-
cargo check --target $TARGET --no-default-features
4+
cargo check --target $TARGET
55

6-
if [ $TARGET != x86_64-unknown-linux-gnu ]; then
7-
cargo check --target $TARGET
6+
if [ $TRAVIS_RUST_VERSION = nightly ]; then
7+
cargo check --target $TARGET --features inline-asm
88
fi
99
}
1010

src/lib.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
//! Semihosting operations are *very* slow. Like, each WRITE operation can take hundreds of
1919
//! milliseconds.
2020
//!
21+
//! # Requirements
22+
//!
23+
//! Compiling this crate on stable or beta requires `arm-none-eabi-gcc` to be installed and
24+
//! available in `PATH`.
25+
//!
2126
//! # Example
2227
//!
2328
//! This example will show how to print "Hello, world!" on the host.
@@ -28,7 +33,8 @@
2833
//! #[macro_use]
2934
//! extern crate cortex_m_semihosting;
3035
//!
31-
//! fn main() {
36+
//! // This function will be called by the application
37+
//! fn print() {
3238
//! // File descriptor (on the host)
3339
//! const STDOUT: usize = 1; // NOTE the host stdout may not always be fd 1
3440
//! static MSG: &'static [u8] = b"Hello, world!\n";
@@ -69,16 +75,16 @@
6975
//!
7076
//! ``` text
7177
//! $ arm-none-eabi-gdb hello-world
72-
//! # Connect to OpenOCD
78+
//! (gdb) # Connect to OpenOCD
7379
//! (gdb) target remote :3333
7480
//!
75-
//! # Enable OpenOCD's semihosting support
81+
//! (gdb) # Enable OpenOCD's semihosting support
7682
//! (gdb) monitor arm semihosting enable
7783
//!
78-
//! # Flash the program
84+
//! (gdb) # Flash the program
7985
//! (gdb) load
8086
//!
81-
//! # Run the program
87+
//! (gdb) # Run the program
8288
//! (gdb) continue
8389
//! ```
8490
//!
@@ -90,17 +96,15 @@
9096
//! Hello, world!
9197
//! ```
9298
//!
93-
//! # Cargo features
99+
//! # Optional features
94100
//!
95101
//! ## `inline-asm`
96102
//!
97-
//! This feature is *enabled* by default.
98-
//!
99103
//! When this feature is enabled semihosting is implemented using inline assembly (`asm!`) and
100104
//! compiling this crate requires nightly.
101105
//!
102106
//! When this feature is disabled semihosting is implemented using FFI calls into an external
103-
//! assembly file and compiling this crate works on stable.
107+
//! assembly file and compiling this crate works on stable and beta.
104108
//!
105109
//! Apart from the toolchain requirement, disabling `inline-asm` requires `arm-none-eabi-gcc` to be
106110
//! installed on the host. Also, disabling `inline-asm` imposes an overhead of an extra function
@@ -144,12 +148,14 @@ pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize {
144148
match () {
145149
#[cfg(all(thumb, not(feature = "inline-asm")))]
146150
() => __syscall(_nr, _arg),
151+
147152
#[cfg(all(thumb, feature = "inline-asm"))]
148153
() => {
149154
let mut nr = _nr;
150155
asm!("bkpt 0xAB" : "+{r0}"(nr) : "{r1}"(_arg) :: "volatile");
151156
nr
152157
}
158+
153159
#[cfg(not(thumb))]
154160
() => unimplemented!(),
155161
}

0 commit comments

Comments
 (0)