Skip to content

Commit 67b2fcd

Browse files
committed
SBI: fix formatting and CHANGELOG
1 parent 7d5d587 commit 67b2fcd

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

riscv-rt/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Optional cargo feature `sbi` for SBI compatibility, including conditional compilation for machine mode instructions.
13+
1014
### Changed
1115

1216
- Remove superfluous parentheses from link.x, which caused linker errors with nightly.
17+
- Changed `mp_hook` signature, hartid as passed as usize parameter by the caller (required for `sbi` feature).
1318

1419
## [v0.9.0] - 2022-07-01
1520

riscv-rt/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
if target.starts_with("riscv") {
1515
let mut target = Target::from_target_str(&target);
1616
target.retain_extensions("imfdc");
17-
let archive:String;
17+
let archive: String;
1818
if cfg!(feature = "sbi") {
1919
println!("======== compiling riscv-rt for sbi");
2020
archive = format!("bin/{}-sbi.a", target.to_string());

riscv-rt/src/lib.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
//! filename can be use instead of `memory.x`.
2222
//!
2323
//! - A `_sheap` symbol at whose address you can locate a heap.
24-
//!
25-
//! - Support for a runtime in supervisor mode, bootstrapped via [Supervisor Binary Interface (SBI)](https://github.com/riscv-non-isa/riscv-sbi-doc)
24+
//!
25+
//! - Support for a runtime in supervisor mode, bootstrapped via [Supervisor Binary Interface (SBI)](https://github.com/riscv-non-isa/riscv-sbi-doc)
2626
//!
2727
//! ``` text
2828
//! $ cargo new --bin app && cd $_
@@ -322,25 +322,25 @@
322322
//! ```
323323
//!
324324
//! Default implementation of this function stucks in a busy-loop.
325-
//!
325+
//!
326326
//! # Features
327-
//!
327+
//!
328328
//! ## `sbi`
329-
//!
329+
//!
330330
//! The SBI runtime feature (`sbi`) can be activated via [Cargo features](https://doc.rust-lang.org/cargo/reference/features.html).
331-
//!
332-
//! For example:
331+
//!
332+
//! For example:
333333
//! ``` text
334334
//! [dependencies]
335335
//! riscv-rt = {features=["sbi"]}
336-
//! ```
336+
//! ```
337337
//! Using the SBI requires riscv-rt to be run in supervisor mode instead of machine code.
338-
//! Internally, riscv-rt uses different versions of precompiled static libraries
339-
//! for (i) machine mode and (ii) sbi. If the `sbi` feature was activated,
340-
//! the build script selects the sbi library. While most registers/instructions have variants for
341-
//! both `mcause` and `scause`, the `mhartid` hardware thread register is not available in supervisor
338+
//! Internally, riscv-rt uses different versions of precompiled static libraries
339+
//! for (i) machine mode and (ii) sbi. If the `sbi` feature was activated,
340+
//! the build script selects the sbi library. While most registers/instructions have variants for
341+
//! both `mcause` and `scause`, the `mhartid` hardware thread register is not available in supervisor
342342
//! mode. Instead, the hartid is passed as parameter by the calling SBI.
343-
//!
343+
//!
344344
//! QEMU supports [OpenSBI](https://github.com/riscv-software-src/opensbi) as default firmware.
345345
//! ``` text
346346
//! APP_BINARY=$(find target -name app)
@@ -359,7 +359,7 @@
359359
#![no_std]
360360
#![deny(missing_docs)]
361361

362-
use riscv::register::{scause,mcause,mhartid};
362+
use riscv::register::{mcause, mhartid, scause};
363363
pub use riscv_rt_macros::{entry, pre_init};
364364

365365
#[export_name = "error: riscv-rt appears more than once in the dependency graph"]
@@ -400,7 +400,7 @@ pub unsafe extern "C" fn start_rust(a0: usize, a1: usize, a2: usize) -> ! {
400400
}
401401

402402
// sbi passes hartid as first parameter (a0)
403-
let hartid : usize;
403+
let hartid: usize;
404404
if cfg!(feature = "sbi") {
405405
hartid = a0;
406406
} else {
@@ -458,7 +458,7 @@ pub extern "C" fn start_trap_rust(trap_frame: *const TrapFrame) {
458458
}
459459

460460
unsafe {
461-
let code : usize;
461+
let code: usize;
462462
let is_exception: bool;
463463

464464
if cfg!(feature = "sbi") {
@@ -484,7 +484,7 @@ pub extern "C" fn start_trap_rust(trap_frame: *const TrapFrame) {
484484
} else {
485485
DefaultHandler();
486486
}
487-
}
487+
}
488488
}
489489
}
490490

0 commit comments

Comments
 (0)