TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmStdSmc.h
Go to the documentation of this file.
1
20#ifndef ARM_STD_SMC_H_
21#define ARM_STD_SMC_H_
22
23/*
24 * SMC function IDs for Standard Service queries
25 */
26
27#define ARM_SMC_ID_STD_CALL_COUNT 0x8400ff00
28#define ARM_SMC_ID_STD_UID 0x8400ff01
29/* 0x8400ff02 is reserved */
30#define ARM_SMC_ID_STD_REVISION 0x8400ff03
31
32/*
33 * The 'Standard Service Call UID' is supposed to return the Standard
34 * Service UUID. This is a 128-bit value.
35 */
36#define ARM_SMC_STD_UUID0 0x108d905b
37#define ARM_SMC_STD_UUID1 0x47e8f863
38#define ARM_SMC_STD_UUID2 0xfbc02dae
39#define ARM_SMC_STD_UUID3 0xe2f64156
40
41/*
42 * ARM Standard Service Calls revision numbers
43 * The current revision is: 0.1
44 */
45#define ARM_SMC_STD_REVISION_MAJOR 0x0
46#define ARM_SMC_STD_REVISION_MINOR 0x1
47
48/*
49 * Management Mode (MM) calls cover a subset of the Standard Service Call range.
50 * The list below is not exhaustive.
51 */
52#define ARM_SMC_ID_MM_VERSION_AARCH32 0x84000040
53#define ARM_SMC_ID_MM_VERSION_AARCH64 0xC4000040
54
55// Request service from secure standalone MM environment
56#define ARM_SMC_ID_MM_COMMUNICATE_AARCH32 0x84000041
57#define ARM_SMC_ID_MM_COMMUNICATE_AARCH64 0xC4000041
58
59/* Generic ID when using AArch32 or AArch64 execution state */
60#ifdef MDE_CPU_AARCH64
61#define ARM_SMC_ID_MM_COMMUNICATE ARM_SMC_ID_MM_COMMUNICATE_AARCH64
62#endif
63#ifdef MDE_CPU_ARM
64#define ARM_SMC_ID_MM_COMMUNICATE ARM_SMC_ID_MM_COMMUNICATE_AARCH32
65#endif
66
67/* MM return error codes */
68#define ARM_SMC_MM_RET_SUCCESS 0
69#define ARM_SMC_MM_RET_NOT_SUPPORTED -1
70#define ARM_SMC_MM_RET_INVALID_PARAMS -2
71#define ARM_SMC_MM_RET_DENIED -3
72#define ARM_SMC_MM_RET_NO_MEMORY -4
73
74// ARM Architecture Calls
75#define SMCCC_VERSION 0x80000000
76#define SMCCC_ARCH_FEATURES 0x80000001
77#define SMCCC_ARCH_SOC_ID 0x80000002
78#define SMCCC_ARCH_WORKAROUND_1 0x80008000
79#define SMCCC_ARCH_WORKAROUND_2 0x80007FFF
80
81#define SMC_ARCH_CALL_SUCCESS 0
82#define SMC_ARCH_CALL_NOT_SUPPORTED -1
83#define SMC_ARCH_CALL_NOT_REQUIRED -2
84#define SMC_ARCH_CALL_INVALID_PARAMETER -3
85
86/*
87 * Power State Coordination Interface (PSCI) calls cover a subset of the
88 * Standard Service Call range.
89 * The list below is not exhaustive.
90 */
91#define ARM_SMC_ID_PSCI_VERSION 0x84000000
92#define ARM_SMC_ID_PSCI_CPU_SUSPEND_AARCH64 0xc4000001
93#define ARM_SMC_ID_PSCI_CPU_SUSPEND_AARCH32 0x84000001
94#define ARM_SMC_ID_PSCI_CPU_OFF 0x84000002
95#define ARM_SMC_ID_PSCI_CPU_ON_AARCH64 0xc4000003
96#define ARM_SMC_ID_PSCI_CPU_ON_AARCH32 0x84000003
97#define ARM_SMC_ID_PSCI_AFFINITY_INFO_AARCH64 0xc4000004
98#define ARM_SMC_ID_PSCI_AFFINITY_INFO_AARCH32 0x84000004
99#define ARM_SMC_ID_PSCI_MIGRATE_AARCH64 0xc4000005
100#define ARM_SMC_ID_PSCI_MIGRATE_AARCH32 0x84000005
101#define ARM_SMC_ID_PSCI_SYSTEM_OFF 0x84000008
102#define ARM_SMC_ID_PSCI_SYSTEM_RESET 0x84000009
103#define ARM_SMC_ID_PSCI_FEATURES 0x8400000A
104#define ARM_SMC_ID_PSCI_SYSTEM_RESET2_AARCH64 0xC4000012
105
106/* The current PSCI version is: 0.2 */
107#define ARM_SMC_PSCI_VERSION_MAJOR 0
108#define ARM_SMC_PSCI_VERSION_MINOR 2
109#define ARM_SMC_PSCI_VERSION \
110 ((ARM_SMC_PSCI_VERSION_MAJOR << 16) | ARM_SMC_PSCI_VERSION_MINOR)
111
112/* PSCI return error codes */
113#define ARM_SMC_PSCI_RET_SUCCESS 0
114#define ARM_SMC_PSCI_RET_NOT_SUPPORTED -1
115#define ARM_SMC_PSCI_RET_INVALID_PARAMS -2
116#define ARM_SMC_PSCI_RET_DENIED -3
117#define ARM_SMC_PSCI_RET_ALREADY_ON -4
118#define ARM_SMC_PSCI_RET_ON_PENDING -5
119#define ARM_SMC_PSCI_RET_INTERN_FAIL -6
120#define ARM_SMC_PSCI_RET_NOT_PRESENT -7
121#define ARM_SMC_PSCI_RET_DISABLED -8
122
123#define ARM_SMC_PSCI_TARGET_CPU32(Aff2, Aff1, Aff0) \
124 ((((Aff2) & 0xFF) << 16) | (((Aff1) & 0xFF) << 8) | ((Aff0) & 0xFF))
125
126#define ARM_SMC_PSCI_TARGET_CPU64(Aff3, Aff2, Aff1, Aff0) \
127 ((((Aff3) & 0xFFULL) << 32) | (((Aff2) & 0xFF) << 16) | (((Aff1) & 0xFF) << 8) | ((Aff0) & 0xFF))
128
129#define ARM_SMC_PSCI_TARGET_GET_AFF0(TargetId) ((TargetId) & 0xFF)
130#define ARM_SMC_PSCI_TARGET_GET_AFF1(TargetId) (((TargetId) >> 8) & 0xFF)
131
132#define ARM_SMC_ID_PSCI_AFFINITY_LEVEL_0 0
133#define ARM_SMC_ID_PSCI_AFFINITY_LEVEL_1 1
134#define ARM_SMC_ID_PSCI_AFFINITY_LEVEL_2 2
135#define ARM_SMC_ID_PSCI_AFFINITY_LEVEL_3 3
136
137#define ARM_SMC_ID_PSCI_AFFINITY_INFO_ON 0
138#define ARM_SMC_ID_PSCI_AFFINITY_INFO_OFF 1
139#define ARM_SMC_ID_PSCI_AFFINITY_INFO_ON_PENDING 2
140
141/*
142 * SMC function IDs for Trusted OS Service queries
143 */
144#define ARM_SMC_ID_TOS_CALL_COUNT 0xbf00ff00
145#define ARM_SMC_ID_TOS_UID 0xbf00ff01
146/* 0xbf00ff02 is reserved */
147#define ARM_SMC_ID_TOS_REVISION 0xbf00ff03
148
149// Firmware TRNG interface Function IDs
150
151/*
152 SMC/HVC call to get the version of the TRNG backend,
153 Cf. [2], 2.1 TRNG_VERSION
154 Input values:
155 W0 0x8400_0050
156 W1-W7 Reserved (MBZ)
157 Return values:
158 Success (W0 > 0) W0[31] MBZ
159 W0[30:16] Major revision
160 W0[15:0] Minor revision
161 W1 - W3 Reserved (MBZ)
162 Error (W0 < 0)
163 NOT_SUPPORTED Function not implemented
164*/
165#define ARM_SMC_ID_TRNG_VERSION 0x84000050
166
167/*
168 SMC/HVC call to check if a TRNG function ID is implemented by the backend,
169 Cf. [2], Section 2.2 TRNG_FEATURES
170 Input Values
171 W0 0x8400_0051
172 W1 trng_func_id
173 W2-W7 Reserved (MBZ)
174 Return values:
175 Success (W0 >= 0):
176 SUCCESS Function is implemented.
177 > 0 Function is implemented and
178 has specific capabilities,
179 see function definition.
180 Error (W0 < 0)
181 NOT_SUPPORTED Function with FID=trng_func_id
182 is not implemented
183*/
184#define ARM_SMC_ID_TRNG_FEATURES 0x84000051
185
186/*
187 SMC/HVC call to get the UUID of the TRNG backend,
188 Cf. [2], Section 2.3 TRNG_GET_UUID
189 Input Values:
190 W0 0x8400_0052
191 W1-W7 Reserved (MBZ)
192 Return Values:
193 Success (W0 != -1)
194 W0 UUID[31:0]
195 W1 UUID[63:32]
196 W2 UUID[95:64]
197 W3 UUID[127:96]
198 Error (W0 = -1)
199 W0 NOT_SUPPORTED
200*/
201#define ARM_SMC_ID_TRNG_GET_UUID 0x84000052
202
203/*
204 AARCH32 SMC/HVC call to get entropy bits, Cf. [2], Section 2.4 TRNG_RND.
205 Input values:
206 W0 0x8400_0053
207 W2-W7 Reserved (MBZ)
208 Return values:
209 Success (W0 = 0):
210 W0 MBZ
211 W1 Entropy[95:64]
212 W2 Entropy[63:32]
213 W3 Entropy[31:0]
214 Error (W0 < 0)
215 W0 NOT_SUPPORTED
216 NO_ENTROPY
217 INVALID_PARAMETERS
218 W1 - W3 Reserved (MBZ)
219*/
220#define ARM_SMC_ID_TRNG_RND_AARCH32 0x84000053
221
222/*
223 AARCH64 SMC/HVC call to get entropy bits, Cf. [2], Section 2.4 TRNG_RND.
224 Input values:
225 X0 0xC400_0053
226 X2-X7 Reserved (MBZ)
227 Return values:
228 Success (X0 = 0):
229 X0 MBZ
230 X1 Entropy[191:128]
231 X2 Entropy[127:64]
232 X3 Entropy[63:0]
233 Error (X0 < 0)
234 X0 NOT_SUPPORTED
235 NO_ENTROPY
236 INVALID_PARAMETERS
237 X1 - X3 Reserved (MBZ)
238*/
239#define ARM_SMC_ID_TRNG_RND_AARCH64 0xC4000053
240
241// Firmware TRNG status codes
242#define TRNG_STATUS_SUCCESS (INT32)(0)
243#define TRNG_STATUS_NOT_SUPPORTED (INT32)(-1)
244#define TRNG_STATUS_INVALID_PARAMETER (INT32)(-2)
245#define TRNG_STATUS_NO_ENTROPY (INT32)(-3)
246
247/*
248 * SMC64 SiP Service Calls
249 */
250
251#define SMC_FASTCALL 0x80000000
252#define SMC64_FUNCTION (SMC_FASTCALL | 0x40000000)
253#define SMC_SIP_FUNCTION (SMC64_FUNCTION | 0x02000000)
254#define SMC_SIP_FUNCTION_ID(n) (SMC_SIP_FUNCTION | (n))
255
256#endif // ARM_STD_SMC_H_