瀏覽代碼

feat: add `into_inner` function for `HartMask`

This function is useful when forwarding RustSBI to SBI runtime libraries.

Signed-off-by: Zhouqi Jiang <[email protected]>
Zhouqi Jiang 1 年之前
父節點
當前提交
5baa946c40
共有 2 個文件被更改,包括 9 次插入2 次删除
  1. 1 0
      CHANGELOG.md
  2. 8 2
      src/hart_mask.rs

+ 1 - 0
CHANGELOG.md

@@ -15,6 +15,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 - `handle_ecall` now only requires `&self` since RustSBI trait implementations are internally mutable
 - support NACL and STA extensions
 - macro based `#[derive(RustSBI)]` interface
+- `into_inner` function for `HartMask`
 
 ### Modified
 

+ 8 - 2
src/hart_mask.rs

@@ -1,5 +1,5 @@
 /// Hart mask structure in SBI function calls.
-#[derive(Debug, Clone)]
+#[derive(Debug, Copy, Clone)]
 pub struct HartMask {
     inner: BitVector,
 }
@@ -16,6 +16,12 @@ impl HartMask {
         }
     }
 
+    /// Returns `hart_mask` and `hart_mask_base` parameters from the hart mask structure.
+    #[inline]
+    pub const fn into_inner(self) -> (usize, usize) {
+        (self.inner.hart_mask, self.inner.hart_mask_base)
+    }
+
     /// Check if the `hart_id` is included in this hart mask structure.
     #[inline]
     pub const fn has_bit(&self, hart_id: usize) -> bool {
@@ -40,7 +46,7 @@ impl HartMask {
     }
 }
 
-#[derive(Debug, Clone)]
+#[derive(Debug, Copy, Clone)]
 struct BitVector {
     hart_mask: usize,
     hart_mask_base: usize,