Browse Source

nacl: modify type of parameter `shmem` using `NATIVE` constant from sbi-spec

Signed-off-by: Zhouqi Jiang <[email protected]>
Zhouqi Jiang 1 year ago
parent
commit
abdf85fe16
3 changed files with 8 additions and 16 deletions
  1. 1 0
      CHANGELOG.md
  2. 1 1
      Cargo.toml
  3. 6 15
      src/nacl.rs

+ 1 - 0
CHANGELOG.md

@@ -13,6 +13,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 - support CPPC extension 
 - `new_uninit` and `uninit_with_machine_info` constructors for RustSBI instance
 - `handle_ecall` now only requires `&self` since RustSBI trait implementations are internally mutable
+- support NACL and STA extensions
 
 ### Modified
 

+ 1 - 1
Cargo.toml

@@ -17,7 +17,7 @@ edition = "2021"
 exclude = ["/.github"]
 
 [dependencies]
-sbi-spec = "0.0.7-alpha.1"
+sbi-spec = "0.0.7-alpha.2"
 riscv = { version = "0.10.1", optional = true }
 
 [features]

+ 6 - 15
src/nacl.rs

@@ -1,6 +1,7 @@
-use core::mem::size_of;
-
-use spec::binary::{SbiRet, SharedPtr};
+use spec::{
+    binary::{SbiRet, SharedPtr},
+    nacl::shmem_size::NATIVE,
+};
 
 /// Nested Acceleration Extension
 ///
@@ -65,13 +66,7 @@ pub trait Nacl: Send + Sync {
     /// | `SbiRet::success()`         | The steal-time shared memory physical base address was set or cleared successfully.
     /// | `SbiRet::invalid_param()`   | The `flags` parameter is not zero or the `shmem` is not 4096-byte aligned.
     /// | `SbiRet::invalid_address()` | The shared memory pointed to by the `shmem` parameter is not writable or does not satisfy other requirements of shared memory physical address range.
-    // fixme: `shmem` should have length of a constant definition like `SharedPtr<[u8; SHMEM_LEN]>`,
-    // where `SHMEM_LEN` is defined in `sbi-spec` crate to be `4096 + (XLEN * 128)`.
-    fn set_shmem(
-        &self,
-        shmem: SharedPtr<[u8; size_of::<usize>() * 128 + 4096]>,
-        flags: usize,
-    ) -> SbiRet;
+    fn set_shmem(&self, shmem: SharedPtr<[u8; NATIVE]>, flags: usize) -> SbiRet;
     /// Synchronize shared memory CSRs.
     ///
     /// Synchronize CSRs in the nested acceleration shared memory. This is an
@@ -154,11 +149,7 @@ impl<T: Nacl> Nacl for T {
         T::probe_feature(self, feature_id)
     }
     #[inline]
-    fn set_shmem(
-        &self,
-        shmem: SharedPtr<[u8; size_of::<usize>() * 128 + 4096]>,
-        flags: usize,
-    ) -> SbiRet {
+    fn set_shmem(&self, shmem: SharedPtr<[u8; NATIVE]>, flags: usize) -> SbiRet {
         T::set_shmem(self, shmem, flags)
     }
     #[inline]