浏览代码

crate: exclude "machine" on default

run on provided `MachineInfo` by default; bare metal M-mode environment should gate `machine`
luojia65 2 年之前
父节点
当前提交
a3b2fc49be
共有 5 个文件被更改,包括 13 次插入6 次删除
  1. 2 2
      .github/workflows/rust.yml
  2. 2 0
      CHANGELOG.md
  3. 1 1
      Cargo.toml
  4. 1 0
      src/instance.rs
  5. 7 3
      src/lib.rs

+ 2 - 2
.github/workflows/rust.yml

@@ -53,7 +53,7 @@ jobs:
         uses: actions-rs/cargo@v1
         with:
           command: check
-          args: --target ${{ matrix.TARGET }} --no-default-features --verbose
+          args: --target ${{ matrix.TARGET }} --verbose
       - name: Check (machine)
         uses: actions-rs/cargo@v1
         with:
@@ -102,7 +102,7 @@ jobs:
         uses: actions-rs/cargo@v1
         with:
           command: test
-          args: --no-default-features --verbose
+          args: --verbose
       - name: Run tests (machine)
         uses: actions-rs/cargo@v1
         with:

+ 2 - 0
CHANGELOG.md

@@ -11,6 +11,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ### Modified
 
+- run on provided `MachineInfo` by default; bare metal M-mode environment should gate `machine`
+
 ### Removed
 
 - `sbi_2_0` feature; RustSBI now supports SBI 2.0-rc1 by default

+ 1 - 1
Cargo.toml

@@ -20,7 +20,7 @@ sbi-spec = "0.0.5"
 riscv = { version = "0.10.1", optional = true }
 
 [features]
-default = ["machine"]
+default = []
 # Run RustSBI on machine mode
 # This feature enables to use RISC-V primitives on current machine mode environment
 # If you are developing a cross-architecture virtual machine, consider disabling this feature

+ 1 - 0
src/instance.rs

@@ -57,6 +57,7 @@ impl<T: Timer, I: Ipi, R: Fence, H: Hsm, S: Reset, P: Pmu, C: Console>
 
     /// Create RustSBI instance on given machine information for all the SBI extensions
     #[cfg(not(feature = "machine"))]
+    #[allow(clippy::too_many_arguments)] // fixme: is it possible to have a better design here?
     #[inline]
     pub const fn with_machine_info(
         timer: T,

+ 7 - 3
src/lib.rs

@@ -148,9 +148,13 @@
 //!
 //! ```toml
 //! [dependencies]
-//! rustsbi = "0.4.0"
+//! rustsbi = { version = "0.4.0", features = ["machine"] }
 //! ```
 //!
+//! The feature `machine` indicates that RustSBI library is run directly on machine mode RISC-V
+//! environment; it will use `riscv` crate to fetch machine mode environment, which fits our demand
+//! of using it on bare metal RISC-V.
+//!
 //! After hardware initialization process, the part of firmware with RustSBI linked should run on memory
 //! blocks with fast accesses, as it would be called frequently by operating system.
 //! If the supervisor is called by trap generator semantics, insert `rustsbi::RustSBI` structure
@@ -363,11 +367,11 @@
 //! environment they reside in, they may fill in custom one into `MachineInfo` structures.
 //! When creating RustSBI instance, `MachineInfo` structure is required as an input of constructor.
 //!
-//! To begin with, disable default features in file `Cargo.toml`:
+//! To begin with, include RustSBI library in file `Cargo.toml`:
 //!
 //! ```toml
 //! [dependencies]
-//! rustsbi = { version = "0.4.0", default-features = false }
+//! rustsbi = "0.4.0"
 //! ```
 //!
 //! This will disable default feature `machine` which will assume that RustSBI runs on M-mode directly,