Rearrange project. Signed-off-by: Zhouqi Jiang <[email protected]>
@@ -30,9 +30,9 @@ default = []
# to customize environment variables for RISC-V architecture like mvendorid, mimpid, etc.
machine = ["rustsbi-macros/machine", "dep:riscv"]
# Enables the struct `Forward`.
-# Struct `Forward` uses current SBI environment to implement the RustSBI environment.
+# Struct `Forward` uses the current SBI environment to implement the RustSBI environment.
# This feature is only usable when current software runs on another SBI environment,
-# e.g. hypervisors for RISC-V architecture.
+# e.g., hypervisors for RISC-V architecture.
forward = ["dep:sbi-rt"]
[package.metadata.docs.rs]
@@ -17,6 +17,7 @@ This version adds support to RISC-V SBI Specification version 2.0 ratified.
- `pmu_counter_fw_read_hi` in PMU extension
- Support for SBI CPPC extension
- Support for NACL and STA extensions
+- Re-export `HartMask`, `Physical`, `SbiRet` and `SharedPtr` on `sbi-rt` library root
### Modified
@@ -2,10 +2,9 @@
use crate::binary::{sbi_call_0, sbi_call_1};
-pub use sbi_spec::base::Version;
use sbi_spec::base::{
- EID_BASE, GET_MARCHID, GET_MIMPID, GET_MVENDORID, GET_SBI_IMPL_ID, GET_SBI_IMPL_VERSION,
- GET_SBI_SPEC_VERSION, PROBE_EXTENSION,
+ Version, EID_BASE, GET_MARCHID, GET_MIMPID, GET_MVENDORID, GET_SBI_IMPL_ID,
+ GET_SBI_IMPL_VERSION, GET_SBI_SPEC_VERSION, PROBE_EXTENSION,
};
/// Return the current SBI specification version.
@@ -1,6 +1,6 @@
//! Capture 3. Binary Encoding
-pub use sbi_spec::binary::SbiRet;
+use sbi_spec::binary::SbiRet;
#[inline(always)]
pub(crate) fn sbi_call_0(eid: usize, fid: usize) -> SbiRet {
@@ -1,11 +1,14 @@
//! Chapter 14. CPPC Extension (EID #0x43505043 "CPPC")
+use crate::binary::sbi_call_1;
#[cfg(target_pointer_width = "64")]
use crate::binary::sbi_call_2;
#[cfg(target_pointer_width = "32")]
use crate::binary::sbi_call_3;
-use crate::binary::{sbi_call_1, SbiRet};
-use sbi_spec::cppc::{EID_CPPC, PROBE, READ, READ_HI, WRITE};
+use sbi_spec::{
+ binary::SbiRet,
+ cppc::{EID_CPPC, PROBE, READ, READ_HI, WRITE},
+};
/// Probe whether the CPPC register is implemented or not by the platform.
///
@@ -1,7 +1,7 @@
//! Chapter 12. Debug Console Extension (EID #0x4442434E "DBCN")
-use crate::binary::{sbi_call_1, sbi_call_3, SbiRet};
+use crate::binary::{sbi_call_1, sbi_call_3};
use sbi_spec::{
- binary::Physical,
+ binary::{Physical, SbiRet},
dbcn::{CONSOLE_READ, CONSOLE_WRITE, CONSOLE_WRITE_BYTE, EID_DBCN},
@@ -1,8 +1,11 @@
//! Chapter 9. Hart State Management Extension (EID #0x48534D "HSM")
-use crate::binary::{sbi_call_0, sbi_call_1, sbi_call_3, SbiRet};
+use crate::binary::{sbi_call_0, sbi_call_1, sbi_call_3};
-use sbi_spec::hsm::{EID_HSM, HART_GET_STATUS, HART_START, HART_STOP, HART_SUSPEND};
+ hsm::{EID_HSM, HART_GET_STATUS, HART_START, HART_STOP, HART_SUSPEND},
/// Start executing the given hart at specified address in supervisor-mode.
@@ -31,8 +31,15 @@ mod nacl;
// §16
mod sta;
+pub use sbi_spec::{
+ base::Version,
+ binary::{HartMask, Physical, SbiRet, SharedPtr},
+
+// module `binary` includes crate-local `sbi_call_*` functions and is thus not re-exported
+// into the library root.
pub use base::*;
-pub use binary::*;
pub use cppc::*;
pub use dbcn::*;
pub use hsm::*;
@@ -1,9 +1,9 @@
//! Chapter 15. Nested Acceleration Extension (EID #0x4E41434C "NACL")
- binary::SharedPtr,
+ binary::{SbiRet, SharedPtr},
nacl::{shmem_size, EID_NACL, PROBE_FEATURE, SET_SHMEM, SYNC_CSR, SYNC_HFENCE, SYNC_SRET},
@@ -1,10 +1,13 @@
//! Chapter 11. Performance Monitoring Unit Extension (EID #0x504D55 "PMU")
-use sbi_spec::pmu::{
- COUNTER_CONFIG_MATCHING, COUNTER_FW_READ, COUNTER_FW_READ_HI, COUNTER_GET_INFO, COUNTER_START,
- COUNTER_STOP, EID_PMU, NUM_COUNTERS,
+ pmu::{
+ COUNTER_CONFIG_MATCHING, COUNTER_FW_READ, COUNTER_FW_READ_HI, COUNTER_GET_INFO,
+ COUNTER_START, COUNTER_STOP, EID_PMU, NUM_COUNTERS,
+ },
/// Returns the number of counters, both hardware and firmware.
//! Chapter 8. RFENCE Extension (EID #0x52464E43 "RFNC")
-use crate::binary::{sbi_call_2, sbi_call_4, sbi_call_5, SbiRet};
+use crate::binary::{sbi_call_2, sbi_call_4, sbi_call_5};
- binary::HartMask,
+ binary::{HartMask, SbiRet},
rfnc::{
EID_RFNC, REMOTE_FENCE_I, REMOTE_HFENCE_GVMA, REMOTE_HFENCE_GVMA_VMID, REMOTE_HFENCE_VVMA,
REMOTE_HFENCE_VVMA_ASID, REMOTE_SFENCE_VMA, REMOTE_SFENCE_VMA_ASID,
//! Chapter 7. IPI Extension (EID #0x735049 "sPI: s-mode IPI")
-use crate::binary::{sbi_call_2, SbiRet};
+use crate::binary::sbi_call_2;
spi::{EID_SPI, SEND_IPI},
//! Chapter 10. System Reset Extension (EID #0x53525354 "SRST")
-use sbi_spec::srst::{
- EID_SRST, RESET_REASON_NO_REASON, RESET_REASON_SYSTEM_FAILURE, RESET_TYPE_COLD_REBOOT,
- RESET_TYPE_SHUTDOWN, RESET_TYPE_WARM_REBOOT, SYSTEM_RESET,
+ srst::{
+ EID_SRST, RESET_REASON_NO_REASON, RESET_REASON_SYSTEM_FAILURE, RESET_TYPE_COLD_REBOOT,
+ RESET_TYPE_SHUTDOWN, RESET_TYPE_WARM_REBOOT, SYSTEM_RESET,
/// Reset the system based on provided `reset_type` and `reset_reason`.
//! Chapter 16. Steal-time Accounting Extension (EID #0x535441 "STA")
-use crate::binary::{sbi_call_3, SbiRet};
+use crate::binary::sbi_call_3;
sta::{EID_STA, SET_SHMEM},
@@ -1,7 +1,10 @@
//! Chapter 13. System Suspend Extension (EID #0x53555350 "SUSP")
-use sbi_spec::susp::{EID_SUSP, SUSPEND};
+ susp::{EID_SUSP, SUSPEND},
/// Suspend the system based on provided `sleep_type`.
@@ -1,8 +1,9 @@
//! Chapter 6. Timer Extension (EID #0x54494D45 "TIME")
-use crate::SbiRet;
-
-use sbi_spec::time::{EID_TIME, SET_TIMER};
+ time::{EID_TIME, SET_TIMER},
/// Programs the clock for the next event after an absolute time.