Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
romancardenas committed Jan 2, 2024
1 parent 4dc63f6 commit 449e170
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions riscv-semihosting/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Add recommendation for `semihosting` in README.md.
- Bug fixes
- Moved to the `riscv` Cargo workspace
- Bring in API changes from
[cortex-m-semihosting](https://github.com/rust-embedded/cortex-m/tree/master/cortex-m-semihosting),
Expand Down
15 changes: 13 additions & 2 deletions riscv-semihosting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

# `riscv-semihosting`

> Semihosting for RISC-V processors
> Simple semihosting for RISC-V processors
This is a fork of the
[cortex-m-semihosting](https://docs.rs/cortex-m-semihosting) crate with changes
[`cortex-m-semihosting`] crate with changes
to support the RISC-V Semihosting Specification as documented
[here](https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc)

Expand All @@ -23,6 +23,15 @@ to execute the semihosting operation in an interrupt-free context, while
*user-mode (U-mode)* causes them to just execute the operation.
By default, M-mode is used. You can activate the U-mode via the `u-mode` feature.

# About the [`semihosting`] crate

`riscv-semihosting` provides a simple semihosting API that matches [`cortex-m-semihosting`].
This allows a simple port from Cortex-M applications to RISC-V applications.
However, the [`semihosting`] crate presents a more advanced interface that is compatible
for RISC-V as well as other architectures (e.g., ARM or MIPS).
While `riscv-semihosting` is a good starting point for developing semihosted applications,
**we recommend using the [`semihosting`] crate.**


# Minimum Supported Rust Version (MSRV)

Expand Down Expand Up @@ -59,3 +68,5 @@ to intervene to uphold that code of conduct.

[CoC]: ../CODE_OF_CONDUCT.md
[team]: https://github.com/rust-embedded/wg#the-risc-v-team
[`semihosting`]: https://crates.io/crates/semihosting
[`cortex-m-semihosting`]: https://docs.rs/cortex-m-semihosting
4 changes: 3 additions & 1 deletion riscv-semihosting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize {
//
// See https://github.com/riscv/riscv-semihosting-spec for more details.
asm!("
.balign 16
.option push
.option norvc
slli x0, x0, 0x1f
Expand All @@ -229,7 +230,8 @@ pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize {
.option pop
",
inout("a0") nr,
in("a1") _arg,
inout("a1") _arg,
options(nostack, preserves_flags),
);
nr
}
Expand Down

0 comments on commit 449e170

Please sign in to comment.