1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#![no_std]
#[cfg(all(feature = "hvc", feature = "smc"))]
compile_error!("Only one of `hvc` or `smc` features may be enabled.");
#[cfg(any(feature = "hvc", feature = "smc"))]
mod calls;
pub mod error;
mod smccc;
#[cfg(any(feature = "hvc", feature = "smc"))]
pub use calls::{
affinity_info, cpu_default_suspend, cpu_freeze, cpu_off, cpu_on, cpu_suspend, mem_protect,
mem_protect_check_range, migrate, migrate_info_type, migrate_info_up_cpu, node_hw_state,
psci_features, set_suspend_mode, stat_count, stat_residency, system_off, system_reset,
system_reset2, system_suspend, version,
};
use error::Error;
pub const PSCI_VERSION: u32 = 0x84000000;
pub const PSCI_CPU_SUSPEND_32: u32 = 0x84000001;
pub const PSCI_CPU_SUSPEND_64: u32 = 0xC4000001;
pub const PSCI_CPU_OFF: u32 = 0x84000002;
pub const PSCI_CPU_ON_32: u32 = 0x84000003;
pub const PSCI_CPU_ON_64: u32 = 0xC4000003;
pub const PSCI_AFFINITY_INFO_32: u32 = 0x84000004;
pub const PSCI_AFFINITY_INFO_64: u32 = 0xC4000004;
pub const PSCI_MIGRATE_32: u32 = 0x84000005;
pub const PSCI_MIGRATE_64: u32 = 0xC4000005;
pub const PSCI_MIGRATE_INFO_TYPE: u32 = 0x84000006;
pub const PSCI_MIGRATE_INFO_UP_CPU_32: u32 = 0x84000007;
pub const PSCI_MIGRATE_INFO_UP_CPU_64: u32 = 0xC4000007;
pub const PSCI_SYSTEM_OFF: u32 = 0x84000008;
pub const PSCI_SYSTEM_RESET: u32 = 0x84000009;
pub const PSCI_SYSTEM_RESET2_32: u32 = 0x84000012;
pub const PSCI_SYSTEM_RESET2_64: u32 = 0xC4000012;
pub const PSCI_MEM_PROTECT: u32 = 0x84000013;
pub const PSCI_MEM_PROTECT_CHECK_RANGE_32: u32 = 0x84000014;
pub const PSCI_MEM_PROTECT_CHECK_RANGE_64: u32 = 0xC4000014;
pub const PSCI_FEATURES: u32 = 0x8400000A;
pub const PSCI_CPU_FREEZE: u32 = 0x8400000B;
pub const PSCI_CPU_DEFAULT_SUSPEND_32: u32 = 0x8400000C;
pub const PSCI_CPU_DEFAULT_SUSPEND_64: u32 = 0xC400000C;
pub const PSCI_NODE_HW_STATE_32: u32 = 0x8400000D;
pub const PSCI_NODE_HW_STATE_64: u32 = 0xC400000D;
pub const PSCI_SYSTEM_SUSPEND_32: u32 = 0x8400000E;
pub const PSCI_SYSTEM_SUSPEND_64: u32 = 0xC400000E;
pub const PSCI_SET_SUSPEND_MODE: u32 = 0x8400000F;
pub const PSCI_STAT_RESIDENCY_32: u32 = 0x84000010;
pub const PSCI_STAT_RESIDENCY_64: u32 = 0xC4000010;
pub const PSCI_STAT_COUNT_32: u32 = 0x84000011;
pub const PSCI_STAT_COUNT_64: u32 = 0xC4000011;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum LowestAffinityLevel {
All = 0,
Aff0Ignored = 1,
Aff0Aff1Ignored = 2,
Aff0Aff1Aff2Ignored = 3,
}
impl From<LowestAffinityLevel> for u64 {
fn from(lowest_affinity_level: LowestAffinityLevel) -> u64 {
(lowest_affinity_level as u32).into()
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum AffinityState {
On = 0,
Off = 1,
OnPending = 2,
}
impl TryFrom<i32> for AffinityState {
type Error = Error;
fn try_from(value: i32) -> Result<Self, Error> {
match value {
0 => Ok(Self::On),
1 => Ok(Self::Off),
2 => Ok(Self::OnPending),
_ => Err(value.into()),
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MigrateType {
MigrateCapable = 0,
NotMigrateCapable = 1,
MigrationNotRequired = 2,
}
impl TryFrom<i32> for MigrateType {
type Error = Error;
fn try_from(value: i32) -> Result<Self, Error> {
match value {
0 => Ok(Self::MigrateCapable),
1 => Ok(Self::NotMigrateCapable),
2 => Ok(Self::MigrationNotRequired),
_ => Err(value.into()),
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum PowerState {
HwOn = 0,
HwOff = 1,
HwStandby = 2,
}
impl TryFrom<i32> for PowerState {
type Error = Error;
fn try_from(value: i32) -> Result<Self, Error> {
match value {
0 => Ok(Self::HwOn),
1 => Ok(Self::HwOff),
2 => Ok(Self::HwStandby),
_ => Err(value.into()),
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum SuspendMode {
PlatformCoordinated = 0,
OsInitiated = 1,
}
impl From<SuspendMode> for u32 {
fn from(suspend_mode: SuspendMode) -> u32 {
suspend_mode as u32
}
}