21
21
//! filename can be use instead of `memory.x`.
22
22
//!
23
23
//! - 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)
26
26
//!
27
27
//! ``` text
28
28
//! $ cargo new --bin app && cd $_
322
322
//! ```
323
323
//!
324
324
//! Default implementation of this function stucks in a busy-loop.
325
- //!
325
+ //!
326
326
//! # Features
327
- //!
327
+ //!
328
328
//! ## `sbi`
329
- //!
329
+ //!
330
330
//! 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:
333
333
//! ``` text
334
334
//! [dependencies]
335
335
//! riscv-rt = {features=["sbi"]}
336
- //! ```
336
+ //! ```
337
337
//! 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
342
342
//! mode. Instead, the hartid is passed as parameter by the calling SBI.
343
- //!
343
+ //!
344
344
//! QEMU supports [OpenSBI](https://github.com/riscv-software-src/opensbi) as default firmware.
345
345
//! ``` text
346
346
//! APP_BINARY=$(find target -name app)
359
359
#![ no_std]
360
360
#![ deny( missing_docs) ]
361
361
362
- use riscv:: register:: { scause , mcause, mhartid} ;
362
+ use riscv:: register:: { mcause, mhartid, scause } ;
363
363
pub use riscv_rt_macros:: { entry, pre_init} ;
364
364
365
365
#[ 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) -> ! {
400
400
}
401
401
402
402
// sbi passes hartid as first parameter (a0)
403
- let hartid : usize ;
403
+ let hartid: usize ;
404
404
if cfg ! ( feature = "sbi" ) {
405
405
hartid = a0;
406
406
} else {
@@ -458,7 +458,7 @@ pub extern "C" fn start_trap_rust(trap_frame: *const TrapFrame) {
458
458
}
459
459
460
460
unsafe {
461
- let code : usize ;
461
+ let code: usize ;
462
462
let is_exception: bool ;
463
463
464
464
if cfg ! ( feature = "sbi" ) {
@@ -484,7 +484,7 @@ pub extern "C" fn start_trap_rust(trap_frame: *const TrapFrame) {
484
484
} else {
485
485
DefaultHandler ( ) ;
486
486
}
487
- }
487
+ }
488
488
}
489
489
}
490
490
0 commit comments