sbi_spec/nacl.rs
1//! Chapter 15. Nested Acceleration Extension (EID #0x4E41434C "NACL").
2
3/// Extension ID for Nested Acceleration Extension.
4pub const EID_NACL: usize = crate::eid_from_str("NACL") as _;
5
6pub use fid::*;
7
8/// Declared in § 15.15.
9mod fid {
10 /// Function ID to probe a nested acceleration feature.
11 ///
12 /// Declared in §15.5.
13 pub const PROBE_FEATURE: usize = 0;
14 /// Function ID to set and enable the shared memory for nested acceleration on the calling hart.
15 ///
16 /// Declared in §15.6.
17 pub const SET_SHMEM: usize = 1;
18 /// Function ID to synchronize CSRs in the nested acceleration shared memory.
19 ///
20 /// Declared in §15.7.
21 pub const SYNC_CSR: usize = 2;
22 /// Function ID to synchronize HFENCEs in the nested acceleration shared memory.
23 ///
24 /// Declared in §15.8.
25 pub const SYNC_HFENCE: usize = 3;
26 /// Function ID to synchronize CSRs and HFENCEs in the nested acceleration shared memory and emulate the SRET instruction.
27 ///
28 /// Declared in §15.9.
29 pub const SYNC_SRET: usize = 4;
30}
31
32/// Nested Acceleration Feature ID.
33///
34/// Declared in §15.
35pub mod feature_id {
36 /// Feature ID for the CSR synchronizing feature.
37 ///
38 /// Declared in §15.1.
39 pub const SYNC_CSR: usize = 0;
40 /// Feature ID for the HFENCE synchronizing feature.
41 ///
42 /// Declared in §15.2.
43 pub const SYNC_HFENCE: usize = 1;
44 /// Feature ID for the SRET synchronizing feature.
45 ///
46 /// Declared in §15.3.
47 pub const SYNC_SRET: usize = 2;
48 /// Feature ID for the auto-swap CSR feature.
49 ///
50 /// Declared in §15.4.
51 pub const AUTOSWAP_CSR: usize = 3;
52}
53
54/// Size of shared memory set by supervisor software for current hart.
55///
56/// NACL shared memory includes scratch space and CSR space. Due to the difference
57/// of CSR width, this size varies between different `XLEN` values. `NATIVE`
58/// constant here only matches the integer width for the target this crate is compiled.
59/// If you are writing an SEE with different `XLEN` from the host platform, you should
60/// choose other correct constant value from `RV32`, `RV64` or `RV128` in module `shmem_size`
61/// instead.
62pub mod shmem_size {
63 use core::mem::size_of;
64 /// Size of NACL shared memory on platforms with `XLEN` of the same width as the current platform.
65 pub const NATIVE: usize = 4096 + 1024 * size_of::<usize>();
66
67 /// Size of NACL shared memory on RV32 platforms.
68 pub const RV32: usize = 4096 + 1024 * size_of::<u32>();
69
70 /// Size of NACL shared memory on RV64 platforms.
71 pub const RV64: usize = 4096 + 1024 * size_of::<u64>();
72
73 /// Size of NACL shared memory on RV128 platforms.
74 pub const RV128: usize = 4096 + 1024 * size_of::<u128>();
75}