Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions riscv-semihosting/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed

- Use `cfg(any(target_arch = "riscv32", target_arch = "riscv64"))` instead of `cfg(riscv)`.

### Removed

- Removed custom build script, as `cfg(riscv)` is no longer necessary.

## [v0.2.0] - 2025-06-10

### Changed
Expand Down
11 changes: 0 additions & 11 deletions riscv-semihosting/build.rs

This file was deleted.

17 changes: 10 additions & 7 deletions riscv-semihosting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@
#![deny(missing_docs)]
#![no_std]

#[cfg(all(riscv, not(feature = "no-semihosting")))]
use core::arch::asm;

#[macro_use]
mod macros;

Expand Down Expand Up @@ -213,15 +210,18 @@ pub unsafe fn syscall<T>(nr: usize, arg: &T) -> usize {
#[inline(always)]
pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize {
match () {
#[cfg(all(riscv, not(feature = "no-semihosting")))]
#[cfg(all(
any(target_arch = "riscv32", target_arch = "riscv64"),
not(feature = "no-semihosting")
))]
() => {
let mut nr = _nr;
let arg = _arg;
// The instructions below must always be uncompressed, otherwise
// it will be treated as a regular break, hence the norvc option.
//
// See https://github.com/riscv/riscv-semihosting-spec for more details.
asm!("
core::arch::asm!("
.balign 16
.option push
.option norvc
Expand All @@ -236,9 +236,12 @@ pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize {
);
nr
}
#[cfg(all(riscv, feature = "no-semihosting"))]
#[cfg(all(
any(target_arch = "riscv32", target_arch = "riscv64"),
feature = "no-semihosting"
))]
() => 0,
#[cfg(not(riscv))]
#[cfg(not(any(target_arch = "riscv32", target_arch = "riscv64")))]
() => unimplemented!(),
}
}