Skip to content

Commit 64ef9e4

Browse files
authored
Merge pull request #3 from FawazTirmizi/rivos/main
Documentation and repository clean-up
2 parents e07d797 + 6002ee5 commit 64ef9e4

File tree

5 files changed

+74
-187
lines changed

5 files changed

+74
-187
lines changed

CHANGELOG.md

Lines changed: 19 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -5,155 +5,25 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8-
## [v0.4.1] - 2020-10-20
9-
10-
0.4.1 was yanked because the pre-built binaries contain conflicting symbols
11-
with a supported version of cortex-m.
12-
13-
- Fix missing prebuilt binaries (#271)
14-
15-
## [v0.4.0] - 2020-10-14
16-
17-
v0.4.0 was yanked because it did not include the required pre-built binaries
18-
in the final crate.
19-
20-
- Moved into cortex-m repository
21-
- Merge `HStdout` and `HStderr` into one type: `HostStream`
22-
- Support cortex-m v0.7
23-
- Semihosting macros no longer return a Result, instead errors are ignored.
24-
25-
## [v0.3.7] - 2020-12-02
26-
27-
- Replaces the yanked v0.3.6 by reverting #48, so the semihosting macros
28-
continue to return a Result.
29-
30-
## [v0.3.6] - 2020-12-01
31-
32-
v0.3.6 was yanked because it incorrectly included #48, which was a breaking
33-
change.
34-
35-
### Added
36-
37-
- Update cortex-m dependency to support version 0.7.
38-
- Add `no-semihosting` feature to disable all semihosting calls.
39-
40-
## [v0.3.5] - 2019-08-29
41-
42-
### Added
43-
44-
- Adds a feature to work around JLink quirks
45-
- Adds a dbg! macro using heprintln
46-
- Added thumbv8m.main support on stable
47-
48-
### Fixed
49-
50-
- Now Rust 2018 edition
51-
52-
## [v0.3.4] - 2019-08-13
53-
54-
### Fixed
55-
56-
- Support for thumbv8 mainline hf target
57-
58-
## [v0.3.3] - 2019-04-22
59-
60-
### Added
61-
62-
- Adds support for thumbv8 and cortex-m v0.6.0
63-
64-
## [v0.3.2] - 2018-11-04
65-
66-
### Added
67-
68-
- Added a family of `hprint` macros for printing to the host standard output /
69-
error via globally shared `HStdout` / `HStderr` handles .
70-
71-
## [v0.3.1] - 2018-08-27
72-
73-
### Changed
74-
75-
- This crate no longer depends on `arm-none-eabi-gcc`.
76-
77-
## [v0.3.0] - 2018-05-10
78-
79-
### Changed
80-
81-
- [breaking-change] `inline-asm` is no longer a default feature (i.e. a feature that's enabled by
82-
default). The consequence is that this crate now compiles on 1.27 (beta) by default, and opting
83-
into `inline-asm` requires nightly.
84-
85-
## [v0.2.1] - 2018-04-25
86-
87-
### Added
88-
89-
- An opt-out "inline-asm" Cargo feature. When this feature is disabled semihosting is implemented
90-
using an external assembly file instead of using the unstable inline assembly (`asm!`) feature
91-
meaning that this crate can be compiled on stable.
92-
93-
## [v0.2.0] - 2017-07-07
94-
95-
### Added
96-
97-
- `exit` and `report_exception` syscalls
98-
99-
- `HStdout` and `HStderr` structs that represent handles to the host stdout and
100-
stderr stream respectively.
101-
102-
### Changed
103-
104-
- [breaking-change] The `io` module has been renamed to `hio` to reflect that
105-
this is I/O *on the host*.
106-
107-
### Removed
108-
109-
- [breaking-change] the family of `write` functions in the `io` module. Instead
110-
use `HStdout` / `HStderr` and its `write_all` method and `fmt::Write`
111-
implementation.
112-
113-
- [breaking-change] the `hprint!` family of macros. Instead use `HStdout` and
114-
the standard `write!` macro.
115-
116-
## [v0.1.3] - 2017-02-27
117-
118-
### Added
119-
120-
- A family of `ewrite` functions and `ehprint!` macros to write to the host's
121-
stderr.
122-
123-
### Fixed
124-
125-
- `write_all` logic when a single write doesn't write all the buffer bytes
126-
127-
## [v0.1.2] - 2017-02-15
128-
129-
### Fixed
130-
131-
- the `hprintln!` macro when called without arguments.
132-
133-
## [v0.1.1] - 2017-01-22
134-
135-
### Added
136-
137-
- Expose a family of `write` functions to write to the host's stdout without
138-
going through the `hprint!` macros.
139-
140-
## v0.1.0 - 2017-01-22
8+
- Bring in API changes from
9+
[cortex-m-semihosting](https://github.com/rust-embedded/cortex-m/tree/master/cortex-m-semihosting),
10+
including:
11+
- Addition of the `hprint`, `hprintln`, `heprint`, `heprintln`, and `dbg`
12+
macros.
13+
- `hprint` and `heprintln` print to host stdout without and with a
14+
newline, respectively.
15+
- `heprint` and `heprintln` do the same, except to host stderr.
16+
- `dbg` works exactly like
17+
[`std::dbg`](https://doc.rust-lang.org/std/macro.dbg.html).
18+
- `HStdout` and `HStderr` have been combined into `HostStream`.
19+
- `inline-asm` feature removed, switched to stabilized inline asm and MSRV
20+
bumped to 1.59.0
21+
- Clean up documentation, removing unnecessary references to
22+
cortex-m-semihosting and improving clarity.
23+
24+
## [v0.0.1] - 2018-02-27
14125

14226
- Initial release
14327

144-
[Unreleased]: https://github.com/rust-embedded/cortex-m/compare/c-m-sh-v0.4.1...HEAD
145-
[v0.4.1]: https://github.com/rust-embedded/cortex-m/compare/c-m-sh-v0.4.0...c-m-sh-v0.4.1
146-
[v0.4.0]: https://github.com/rust-embedded/cortex-m/compare/c-m-sh-v0.3.5...c-m-sh-v0.4.0
147-
[v0.3.7]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.6...v0.3.7
148-
[v0.3.6]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.5...v0.3.6
149-
[v0.3.5]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.4...v0.3.5
150-
[v0.3.4]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.3...v0.3.4
151-
[v0.3.3]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.2...v0.3.3
152-
[v0.3.2]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.1...v0.3.2
153-
[v0.3.1]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.0...v0.3.1
154-
[v0.3.0]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.2.1...v0.3.0
155-
[v0.2.1]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.2.0...v0.2.1
156-
[v0.2.0]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.1.3...v0.2.0
157-
[v0.1.3]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.1.2...v0.1.3
158-
[v0.1.2]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.1.1...v0.1.2
159-
[v0.1.1]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.1.0...v0.1.1
28+
[Unreleased]: https://github.com/riscv-rust/riscv-semihosting/compare/cb1afe4002d576b87bfd4c199f42a43815984ce4..HEAD
29+
[v0.0.1]: https://github.com/riscv-rust/riscv-semihosting/tree/cb1afe4002d576b87bfd4c199f42a43815984ce4

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
authors = [
33
"The Cortex-M Team <[email protected]>",
44
"Jorge Aparicio <[email protected]>",
5+
"The RISC-V Team <[email protected]>",
56
]
67
description = "Semihosting for RISCV processors"
78
documentation = "https://docs.rs/riscv-semihosting"
@@ -12,7 +13,8 @@ name = "riscv-semihosting"
1213
readme = "README.md"
1314
repository = "https://github.com/riscv-rust/riscv-semihosting"
1415
version = "0.0.1"
15-
edition = "2018"
16+
edition = "2021"
17+
rust-version = "1.59.0"
1618

1719
[features]
1820
default = ["jlink-quirks"]

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
[![crates.io](https://img.shields.io/crates/v/cortex-m-semihosting.svg)](https://crates.io/crates/cortex-m-semihosting)
2-
[![crates.io](https://img.shields.io/crates/d/cortex-m-semihosting.svg)](https://crates.io/crates/cortex-m-semihosting)
1+
# `riscv-semihosting`
32

4-
# `cortex-m-semihosting`
3+
> Semihosting for RISC-V processors
54
6-
> Semihosting for ARM Cortex-M processors
5+
This is a fork of the
6+
[cortex-m-semihosting](https://docs.rs/cortex-m-semihosting) crate with changes
7+
to support the RISC-V Semihosting Specification as documented
8+
[here](https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc)
79

8-
This project is developed and maintained by the [Cortex-M team][team].
9-
10-
## [Documentation](https://docs.rs/cortex-m-semihosting)
10+
This crate can be used in exactly the same way as cortex-m-semihosting, simply
11+
by changing calls to `cortex_m_semihosting::*` to `riscv_semihosting::*`. Given
12+
this, the
13+
[cortex-m-semihosting documentation](https://docs.rs/cortex-m-semihosting) is
14+
generally sufficient for using this library.
1115

1216
# Minimum Supported Rust Version (MSRV)
1317

@@ -20,7 +24,8 @@ Licensed under either of
2024

2125
- Apache License, Version 2.0 ([LICENSE-APACHE](../LICENSE-APACHE) or
2226
http://www.apache.org/licenses/LICENSE-2.0)
23-
- MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT)
27+
- MIT license ([LICENSE-MIT](../LICENSE-MIT) or
28+
http://opensource.org/licenses/MIT)
2429

2530
at your option.
2631

@@ -33,8 +38,8 @@ dual licensed as above, without any additional terms or conditions.
3338
## Code of Conduct
3439

3540
Contribution to this crate is organized under the terms of the [Rust Code of
36-
Conduct][CoC], the maintainer of this crate, the [Cortex-M team][team], promises
41+
Conduct][CoC], the maintainer of this crate, the [RISC-V team][team], promises
3742
to intervene to uphold that code of conduct.
3843

3944
[CoC]: ../CODE_OF_CONDUCT.md
40-
[team]: https://github.com/rust-embedded/wg#the-cortex-m-team
45+
[team]: https://github.com/rust-embedded/wg#the-risc-v-team

src/lib.rs

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,32 @@
22
//!
33
//! # What is semihosting?
44
//!
5-
//! "Semihosting is a mechanism that enables code running on an ARM target to communicate and use
6-
//! the Input/Output facilities on a host computer that is running a debugger." - ARM
5+
//! "Semihosting is a technique where an application running in a debug or
6+
//! simulation environment can access elements of the system hosting the
7+
//! debugger or simulator including console, file system, time and other
8+
//! functions. This allows for diagnostics, interaction and measurement of a
9+
//! target system without requiring significant infrastructure to exist in that
10+
//! target environment." - RISC-V Semihosting Spec
711
//!
812
//! # Interface
913
//!
1014
//! This crate provides implementations of
11-
//! [`core::fmt::Write`](https://doc.rust-lang.org/core/fmt/trait.Write.html), so you can use it,
12-
//! in conjunction with
13-
//! [`core::format_args!`](https://doc.rust-lang.org/core/macro.format_args.html) or the [`write!` macro](https://doc.rust-lang.org/core/macro.write.html), for user-friendly construction and printing of formatted strings.
15+
//! [`core::fmt::Write`](https://doc.rust-lang.org/core/fmt/trait.Write.html),
16+
//! so you can use it, in conjunction with
17+
//! [`core::format_args!`](https://doc.rust-lang.org/core/macro.format_args.html)
18+
//! or the [`write!` macro](https://doc.rust-lang.org/core/macro.write.html),
19+
//! for user-friendly construction and printing of formatted strings.
1420
//!
15-
//! Since semihosting operations are modeled as [system calls][sc], this crate exposes an untyped
16-
//! `syscall!` interface just like the [`sc`] crate does.
21+
//! Since semihosting operations are modeled as [system calls][sc], this crate
22+
//! exposes an untyped `syscall!` interface just like the [`sc`] crate does.
1723
//!
1824
//! [sc]: https://en.wikipedia.org/wiki/System_call
1925
//! [`sc`]: https://crates.io/crates/sc
2026
//!
2127
//! # Forewarning
2228
//!
23-
//! Semihosting operations are *very* slow. Like, each WRITE operation can take hundreds of
24-
//! milliseconds.
29+
//! Semihosting operations are *very* slow. Like, each WRITE operation can take
30+
//! hundreds of milliseconds.
2531
//!
2632
//! # Example
2733
//!
@@ -56,8 +62,8 @@
5662
//! # the command will block at this point
5763
//! ```
5864
//!
59-
//! The OpenOCD logs will be redirected to `/tmp/openocd.log`. You can view those logs in "real
60-
//! time" using `tail`
65+
//! The OpenOCD logs will be redirected to `/tmp/openocd.log`. You can view
66+
//! those logs in "real time" using `tail`
6167
//!
6268
//! ``` text
6369
//! $ tail -f /tmp/openocd.log
@@ -69,8 +75,9 @@
6975
//! Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
7076
//! ```
7177
//!
72-
//! Alternatively you could omit the `-l` flag from the `openocd` call, and the `tail -f` command
73-
//! but the OpenOCD output will have intermingled in it logs from its normal operation.
78+
//! Alternatively you could omit the `-l` flag from the `openocd` call, and the
79+
//! `tail -f` command but the OpenOCD output will have intermingled in it logs
80+
//! from its normal operation.
7481
//!
7582
//! Then, we run the program:
7683
//!
@@ -119,9 +126,9 @@
119126
//!
120127
//! ## The `dbg!` macro
121128
//!
122-
//! Analogous to [`std::dbg`](https://doc.rust-lang.org/std/macro.dbg.html) the macro
123-
//! `dbg!` returns a given expression and prints it using `heprintln!` including context
124-
//! for quick and dirty debugging.
129+
//! Analogous to [`std::dbg`](https://doc.rust-lang.org/std/macro.dbg.html) the
130+
//! macro `dbg!` returns a given expression and prints it using `heprintln!`
131+
//! including context for quick and dirty debugging.
125132
//!
126133
//! Panics if `heprintln!` returns an error.
127134
//!
@@ -153,23 +160,22 @@
153160
//!
154161
//! ## `jlink-quirks`
155162
//!
156-
//! When this feature is enabled, return values above `0xfffffff0` from semihosting operation
157-
//! `SYS_WRITE` (0x05) are interpreted as if the entire buffer had been written. The current
158-
//! latest version 6.48b of J-Link exhibits such behaviour, causing a panic if this feature
159-
//! is not enabled.
163+
//! When this feature is enabled, return values above `0xfffffff0` from
164+
//! semihosting operation `SYS_WRITE` (0x05) are interpreted as if the entire
165+
//! buffer had been written. The current latest version 6.48b of J-Link exhibits
166+
//! such behaviour, causing a panic if this feature is not enabled.
160167
//!
161168
//! ## `no-semihosting`
162169
//!
163170
//! When this feature is enabled, the underlying system calls are patched out.
164171
//!
165172
//! # Reference
166173
//!
167-
//! For documentation about the semihosting operations, check:
168-
//!
169-
//! 'Chapter 8 - Semihosting' of the ['ARM Compiler toolchain Version 5.0'][pdf]
170-
//! manual.
171-
//!
172-
//! [pdf]: http://infocenter.arm.com/help/topic/com.arm.doc.dui0471e/DUI0471E_developing_for_arm_processors.pdf
174+
//! For documentation about the semihosting operations, check
175+
//! ['Semihosting for AArch32 and AArch64'](https://github.com/ARM-software/abi-aa/blob/main/semihosting/semihosting.rst).
176+
//! The RISC-V Semihosting spec is identical to Arm's with the exception of the
177+
//! assembly sequence necessary to trigger a semihosting call, so their
178+
//! documentation is sufficient.
173179
174180
#![deny(missing_docs)]
175181
#![no_std]

src/nr.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
//! Semihosting operations
2+
//!
3+
//! The details of what each operation does can be found in the
4+
//! [ARM Semihosting Specification](https://github.com/ARM-software/abi-aa/blob/main/semihosting/semihosting.rst#semihosting-operations).
5+
//! The RISC-V Semihosting operations are identiacal to ARM's, so their
6+
//! documentation is sufficient.
27
3-
// TODO document
48
#![allow(missing_docs)]
59

610
pub const CLOCK: usize = 0x10;

0 commit comments

Comments
 (0)