Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Adapt riscv-semihosting to edition 2024
  • Loading branch information
romancardenas committed Jun 23, 2025
commit a71b9a5514664a995557ee0d21eb47f15ec1d824
4 changes: 2 additions & 2 deletions .github/workflows/riscv-semihosting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
build-riscv:
strategy:
matrix:
# All generated code should be running on stable now, MRSV is 1.67.0
toolchain: [ stable, nightly, 1.67.0 ]
# All generated code should be running on stable now, MRSV is 1.85.0
toolchain: [ stable, nightly, 1.85.0 ]
target:
- riscv32i-unknown-none-elf
- riscv32imc-unknown-none-elf
Expand Down
1 change: 1 addition & 0 deletions riscv-semihosting/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- Use `cfg(any(target_arch = "riscv32", target_arch = "riscv64"))` instead of `cfg(riscv)`.
- Update to Rust edition 2024 (MSRV 1.85)

### Removed

Expand Down
6 changes: 3 additions & 3 deletions riscv-semihosting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = [
"Jorge Aparicio <japaricious@gmail.com>",
"The RISC-V Team <risc-v@teams.rust-embedded.org>",
]
description = "Semihosting for RISCV processors"
description = "Semihosting for RISC-V processors"
documentation = "https://docs.rs/riscv-semihosting"
keywords = ["semihosting", "riscv"]
categories = ["no-std", "embedded"]
Expand All @@ -13,8 +13,8 @@ name = "riscv-semihosting"
readme = "README.md"
repository = "https://github.com/riscv-rust/riscv"
version = "0.2.0"
edition = "2021"
rust-version = "1.67"
edition = "2024"
rust-version = "1.85"

[features]
u-mode = []
Expand Down
6 changes: 3 additions & 3 deletions riscv-semihosting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ While `riscv-semihosting` is a good starting point for developing semihosted app

# Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.60.0 and up. It **won't**
This crate is guaranteed to compile on stable Rust 1.85.0 and up. It **won't**
compile with older versions.

## License

Copyright 2018-2023 [RISC-V team][team]
Copyright 2018-2025 [RISC-V team][team]

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
Expand Down Expand Up @@ -69,4 +69,4 @@ 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
[`cortex-m-semihosting`]: https://docs.rs/cortex-m-semihosting
14 changes: 8 additions & 6 deletions riscv-semihosting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub mod nr;
/// [semihosting operation]: https://developer.arm.com/documentation/dui0471/i/semihosting/semihosting-operations?lang=en
#[inline(always)]
pub unsafe fn syscall<T>(nr: usize, arg: &T) -> usize {
syscall1(nr, arg as *const T as usize)
unsafe { syscall1(nr, arg as *const T as usize) }
}

/// Performs a semihosting operation, takes one integer as an argument
Expand All @@ -221,7 +221,8 @@ pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize {
// it will be treated as a regular break, hence the norvc option.
//
// See https://github.com/riscv/riscv-semihosting-spec for more details.
core::arch::asm!("
unsafe {
core::arch::asm!("
.balign 16
.option push
.option norvc
Expand All @@ -230,10 +231,11 @@ pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize {
srai x0, x0, 0x7
.option pop
",
inout("a0") nr,
inout("a1") arg => _,
options(nostack, preserves_flags),
);
inout("a0") nr,
inout("a1") arg => _,
options(nostack, preserves_flags),
)
};
nr
}
#[cfg(all(
Expand Down