Explorar el Código

sbi-rt: re-export `HartMask`, `Physical`, `SbiRet` and `SharedPtr` on library root

Rearrange project.

Signed-off-by: Zhouqi Jiang <[email protected]>
Zhouqi Jiang hace 1 año
padre
commit
42d0bb8f3a

+ 2 - 2
Cargo.toml

@@ -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]

+ 1 - 0
sbi-rt/CHANGELOG.md

@@ -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 - 3
sbi-rt/src/base.rs

@@ -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 - 1
sbi-rt/src/binary.rs

@@ -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 {

+ 5 - 2
sbi-rt/src/cppc.rs

@@ -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.
 ///

+ 2 - 2
sbi-rt/src/dbcn.rs

@@ -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},
 };
 

+ 5 - 2
sbi-rt/src/hsm.rs

@@ -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};
+use sbi_spec::{
+    binary::SbiRet,
+    hsm::{EID_HSM, HART_GET_STATUS, HART_START, HART_STOP, HART_SUSPEND},
+};
 
 /// Start executing the given hart at specified address in supervisor-mode.
 ///

+ 8 - 1
sbi-rt/src/lib.rs

@@ -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::*;

+ 2 - 2
sbi-rt/src/nacl.rs

@@ -1,9 +1,9 @@
 //! Chapter 15. Nested Acceleration Extension (EID #0x4E41434C "NACL")
 
-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::{
-    binary::SharedPtr,
+    binary::{SbiRet, SharedPtr},
     nacl::{shmem_size, EID_NACL, PROBE_FEATURE, SET_SHMEM, SYNC_CSR, SYNC_HFENCE, SYNC_SRET},
 };
 

+ 7 - 4
sbi-rt/src/pmu.rs

@@ -1,10 +1,13 @@
 //! Chapter 11. Performance Monitoring Unit Extension (EID #0x504D55 "PMU")
 
-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::pmu::{
-    COUNTER_CONFIG_MATCHING, COUNTER_FW_READ, COUNTER_FW_READ_HI, COUNTER_GET_INFO, COUNTER_START,
-    COUNTER_STOP, EID_PMU, NUM_COUNTERS,
+use sbi_spec::{
+    binary::SbiRet,
+    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.

+ 2 - 2
sbi-rt/src/rfnc.rs

@@ -1,9 +1,9 @@
 //! 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};
 
 use sbi_spec::{
-    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,

+ 2 - 2
sbi-rt/src/spi.rs

@@ -1,9 +1,9 @@
 //! Chapter 7. IPI Extension (EID #0x735049 "sPI: s-mode IPI")
 
-use crate::binary::{sbi_call_2, SbiRet};
+use crate::binary::sbi_call_2;
 
 use sbi_spec::{
-    binary::HartMask,
+    binary::{HartMask, SbiRet},
     spi::{EID_SPI, SEND_IPI},
 };
 

+ 7 - 4
sbi-rt/src/srst.rs

@@ -1,10 +1,13 @@
 //! Chapter 10. System Reset Extension (EID #0x53525354 "SRST")
 
-use crate::binary::{sbi_call_2, SbiRet};
+use crate::binary::sbi_call_2;
 
-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,
+use sbi_spec::{
+    binary::SbiRet,
+    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`.

+ 2 - 2
sbi-rt/src/sta.rs

@@ -1,9 +1,9 @@
 //! Chapter 16. Steal-time Accounting Extension (EID #0x535441 "STA")
 
-use crate::binary::{sbi_call_3, SbiRet};
+use crate::binary::sbi_call_3;
 
 use sbi_spec::{
-    binary::SharedPtr,
+    binary::{SbiRet, SharedPtr},
     sta::{EID_STA, SET_SHMEM},
 };
 

+ 5 - 2
sbi-rt/src/susp.rs

@@ -1,7 +1,10 @@
 //! Chapter 13. System Suspend Extension (EID #0x53555350 "SUSP")
 
-use crate::binary::{sbi_call_3, SbiRet};
-use sbi_spec::susp::{EID_SUSP, SUSPEND};
+use crate::binary::sbi_call_3;
+use sbi_spec::{
+    binary::SbiRet,
+    susp::{EID_SUSP, SUSPEND},
+};
 
 /// Suspend the system based on provided `sleep_type`.
 ///

+ 4 - 3
sbi-rt/src/time.rs

@@ -1,8 +1,9 @@
 //! Chapter 6. Timer Extension (EID #0x54494D45 "TIME")
 
-use crate::SbiRet;
-
-use sbi_spec::time::{EID_TIME, SET_TIMER};
+use sbi_spec::{
+    binary::SbiRet,
+    time::{EID_TIME, SET_TIMER},
+};
 
 /// Programs the clock for the next event after an absolute time.
 ///