sbi_spec/hsm.rs
1//! Chapter 9. Hart State Management Extension (EID #0x48534D "HSM").
2
3/// Extension ID for Hart State Management extension.
4pub const EID_HSM: usize = crate::eid_from_str("HSM") as _;
5pub use fid::*;
6
7/// Hart states.
8///
9/// Declared in Table 1 at §9.
10pub mod hart_state {
11 /// The hart is physically powered-up and executing normally.
12 pub const STARTED: usize = 0;
13 /// The hart is not executing in supervisor-mode or any lower privilege mode.
14 ///
15 /// It is probably powered-down by the SBI implementation if the underlying platform
16 /// has a mechanism to physically power-down harts.
17 pub const STOPPED: usize = 1;
18 /// The hart is pending before being started
19 ///
20 /// Some other hart has requested to start (or power-up) the hart from the STOPPED state,
21 /// and the SBI implementation is still working to get the hart in the STARTED state.
22 pub const START_PENDING: usize = 2;
23 /// The hart is pending before being stopped.
24 ///
25 /// The hart has requested to stop (or power-down) itself from the STARTED state,
26 /// and the SBI implementation is still working to get the hart in the STOPPED state.
27 pub const STOP_PENDING: usize = 3;
28 /// The hart is in a platform-specific suspend (or low-power) state.
29 pub const SUSPENDED: usize = 4;
30 /// The hart is pending before being suspended.
31 ///
32 /// The hart has requested to put itself in a platform-specific low-power state
33 /// from the STARTED state, and the SBI implementation is still working to get
34 /// the hart in the platform-specific SUSPENDED state.
35 pub const SUSPEND_PENDING: usize = 5;
36 /// The hart is pending before being resumed.
37 ///
38 /// An interrupt or platform specific hardware event has caused the hart to resume
39 /// normal execution from the SUSPENDED state, and the SBI implementation is still
40 /// working to get the hart in the STARTED state.
41 pub const RESUME_PENDING: usize = 6;
42}
43
44/// Hart suspend types.
45pub mod suspend_type {
46 /// Default retentive hart suspend type.
47 pub const RETENTIVE: u32 = 0;
48 /// Default non-retentive hart suspend type.
49 pub const NON_RETENTIVE: u32 = 0x8000_0000;
50}
51
52/// Declared in §9.5.
53mod fid {
54 /// Function ID to start executing the given hart at specified address in supervisor-mode.
55 ///
56 /// Declared in §9.1.
57 pub const HART_START: usize = 0;
58 /// Function ID to stop executing the calling hart in supervisor-mode.
59 ///
60 /// Declared in §9.2.
61 pub const HART_STOP: usize = 1;
62 /// Function ID to get the current status (or HSM state id) of the given hart.
63 ///
64 /// Declared in §9.3.
65 pub const HART_GET_STATUS: usize = 2;
66 /// Function ID to put the calling hart into suspend or platform-specific lower power states.
67 ///
68 /// Declared in §9.4.
69 pub const HART_SUSPEND: usize = 3;
70}