You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lib.rs
+36-35Lines changed: 36 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -362,12 +362,12 @@
362
362
//! or provide another set of information to override the current environment. Notably,
363
363
//! RISC-V hypervisors do not have direct access to machine mode (M-mode) registers.
364
364
//!
365
-
//! RustSBI supports both by providing a `MachineInfo` structure in instance based interface.
365
+
//! RustSBI supports both by providing a `EnvInfo` structure in instance based interface.
366
366
//! If RISC-V hypervisors choose to use existing information on current machine, it may require
367
-
//! to call underlying M-mode environment using SBI calls and fill in information into `MachineInfo`.
367
+
//! to call underlying M-mode environment using SBI calls and fill in information into `EnvInfo`.
368
368
//! If hypervisors use customized information other than taking the same one from the
369
-
//! environment they reside in, they may fill in custom one into `MachineInfo` structures.
370
-
//! When creating RustSBI instance, `MachineInfo` structure is required as an input of constructor.
369
+
//! environment they reside in, they may fill in custom one into `EnvInfo` structures.
370
+
//! When creating RustSBI instance, `EnvInfo` structure is required as an input of constructor.
371
371
//!
372
372
//! To begin with, include RustSBI library in file `Cargo.toml`:
373
373
//!
@@ -550,7 +550,7 @@ pub extern crate sbi_spec as spec;
550
550
///
551
551
/// # Usage
552
552
///
553
-
/// The `#[derive(RustSBI)]` macro provides a convenient way of building `RustSBI` trait implementation.
553
+
/// The `#[derive(RustSBI)]` macro provides a convenient way of building `RustSBI` trait implementations.
554
554
/// To use this macro, say that we have a struct `MyFence` with RISC-V SBI Remote Fence extension
555
555
/// implemented using `rustsbi::Fence` trait. Then, we build a struct around it, representing a
556
556
/// whole SBI implementation including one `Fence` extension only; we can name it `MySBI`:
@@ -572,10 +572,10 @@ pub extern crate sbi_spec as spec;
572
572
/// }
573
573
/// ```
574
574
///
575
-
/// Here, we declared the field named `fence` with type `MyFence`. The name `fence` is special, it tells
576
-
/// RustSBI derive macro that this field implements SBI Remote Fence instead of other SBI extensions.
575
+
/// Here, we declared the field named `fence` with type `MyFence`. The variable name `fence` is special,
576
+
/// it tells RustSBI derive macro that this field implements SBI Remote Fence instead of other SBI extensions.
577
577
/// We can continue to adding more fields into `MySBI`. For example, if we have RISC-V SBI Time extension
578
-
/// implementation `MyTimer`, we can add it to `MySBI`:
578
+
/// implementation with type `MyTimer`, we can add it to `MySBI`:
579
579
///
580
580
/// ```rust
581
581
/// struct MySBI {
@@ -615,7 +615,7 @@ pub extern crate sbi_spec as spec;
615
615
/// Oops! Compile failed. We'd check what happened here:
616
616
///
617
617
/// ```text
618
-
/// error: can't derive RustSBI: #[cfg(feature = "machine")] is needed to derive RustSBI with no extra MachineInfo provided; consider adding an `info` parameter to provide machine information if RustSBI is not run on machine mode.
618
+
/// error: can't derive RustSBI: #[cfg(feature = "machine")] is needed to derive RustSBI with no extra `EnvInfo` provided; consider adding an `info` parameter to provide machine information implementing `rustsbi::EnvInfo` if RustSBI is not run on machine mode.
619
619
/// --> example.rs:LL:10
620
620
/// |
621
621
/// LL | #[derive(RustSBI)]
@@ -626,12 +626,12 @@ pub extern crate sbi_spec as spec;
626
626
/// error: aborting due to previous error
627
627
/// ```
628
628
///
629
-
/// The error message hints that we don't have machine information implementing trait `MachineInfo`
630
-
/// provided. By default, RustSBI is targeted to provide RISC-V supervisor environment on any hardware,
629
+
/// The error message hints that we didn't provide any SBI environment information implementing trait
630
+
/// `EnvInfo`. By default, RustSBI is targeted to provide RISC-V supervisor environment on any hardware,
631
631
/// targeting hypervisor, emulator and binary translation applications. In this case, the virtualized
632
-
/// environment should provide the supervisor with machine information like `mvendorid`, `marchid` and
633
-
/// `mimpid` values. RustSBI could also be used on bare-metal RISC-V machines where such values would
634
-
/// be directly accessible through CSR read operations.
632
+
/// environment should provide the supervisor with machine environment information like `mvendorid`,
633
+
/// `marchid` and `mimpid` values. RustSBI could also be used on bare-metal RISC-V machines where such
634
+
/// values would be directly accessible through CSR read operations.
635
635
///
636
636
/// If we are targeting bare-metal, we can use the RustSBI library with `#[cfg(feature = "machine")]`
637
637
/// enabled by changing `dependencies` section in `Cargo.toml` file (if we are using Cargo):
@@ -642,7 +642,7 @@ pub extern crate sbi_spec as spec;
642
642
/// ```
643
643
///
644
644
/// If that's not the case and we are writing a virtualization targeted application, we should add a
645
-
/// `MachineInfo` implementation into the structure like `MySBI` mentioned above, with a special field
645
+
/// `EnvInfo` implementation into the structure like `MySBI` mentioned above, with a special field
646
646
/// name `info`. We can do it like:
647
647
///
648
648
/// ```rust
@@ -651,12 +651,12 @@ pub extern crate sbi_spec as spec;
651
651
/// fence: MyFence,
652
652
/// timer: MyTimer,
653
653
/// # #[cfg(not(feature = "machine"))]
654
-
/// info: MyMachineInfo,
654
+
/// info: MyEnvInfo,
655
655
/// }
656
656
///
657
-
/// struct MyMachineInfo;
657
+
/// struct MyEnvInfo;
658
658
///
659
-
/// impl rustsbi::MachineInfo for MyMachineInfo {
659
+
/// impl rustsbi::EnvInfo for MyEnvInfo {
660
660
/// #[inline]
661
661
/// fn mvendorid(&self) -> usize { todo!("add real value here") }
662
662
/// #[inline]
@@ -690,14 +690,14 @@ pub extern crate sbi_spec as spec;
690
690
/// #[derive(RustSBI)]
691
691
/// struct MySBI {
692
692
/// /* we omit the extension fields by now */
693
-
/// # info: MyMachineInfo,
693
+
/// # info: MyEnvInfo,
694
694
/// }
695
695
///
696
696
/// fn main() {
697
697
/// // Create a MySBI instance.
698
698
/// let sbi = MySBI {
699
699
/// /* include initial values for fields */
700
-
/// # info: MyMachineInfo
700
+
/// # info: MyEnvInfo
701
701
/// };
702
702
/// // Make the call. Read SBI implementation ID resides in extension Base (0x10),
703
703
/// // with function id 1, and it doesn't have any parameters.
@@ -706,8 +706,8 @@ pub extern crate sbi_spec as spec;
706
706
/// println!("SBI implementation ID for MySBI: {}", ret.value);
707
707
/// assert_eq!(ret.value, 4);
708
708
/// }
709
-
/// # struct MyMachineInfo;
710
-
/// # impl rustsbi::MachineInfo for MyMachineInfo {
0 commit comments