blob: 39772a9579507fd238fb775ebeae17298ff78d3a [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
5 */
6
7#ifndef SMC_RMI_H
8#define SMC_RMI_H
9
Soby Mathewb4c6df42022-11-09 11:13:29 +000010#include <smc.h>
11
12/*
13 * This file describes the Realm Management Interface (RMI) Application Binary
14 * Interface (ABI) for SMC calls made from Non-secure state to the RMM and
15 * serviced by the RMM.
Soby Mathewb4c6df42022-11-09 11:13:29 +000016 */
17
18/*
19 * The major version number of the RMI implementation. Increase this whenever
20 * the binary format or semantics of the SMC calls change.
21 */
AlexeiFedorov2cc6cee2023-10-09 16:19:05 +010022#define RMI_ABI_VERSION_MAJOR UL(1)
Soby Mathewb4c6df42022-11-09 11:13:29 +000023
24/*
25 * The minor version number of the RMI implementation. Increase this when
26 * a bug is fixed, or a feature is added without breaking binary compatibility.
27 */
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +010028#ifdef RMM_V1_1
29#define RMI_ABI_VERSION_MINOR UL(1)
30#else
AlexeiFedorovddf5daf2023-10-10 14:28:56 +010031#define RMI_ABI_VERSION_MINOR UL(0)
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +010032#endif
Soby Mathewb4c6df42022-11-09 11:13:29 +000033
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000034#define RMI_ABI_VERSION ((RMI_ABI_VERSION_MAJOR << U(16)) | \
AlexeiFedorovddf5daf2023-10-10 14:28:56 +010035 RMI_ABI_VERSION_MINOR)
Soby Mathewb4c6df42022-11-09 11:13:29 +000036
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000037#define RMI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> U(16))
38#define RMI_ABI_VERSION_GET_MINOR(_version) ((_version) & U(0xFFFF))
Soby Mathewb4c6df42022-11-09 11:13:29 +000039
40#define SMC64_RMI_FID(_offset) SMC64_STD_FID(RMI, _offset)
41
42#define IS_SMC64_RMI_FID(_fid) IS_SMC64_STD_FAST_IN_RANGE(RMI, _fid)
43
Yousuf A0ec040d2022-10-31 12:30:57 +000044/* Command completed successfully. index is zero. */
45#define RMI_SUCCESS U(0)
46
47/*
48 * The value of a command input value caused the command to fail.
49 * Index is zero.
50 */
51#define RMI_ERROR_INPUT U(1)
52
53/*
54 * An attribute of a Realm does not match the expected value.
55 * index varies between usages.
56 */
57#define RMI_ERROR_REALM U(2)
58
59/*
60 * An attribute of a REC does not match the expected value.
61 * Index is zero.
62 */
63#define RMI_ERROR_REC U(3)
64
65/*
66 * An RTT walk terminated before reaching the target RTT level, or reached
67 * an RTTE with an unexpected value. index: RTT level at which the walk
68 * terminated
69 */
70#define RMI_ERROR_RTT U(4)
71
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +010072/* An attribute of a device does not match the expected value */
73#define RMI_ERROR_DEVICE U(5)
74
75/* The command is not supported */
76#define RMI_ERROR_NOT_SUPPORTED U(6)
77
78/* RTTE in an auxiliary RTT contained an unexpected value */
79#define RMI_ERROR_RTT_AUX U(7)
80
81/* Max number of RMI Status Errors. */
82#define RMI_ERROR_COUNT_MAX U(8)
Yousuf A0ec040d2022-10-31 12:30:57 +000083
Soby Mathewb4c6df42022-11-09 11:13:29 +000084/*
85 * The number of GPRs (starting from X0) that are
86 * configured by the host when a REC is created.
87 */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000088#define REC_CREATE_NR_GPRS U(8)
Soby Mathewb4c6df42022-11-09 11:13:29 +000089
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000090#define REC_PARAMS_FLAG_RUNNABLE (UL(1) << 0)
Soby Mathewb4c6df42022-11-09 11:13:29 +000091
92/*
93 * The number of GPRs (starting from X0) per voluntary exit context.
94 * Per SMCCC.
95 */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000096#define REC_EXIT_NR_GPRS U(31)
Soby Mathewb4c6df42022-11-09 11:13:29 +000097
98/* RmiHashAlgorithm type */
AlexeiFedorov6a4314e2023-10-20 15:40:14 +010099#define RMI_HASH_SHA_256 0U
100#define RMI_HASH_SHA_512 1U
Soby Mathewb4c6df42022-11-09 11:13:29 +0000101
102/* Maximum number of Interrupt Controller List Registers */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000103#define REC_GIC_NUM_LRS U(16)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000104
Mate Toth-Pal0a8f37c2023-08-09 13:37:55 +0200105#ifndef CBMC
Soby Mathewb4c6df42022-11-09 11:13:29 +0000106/* Maximum number of auxiliary granules required for a REC */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000107#define MAX_REC_AUX_GRANULES U(16)
Mate Toth-Pal0a8f37c2023-08-09 13:37:55 +0200108#else /* CBMC */
109#define MAX_REC_AUX_GRANULES U(1)
110#endif /* CBMC */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000111
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100112/* Whether Host has completed emulation for an Emulatable Data Abort */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000113#define REC_ENTRY_FLAG_EMUL_MMIO (UL(1) << 0)
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100114
115/* Whether to inject a Synchronous External Abort into Realm */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000116#define REC_ENTRY_FLAG_INJECT_SEA (UL(1) << 1)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000117
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100118/* Whether to trap WFI/WFE execution by Realm */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000119#define REC_ENTRY_FLAG_TRAP_WFI (UL(1) << 2)
120#define REC_ENTRY_FLAG_TRAP_WFE (UL(1) << 3)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000121
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100122/* Host response to RIPAS change request */
123#define REC_ENTRY_FLAG_RIPAS_RESPONSE (UL(1) << 4)
124
Soby Mathewb4c6df42022-11-09 11:13:29 +0000125/*
126 * RmiRecExitReason represents the reason for a REC exit.
127 * This is returned to NS hosts via RMI_REC_ENTER::run_ptr.
128 */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000129#define RMI_EXIT_SYNC U(0)
130#define RMI_EXIT_IRQ U(1)
131#define RMI_EXIT_FIQ U(2)
132#define RMI_EXIT_PSCI U(3)
133#define RMI_EXIT_RIPAS_CHANGE U(4)
134#define RMI_EXIT_HOST_CALL U(5)
135#define RMI_EXIT_SERROR U(6)
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100136#define RMI_EXIT_DEV_COMM U(7)
137#define RMI_EXIT_RTT_REQUEST U(8)
138#define RMI_EXIT_S2AP_CHANGE U(9)
139#define RMI_EXIT_VDEV_REQUEST U(10)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000140
141/* RmiRttEntryState represents the state of an RTTE */
AlexeiFedorovc53b1f72023-07-04 15:37:03 +0100142#define RMI_UNASSIGNED UL(0)
143#define RMI_ASSIGNED UL(1)
144#define RMI_TABLE UL(2)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000145
AlexeiFedorov7bb7a702023-01-17 17:04:14 +0000146/* RmiFeature enumerations */
AlexeiFedorovc09b1652023-04-04 15:41:37 +0100147#define RMI_FEATURE_FALSE UL(0)
148#define RMI_FEATURE_TRUE UL(1)
AlexeiFedorov7bb7a702023-01-17 17:04:14 +0000149
Yousuf Aa297b9b2022-10-13 13:54:21 +0100150/* RmiFeatureRegister0 format */
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100151#define RMI_FEATURE_REGISTER_0_INDEX UL(0)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100152
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100153#define RMI_FEATURE_REGISTER_0_S2SZ_SHIFT UL(0)
154#define RMI_FEATURE_REGISTER_0_S2SZ_WIDTH UL(8)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100155
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100156#define RMI_FEATURE_REGISTER_0_LPA2_SHIFT UL(8)
157#define RMI_FEATURE_REGISTER_0_LPA2_WIDTH UL(1)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100158
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100159#define RMI_FEATURE_REGISTER_0_SVE_EN_SHIFT UL(9)
160#define RMI_FEATURE_REGISTER_0_SVE_EN_WIDTH UL(1)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100161
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100162#define RMI_FEATURE_REGISTER_0_SVE_VL_SHIFT UL(10)
163#define RMI_FEATURE_REGISTER_0_SVE_VL_WIDTH UL(4)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100164
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100165#define RMI_FEATURE_REGISTER_0_NUM_BPS_SHIFT UL(14)
166#define RMI_FEATURE_REGISTER_0_NUM_BPS_WIDTH UL(6)
AlexeiFedorov18002922023-04-06 10:19:51 +0100167
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100168#define RMI_FEATURE_REGISTER_0_NUM_WPS_SHIFT UL(20)
169#define RMI_FEATURE_REGISTER_0_NUM_WPS_WIDTH UL(6)
AlexeiFedorov18002922023-04-06 10:19:51 +0100170
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100171#define RMI_FEATURE_REGISTER_0_PMU_EN_SHIFT UL(26)
172#define RMI_FEATURE_REGISTER_0_PMU_EN_WIDTH UL(1)
AlexeiFedorov7bb7a702023-01-17 17:04:14 +0000173
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100174#define RMI_FEATURE_REGISTER_0_PMU_NUM_CTRS_SHIFT UL(27)
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100175#define RMI_FEATURE_REGISTER_0_PMU_NUM_CTRS_WIDTH UL(5)
AlexeiFedorov7bb7a702023-01-17 17:04:14 +0000176
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100177#define RMI_FEATURE_REGISTER_0_HASH_SHA_256_SHIFT UL(32)
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100178#define RMI_FEATURE_REGISTER_0_HASH_SHA_256_WIDTH UL(1)
AlexeiFedorov18002922023-04-06 10:19:51 +0100179
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100180#define RMI_FEATURE_REGISTER_0_HASH_SHA_512_SHIFT UL(33)
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100181#define RMI_FEATURE_REGISTER_0_HASH_SHA_512_WIDTH UL(1)
Arunachalam Ganapathyf6491212023-02-23 16:04:34 +0000182
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100183#define RMI_FEATURE_REGISTER_0_GICV3_NUM_LRS_SHIFT UL(34)
184#define RMI_FEATURE_REGISTER_0_GICV3_NUM_LRS_WIDTH UL(4)
185
186#define RMI_FEATURE_REGISTER_0_MAX_RECS_ORDER_SHIFT UL(38)
187#define RMI_FEATURE_REGISTER_0_MAX_RECS_ORDER_WIDTH UL(4)
188
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100189#define RMI_FEATURE_REGISTER_0_DA_EN_SHIFT UL(42)
190#define RMI_FEATURE_REGISTER_0_DA_EN_WIDTH UL(1)
191
192#define RMI_FEATURE_REGISTER_0_PLANE_RTT_SHIFT UL(43)
193#define RMI_FEATURE_REGISTER_0_PLANE_RTT_WIDTH UL(2)
194
195#define RMI_FEATURE_REGISTER_0_MAX_NUM_AUX_PLANES_SHIFT UL(45)
196#define RMI_FEATURE_REGISTER_0_MAX_NUM_AUX_PLANES_WIDTH UL(4)
197
AlexeiFedorovc53b1f72023-07-04 15:37:03 +0100198/* The RmiRipas enumeration represents realm IPA state */
199
200/* Address where no Realm resources are mapped */
201#define RMI_EMPTY UL(0)
202
203/* Address where private code or data owned by the Realm is mapped */
204#define RMI_RAM UL(1)
205
206/* Address which is inaccessible to the Realm due to an action taken by the Host */
207#define RMI_DESTROYED UL(2)
Yousuf A62808152022-10-31 10:35:42 +0000208
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100209/* Address where MMIO of an assigned Realm device is mapped. */
210#define RMI_IO UL(3)
211
AlexeiFedorov4d4e7342023-06-12 12:10:06 +0100212/* RmiPmuOverflowStatus enumeration representing PMU overflow status */
213#define RMI_PMU_OVERFLOW_NOT_ACTIVE U(0)
214#define RMI_PMU_OVERFLOW_ACTIVE U(1)
215
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100216/*
217 * RmiResponse enumeration represents whether the Host accepted
218 * or rejected a Realm request
219 */
AlexeiFedorov6a4314e2023-10-20 15:40:14 +0100220#define RMI_ACCEPT 0U
221#define RMI_REJECT 1U
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100222
AlexeiFedorov2cc6cee2023-10-09 16:19:05 +0100223/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100224 * FID: 0xC4000150
225 *
AlexeiFedorov2cc6cee2023-10-09 16:19:05 +0100226 * arg0: Requested interface version
227 *
228 * ret0: Command return status
229 * ret1: Lower implemented interface revision
230 * ret2: Higher implemented interface revision
231 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100232#define SMC_RMI_VERSION SMC64_RMI_FID(U(0x0))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000233
234/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100235 * FID: 0xC4000151
236 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000237 * arg0 == target granule address
238 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100239#define SMC_RMI_GRANULE_DELEGATE SMC64_RMI_FID(U(0x1))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000240
241/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100242 * FID: 0xC4000152
243 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000244 * arg0 == target granule address
245 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100246#define SMC_RMI_GRANULE_UNDELEGATE SMC64_RMI_FID(U(0x2))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000247
248/* RmiDataMeasureContent type */
AlexeiFedorov93f5ec52023-08-31 14:26:53 +0100249#define RMI_NO_MEASURE_CONTENT U(0)
250#define RMI_MEASURE_CONTENT U(1)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000251
252/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100253 * FID: 0xC4000153
254 *
AlexeiFedorovac923c82023-04-06 15:12:04 +0100255 * arg0 == RD address
256 * arg1 == data address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000257 * arg2 == map address
258 * arg3 == SRC address
259 * arg4 == flags
260 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100261#define SMC_RMI_DATA_CREATE SMC64_RMI_FID(U(0x3))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000262
263/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100264 * FID: 0xC4000154
265 *
AlexeiFedorovac923c82023-04-06 15:12:04 +0100266 * arg0 == RD address
267 * arg1 == data address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000268 * arg2 == map address
269 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100270#define SMC_RMI_DATA_CREATE_UNKNOWN SMC64_RMI_FID(U(0x4))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000271
272/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100273 * FID: 0xC4000155
274 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000275 * arg0 == RD address
276 * arg1 == map address
AlexeiFedorove2002be2023-04-19 17:20:12 +0100277 *
278 * ret1 == Address(PA) of the DATA granule, if ret0 == RMI_SUCCESS.
279 * Otherwise, undefined.
280 * ret2 == Top of the non-live address region. Only valid
AlexeiFedorov697445b2023-04-25 15:27:57 +0100281 * if ret0 == RMI_SUCCESS or ret0 == (RMI_ERROR_RTT, x)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000282 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100283#define SMC_RMI_DATA_DESTROY SMC64_RMI_FID(U(0x5))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000284
285/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100286 * FID: 0xC4000156
287 */
288#define SMC_RMI_PDEV_AUX_COUNT SMC64_RMI_FID(U(0x6))
289
290/*
291 * FID: 0xC4000157
292 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000293 * arg0 == RD address
294 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100295#define SMC_RMI_REALM_ACTIVATE SMC64_RMI_FID(U(0x7))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000296
297/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100298 * FID: 0xC4000158
299 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000300 * arg0 == RD address
AlexeiFedorovac923c82023-04-06 15:12:04 +0100301 * arg1 == struct rmi_realm_params address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000302 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100303#define SMC_RMI_REALM_CREATE SMC64_RMI_FID(U(0x8))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000304
305/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100306 * FID: 0xC4000159
307 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000308 * arg0 == RD address
309 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100310#define SMC_RMI_REALM_DESTROY SMC64_RMI_FID(U(0x9))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000311
312/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100313 * FID: 0xC400015A
314 *
AlexeiFedorovac923c82023-04-06 15:12:04 +0100315 * arg0 == RD address
316 * arg1 == REC address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000317 * arg2 == struct rmm_rec address
318 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100319#define SMC_RMI_REC_CREATE SMC64_RMI_FID(U(0xA))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000320
321/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100322 * FID: 0xC400015B
323 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000324 * arg0 == REC address
325 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100326#define SMC_RMI_REC_DESTROY SMC64_RMI_FID(U(0xB))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000327
328/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100329 * FID: 0xC400015C
330 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000331 * arg0 == rec address
AlexeiFedorovac923c82023-04-06 15:12:04 +0100332 * arg1 == struct rec_run address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000333 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100334#define SMC_RMI_REC_ENTER SMC64_RMI_FID(U(0xC))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000335
336/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100337 * FID: 0xC400015D
338 *
AlexeiFedorovac923c82023-04-06 15:12:04 +0100339 * arg0 == RD address
340 * arg1 == RTT address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000341 * arg2 == map address
342 * arg3 == level
343 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100344#define SMC_RMI_RTT_CREATE SMC64_RMI_FID(U(0xD))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000345
346/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100347 * FID: 0xC400015E
348 *
AlexeiFedorove2002be2023-04-19 17:20:12 +0100349 * arg0 == RD address
350 * arg1 == map address
351 * arg2 == level
352 *
353 * ret1 == Address (PA) of the RTT, if ret0 == RMI_SUCCESS
354 * Otherwise, undefined.
355 * ret2 == Top of the non-live address region. Only valid
AlexeiFedorov697445b2023-04-25 15:27:57 +0100356 * if ret0 == RMI_SUCCESS or ret0 == (RMI_ERROR_RTT, x)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000357 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100358#define SMC_RMI_RTT_DESTROY SMC64_RMI_FID(U(0xE))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000359
360/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100361 * FID: 0xC400015F
362 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000363 * arg0 == RD address
364 * arg1 == map address
365 * arg2 == level
366 * arg3 == s2tte
367 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100368#define SMC_RMI_RTT_MAP_UNPROTECTED SMC64_RMI_FID(U(0xF))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000369
370/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100371 * FID: 0xC4000160
372 */
373#define SMC_RMI_VDEV_AUX_COUNT SMC64_RMI_FID(U(0x10))
374
375/*
376 * FID: 0xC4000161
377 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000378 * arg0 == RD address
379 * arg1 == map address
380 * arg2 == level
AlexeiFedorov697445b2023-04-25 15:27:57 +0100381 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000382 * ret1 == level
383 * ret2 == s2tte type
384 * ret3 == s2tte
385 * ret4 == ripas
AlexeiFedorov697445b2023-04-25 15:27:57 +0100386 * if ret0 == RMI_SUCCESS, otherwise, undefined.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000387 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100388#define SMC_RMI_RTT_READ_ENTRY SMC64_RMI_FID(U(0x11))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000389
390/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100391 * FID: 0xC4000162
392 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000393 * arg0 == RD address
394 * arg1 == map address
395 * arg2 == level
396 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100397#define SMC_RMI_RTT_UNMAP_UNPROTECTED SMC64_RMI_FID(U(0x12))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000398
399/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100400 * FID: 0xC4000164
401 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000402 * arg0 == calling rec address
403 * arg1 == target rec address
404 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100405#define SMC_RMI_PSCI_COMPLETE SMC64_RMI_FID(U(0x14))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000406
407/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100408 * FID: 0xC4000165
409 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000410 * arg0 == Feature register index
411 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100412#define SMC_RMI_FEATURES SMC64_RMI_FID(U(0x15))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000413
414/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100415 * FID: 0xC4000166
416 *
AlexeiFedorove2002be2023-04-19 17:20:12 +0100417 * arg0 == RD address
418 * arg1 == map address
419 * arg2 == level
420 *
421 * ret1 == Address(PA) of the RTT folded, if ret0 == RMI_SUCCESS
Soby Mathewb4c6df42022-11-09 11:13:29 +0000422 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100423#define SMC_RMI_RTT_FOLD SMC64_RMI_FID(U(0x16))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000424
425/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100426 * FID: 0xC4000167
427 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000428 * arg0 == RD address
429 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100430#define SMC_RMI_REC_AUX_COUNT SMC64_RMI_FID(U(0x17))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000431
432/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100433 * FID: 0xC4000168
434 *
AlexeiFedorovac923c82023-04-06 15:12:04 +0100435 * arg0 == RD address
AlexeiFedorov960d1612023-04-25 13:23:39 +0100436 * arg1 == start address
437 * arg2 == end address
438 *
439 * ret1 == Top of the address range where the RIPAS was updated,
440 * if ret0 == RMI_SUCCESS
Soby Mathewb4c6df42022-11-09 11:13:29 +0000441 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100442#define SMC_RMI_RTT_INIT_RIPAS SMC64_RMI_FID(U(0x18))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000443
444/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100445 * FID: 0xC4000169
446 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000447 * arg0 == RD address
448 * arg1 == REC address
AlexeiFedorov5cf35ba2023-04-25 10:02:20 +0100449 * arg2 == start address
450 * arg3 == end address
451 *
452 * ret1 == Top of the address range where the RIPAS was updated,
453 * if ret0 == RMI_SUCCESS
Soby Mathewb4c6df42022-11-09 11:13:29 +0000454 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100455#define SMC_RMI_RTT_SET_RIPAS SMC64_RMI_FID(U(0x19))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000456
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100457/*
458 * TODO: Update the documentation of new FIDs once the 1.1 spec has stabilized.
459 */
460
461/*
462 * FID: 0xC4000170
463 */
464#define SMC_RMI_GRANULE_DEV_DELEGATE SMC64_RMI_FID(U(0x20))
465
466/*
467 * FID: 0xC4000171
468 */
469#define SMC_RMI_GRANULE_DEV_UNDELEGATE SMC64_RMI_FID(U(0x21))
470
471/*
472 * FID: 0xC4000172
473 */
474#define SMC_RMI_DEV_MAP SMC64_RMI_FID(U(0x22))
475
476/*
477 * FID: 0xC4000173
478 */
479#define SMC_RMI_DEV_UNMAP SMC64_RMI_FID(U(0x23))
480
481/*
482 * FID: 0xC4000174
483 */
484#define SMC_RMI_PDEV_ABORT SMC64_RMI_FID(U(0x24))
485
486/*
487 * FID: 0xC4000175
488 */
489#define SMC_RMI_PDEV_COMMUNICATE SMC64_RMI_FID(U(0x25))
490
491/*
492 * FID: 0xC4000176
493 */
494#define SMC_RMI_PDEV_CREATE SMC64_RMI_FID(U(0x26))
495
496/*
497 * FID: 0xC4000177
498 */
499#define SMC_RMI_PDEV_DESTROY SMC64_RMI_FID(U(0x27))
500
501/*
502 * FID: 0xC4000178
503 */
504#define SMC_RMI_PDEV_GET_STATE SMC64_RMI_FID(U(0x28))
505
506/*
507 * FID: 0xC4000179
508 */
509#define SMC_RMI_PDEV_IDE_RESET SMC64_RMI_FID(U(0x29))
510
511/*
512 * FID: 0xC400017A
513 */
514#define SMC_RMI_PDEV_NOTIFY SMC64_RMI_FID(U(0x2A))
515
516/*
517 * FID: 0xC400017B
518 */
519#define SMC_RMI_PDEV_SET_PUBKEY SMC64_RMI_FID(U(0x2B))
520
521/*
522 * FID: 0xC400017C
523 */
524#define SMC_RMI_PDEV_STOP SMC64_RMI_FID(U(0x2C))
525
526/*
527 * FID: 0xC400017D
528 */
529#define SMC_RMI_RTT_AUX_CREATE SMC64_RMI_FID(U(0x2D))
530
531/*
532 * FID: 0xC400017E
533 */
534#define SMC_RMI_RTT_AUX_DESTROY SMC64_RMI_FID(U(0x2E))
535
536/*
537 * FID: 0xC400017F
538 */
539#define SMC_RMI_RTT_AUX_FOLD SMC64_RMI_FID(U(0x2F))
540
541/*
542 * FID: 0xC4000180
543 */
544#define SMC_RMI_RTT_AUX_MAP_PROTECTED SMC64_RMI_FID(U(0x30))
545
546/*
547 * FID: 0xC4000181
548 */
549#define SMC_RMI_RTT_AUX_MAP_UNPROTECTED SMC64_RMI_FID(U(0x31))
550
551/*
552 * FID: 0xC4000183
553 */
554#define SMC_RMI_RTT_AUX_UNMAP_PROTECTED SMC64_RMI_FID(U(0x33))
555
556/*
557 * FID: 0xC4000184
558 */
559#define SMC_RMI_RTT_AUX_UNMAP_UNPROTECTED SMC64_RMI_FID(U(0x34))
560
561/*
562 * FID: 0xC4000185
563 */
564#define SMC_RMI_VDEV_ABORT SMC64_RMI_FID(U(0x35))
565
566/*
567 * FID: 0xC4000186
568 */
569#define SMC_RMI_VDEV_COMMUNICATE SMC64_RMI_FID(U(0x36))
570
571/*
572 * FID: 0xC4000187
573 */
574#define SMC_RMI_VDEV_CREATE SMC64_RMI_FID(U(0x37))
575
576/*
577 * FID: 0xC4000188
578 */
579#define SMC_RMI_VDEV_DESTROY SMC64_RMI_FID(U(0x38))
580
581/*
582 * FID: 0xC4000189
583 */
584#define SMC_RMI_VDEV_GET_STATE SMC64_RMI_FID(U(0x39))
585
586/*
587 * FID: 0xC400018A
588 */
589#define SMC_RMI_VDEV_STOP SMC64_RMI_FID(U(0x3A))
590
591/*
592 * FID: 0xC400018B
593 */
594#define SMC_RMI_RTT_SET_S2AP SMC64_RMI_FID(U(0x3B))
595
596/*
597 * FID: 0xC400018C
598 */
599#define SMC_RMI_MEC_SET_SHARED SMC64_RMI_FID(U(0x3C))
600
601/*
602 * FID: 0xC400018D
603 */
604#define SMC_RMI_MEC_SET_PRIVATE SMC64_RMI_FID(U(0x3D))
605
606/*
607 * FID: 0xC400018E
608 */
609#define SMC_RMI_VDEV_COMPLETE SMC64_RMI_FID(U(0x3E))
610
Soby Mathewb4c6df42022-11-09 11:13:29 +0000611/* Size of Realm Personalization Value */
Mate Toth-Palc751c0d2023-11-14 16:56:41 +0100612#ifndef CBMC
Soby Mathewb4c6df42022-11-09 11:13:29 +0000613#define RPV_SIZE 64
Mate Toth-Palc751c0d2023-11-14 16:56:41 +0100614#else
615/*
616 * Small RPV size so that `struct rd` fits in the reduced sized granule defined
617 * for CBMC
618 */
619#define RPV_SIZE 1
620#endif
Soby Mathewb4c6df42022-11-09 11:13:29 +0000621
AlexeiFedorov18002922023-04-06 10:19:51 +0100622/* RmiRealmFlags format */
623#define RMI_REALM_FLAGS_LPA2_SHIFT UL(0)
624#define RMI_REALM_FLAGS_LPA2_WIDTH UL(1)
625
626#define RMI_REALM_FLAGS_SVE_SHIFT UL(1)
627#define RMI_REALM_FLAGS_SVE_WIDTH UL(1)
628
629#define RMI_REALM_FLAGS_PMU_SHIFT UL(2)
630#define RMI_REALM_FLAGS_PMU_WIDTH UL(1)
631
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000632#ifndef __ASSEMBLER__
Soby Mathewb4c6df42022-11-09 11:13:29 +0000633/*
Soby Mathewc414f2a2023-01-17 02:50:17 +0000634 * Defines member of structure and reserves space
635 * for the next member with specified offset.
636 */
637#define SET_MEMBER_RMI SET_MEMBER
638
639/*
Soby Mathewb4c6df42022-11-09 11:13:29 +0000640 * The Realm attribute parameters are shared by the Host via
641 * RMI_REALM_CREATE::params_ptr. The values can be observed or modified
642 * either by the Host or by the Realm.
643 */
644struct rmi_realm_params {
AlexeiFedorov18002922023-04-06 10:19:51 +0100645 /* Flags */
646 SET_MEMBER_RMI(unsigned long flags, 0, 0x8); /* Offset 0 */
647 /* Requested IPA width */
648 SET_MEMBER_RMI(unsigned int s2sz, 0x8, 0x10); /* 0x8 */
649 /* Requested SVE vector length */
650 SET_MEMBER_RMI(unsigned int sve_vl, 0x10, 0x18); /* 0x10 */
651 /* Requested number of breakpoints */
652 SET_MEMBER_RMI(unsigned int num_bps, 0x18, 0x20); /* 0x18 */
653 /* Requested number of watchpoints */
654 SET_MEMBER_RMI(unsigned int num_wps, 0x20, 0x28); /* 0x20 */
655 /* Requested number of PMU counters */
656 SET_MEMBER_RMI(unsigned int pmu_num_ctrs, 0x28, 0x30); /* 0x28 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000657 /* Measurement algorithm */
AlexeiFedorov56e1a8e2023-09-01 17:06:13 +0100658 SET_MEMBER_RMI(unsigned char algorithm, 0x30, 0x400); /* 0x30 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000659 /* Realm Personalization Value */
AlexeiFedorov18002922023-04-06 10:19:51 +0100660 SET_MEMBER_RMI(unsigned char rpv[RPV_SIZE], 0x400, 0x800); /* 0x400 */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000661 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000662 /* Virtual Machine Identifier */
663 unsigned short vmid; /* 0x800 */
664 /* Realm Translation Table base */
665 unsigned long rtt_base; /* 0x808 */
666 /* RTT starting level */
667 long rtt_level_start; /* 0x810 */
668 /* Number of starting level RTTs */
669 unsigned int rtt_num_start; /* 0x818 */
670 }, 0x800, 0x1000);
671};
672
Soby Mathewb4c6df42022-11-09 11:13:29 +0000673/*
674 * The REC attribute parameters are shared by the Host via
AlexeiFedorov70115132023-11-27 13:04:26 +0000675 * RMI_REC_CREATE::params_ptr. The values can be observed or modified
Soby Mathewb4c6df42022-11-09 11:13:29 +0000676 * either by the Host or by the Realm which owns the REC.
677 */
678struct rmi_rec_params {
679 /* Flags */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000680 SET_MEMBER_RMI(unsigned long flags, 0, 0x100); /* Offset 0 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000681 /* MPIDR of the REC */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000682 SET_MEMBER_RMI(unsigned long mpidr, 0x100, 0x200); /* 0x100 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000683 /* Program counter */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000684 SET_MEMBER_RMI(unsigned long pc, 0x200, 0x300); /* 0x200 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000685 /* General-purpose registers */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000686 SET_MEMBER_RMI(unsigned long gprs[REC_CREATE_NR_GPRS], 0x300, 0x800); /* 0x300 */
687 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000688 /* Number of auxiliary Granules */
689 unsigned long num_aux; /* 0x800 */
690 /* Addresses of auxiliary Granules */
691 unsigned long aux[MAX_REC_AUX_GRANULES];/* 0x808 */
692 }, 0x800, 0x1000);
693};
694
Soby Mathewb4c6df42022-11-09 11:13:29 +0000695/*
696 * Structure contains data passed from the Host to the RMM on REC entry
697 */
AlexeiFedorov52912a62023-07-24 12:28:47 +0100698struct rmi_rec_enter {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000699 /* Flags */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000700 SET_MEMBER_RMI(unsigned long flags, 0, 0x200); /* Offset 0 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000701 /* General-purpose registers */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000702 SET_MEMBER_RMI(unsigned long gprs[REC_EXIT_NR_GPRS], 0x200, 0x300); /* 0x200 */
703 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000704 /* GICv3 Hypervisor Control Register */
705 unsigned long gicv3_hcr; /* 0x300 */
706 /* GICv3 List Registers */
707 unsigned long gicv3_lrs[REC_GIC_NUM_LRS]; /* 0x308 */
708 }, 0x300, 0x800);
709};
710
Soby Mathewb4c6df42022-11-09 11:13:29 +0000711/*
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100712 * RmiVdevAction
713 * Represents realm action which triggered REC exit due to device communication.
714 * Width: 8 bits
715 */
716#define RMI_VDEV_ACTION_GET_INTERFACE_REPORT U(0)
717#define RMI_VDEV_ACTION_GET_MEASUREMENTS U(1)
718#define RMI_VDEV_ACTION_LOCK U(2)
719#define RMI_VDEV_ACTION_START U(3)
720#define RMI_VDEV_ACTION_STOP U(4)
721
722/*
723 * RmiRecExitFlags
724 * Fieldset contains flags provided by the RMM during REC exit.
725 * Width: 64 bits
726 */
727#define RMI_REC_EXIT_FLAGS_RIPAS_DEV_SHARED_SHIFT U(0)
728#define RMI_REC_EXIT_FLAGS_RIPAS_DEV_SHARED_WIDTH U(1)
729
730/*
Soby Mathewb4c6df42022-11-09 11:13:29 +0000731 * Structure contains data passed from the RMM to the Host on REC exit
732 */
733struct rmi_rec_exit {
734 /* Exit reason */
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100735 SET_MEMBER_RMI(unsigned long exit_reason, 0, 0x8);/* Offset 0 */
736 /* RmiRecExitFlags: Flags */
737 SET_MEMBER_RMI(unsigned long flags, 0x8, 0x100);/* 0x8 */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000738 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000739 /* Exception Syndrome Register */
740 unsigned long esr; /* 0x100 */
741 /* Fault Address Register */
742 unsigned long far; /* 0x108 */
743 /* Hypervisor IPA Fault Address register */
744 unsigned long hpfar; /* 0x110 */
745 }, 0x100, 0x200);
746 /* General-purpose registers */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000747 SET_MEMBER_RMI(unsigned long gprs[REC_EXIT_NR_GPRS], 0x200, 0x300); /* 0x200 */
748 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000749 /* GICv3 Hypervisor Control Register */
750 unsigned long gicv3_hcr; /* 0x300 */
751 /* GICv3 List Registers */
752 unsigned long gicv3_lrs[REC_GIC_NUM_LRS]; /* 0x308 */
753 /* GICv3 Maintenance Interrupt State Register */
754 unsigned long gicv3_misr; /* 0x388 */
755 /* GICv3 Virtual Machine Control Register */
756 unsigned long gicv3_vmcr; /* 0x390 */
757 }, 0x300, 0x400);
Soby Mathewc414f2a2023-01-17 02:50:17 +0000758 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000759 /* Counter-timer Physical Timer Control Register */
760 unsigned long cntp_ctl; /* 0x400 */
761 /* Counter-timer Physical Timer CompareValue Register */
762 unsigned long cntp_cval; /* 0x408 */
763 /* Counter-timer Virtual Timer Control Register */
764 unsigned long cntv_ctl; /* 0x410 */
765 /* Counter-timer Virtual Timer CompareValue Register */
766 unsigned long cntv_cval; /* 0x418 */
767 }, 0x400, 0x500);
Soby Mathewc414f2a2023-01-17 02:50:17 +0000768 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000769 /* Base address of pending RIPAS change */
770 unsigned long ripas_base; /* 0x500 */
771 /* Size of pending RIPAS change */
AlexeiFedorovccce3ad2023-04-28 18:29:47 +0100772 unsigned long ripas_top; /* 0x508 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000773 /* RIPAS value of pending RIPAS change */
774 unsigned char ripas_value; /* 0x510 */
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100775 /*
776 * Base PA of device memory region, if RIPAS change is
777 * pending due to execution of
778 * RSI_RDEV_VALIDATE_MAPPING
779 */
780 unsigned long ripas_dev_pa; /* 0x518 */
781 /* Base addr of target region for pending S2AP change */
782 unsigned long s2ap_base; /* 0x520 */
783 /* Top addr of target region for pending S2AP change */
784 unsigned long s2ap_top; /* 0x528 */
785 /* Virtual device ID */
786 unsigned long vdev_id; /* 0x530 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000787 }, 0x500, 0x600);
788 /* Host call immediate value */
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100789 SET_MEMBER_RMI(unsigned int imm, 0x600, 0x608); /* 0x600 */
790 /* UInt64: Plane Index */
791 SET_MEMBER_RMI(unsigned long plane, 0x608, 0x610); /* 0x608 */
792 /* Address: VDEV which triggered REC exit due to device communication */
793 SET_MEMBER_RMI(unsigned long vdev, 0x610, 0x618); /* 0x610 */
794 /* RmiVdevAction: Action which triggered REC exit due to device comm */
795 SET_MEMBER_RMI(unsigned char vdev_action, 0x618, 0x700); /* 0x618 */
AlexeiFedorov4d4e7342023-06-12 12:10:06 +0100796 /* PMU overflow status */
797 SET_MEMBER_RMI(unsigned long pmu_ovf_status, 0x700, 0x800); /* 0x700 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000798};
799
Soby Mathewb4c6df42022-11-09 11:13:29 +0000800/*
801 * Structure contains shared information between RMM and Host
802 * during REC entry and REC exit.
803 */
804struct rmi_rec_run {
805 /* Entry information */
AlexeiFedorov52912a62023-07-24 12:28:47 +0100806 SET_MEMBER_RMI(struct rmi_rec_enter enter, 0, 0x800); /* Offset 0 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000807 /* Exit information */
AlexeiFedoroveaec0c42023-02-01 18:13:32 +0000808 SET_MEMBER_RMI(struct rmi_rec_exit exit, 0x800, 0x1000);/* 0x800 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000809};
810
Arunachalam Ganapathyf36187e2024-05-07 11:49:33 +0100811/*
812 * RmiPdevProtConfig
813 * Represents the protection between system and device.
814 * Width: 2 bits
815 */
816#define RMI_PDEV_IOCOH_E2E_IDE U(0)
817#define RMI_PDEV_IOCOH_E2E_SYS U(1)
818#define RMI_PDEV_FCOH_E2E_IDE U(2)
819#define RMI_PDEV_FCOH_E2E_SYS U(3)
820
821/*
822 * RmiPdevFlags
823 * Fieldset contains flags provided by the Host during PDEV creation
824 * Width: 64 bits
825 */
826/* RmiPdevProtConfig Bits 1:0 */
827#define RMI_PDEV_FLAGS_PROT_CONFIG_SHIFT UL(0)
828#define RMI_PDEV_FLAGS_PROT_CONFIG_WIDTH UL(2)
829
830/*
831 * RmiPdevEvent
832 * Represents physical device event.
833 * Width: 8 bits
834 */
835#define RMI_PDEV_EVENT_IDE_KEY_REFRESH U(0)
836
837/*
838 * RmiPdevState
839 * Represents the state of a PDEV
840 * Width: 8 bits
841 */
842#define RMI_PDEV_STATE_NEW U(0)
843#define RMI_PDEV_STATE_NEEDS_KEY U(1)
844#define RMI_PDEV_STATE_HAS_KEY U(2)
845#define RMI_PDEV_STATE_READY U(3)
846#define RMI_PDEV_STATE_COMMUNICATING U(4)
847#define RMI_PDEV_STATE_STOPPING U(5)
848#define RMI_PDEV_STATE_STOPPED U(6)
849#define RMI_PDEV_STATE_ERROR U(7)
850
851/*
852 * RmiSignatureAlgorithm
853 * Represents signature algorithm used in PDEV set key RMI call.
854 * Width: 8 bits
855 */
856#define RMI_SIGNATURE_ALGORITHM_RSASSA_3072 U(0)
857#define RMI_SIGNATURE_ALGORITHM_ECDSA_P256 U(1)
858#define RMI_SIGNATURE_ALGORITHM_ECDSA_P384 U(2)
859
860/*
861 * RmiDevMemShared
862 * Represents whether device memory Granule should be shared
863 * Width: 1 bit
864 */
865#define RMI_DEV_MEM_PRIVATE U(0)
866#define RMI_DEV_MEM_SHARED U(1)
867
868/*
869 * RmiDevDelegateFlags
870 * Fieldset contains flags provided by the Host during device memory granule
871 * delegation.
872 * Width: 64 bits
873 */
874/* RmiDevMemShared: Bit 0 */
875#define RMI_DEV_DELEGATE_FLAGS_SHARE_SHIFT U(0)
876#define RMI_DEV_DELEGATE_FLAGS_SHARE_WIDTH U(1)
877
878/*
879 * RmiDevCommEnterStatus (Name in Spec RmiDevCommStatus)
880 * Represents status passed from the Host to the RMM during device communication.
881 * Width: 8 bits
882 */
883#define RMI_DEV_COMM_ENTER_STATUS_SUCCESS U(0)
884#define RMI_DEV_COMM_ENTER_STATUS_ERROR U(1)
885#define RMI_DEV_COMM_ENTER_STATUS_NONE U(2)
886
887/*
888 * RmiDevCommEnter
889 * This structure contains data passed from the Host to the RMM during device
890 * communication.
891 * Width: 256 (0x100) bytes
892 */
893struct rmi_dev_comm_enter {
894 /* RmiDevCommEnterStatus: Status of device transaction */
895 SET_MEMBER_RMI(unsigned char status, 0, 0x8);
896 /* Address: Address of request buffer */
897 SET_MEMBER_RMI(unsigned long req_addr, 0x8, 0x10);
898 /* Address: Address of response buffer */
899 SET_MEMBER_RMI(unsigned long resp_addr, 0x10, 0x18);
900 /* UInt64: Amount of valid data in response buffer in bytes */
901 SET_MEMBER_RMI(unsigned long resp_len, 0x18, 0x100);
902};
903
904/*
905 * RmiDevCommExitFlags
906 * Fieldset contains flags provided by the RMM during a device transaction.
907 * Width: 64 bits
908 */
909#define RMI_DEV_COMM_EXIT_FLAGS_CACHE_SHIFT UL(0)
910#define RMI_DEV_COMM_EXIT_FLAGS_CACHE_WIDTH UL(1)
911#define RMI_DEV_COMM_EXIT_FLAGS_SEND_SHIFT UL(1)
912#define RMI_DEV_COMM_EXIT_FLAGS_SEND_WIDTH UL(1)
913#define RMI_DEV_COMM_EXIT_FLAGS_WAIT_SHIFT UL(2)
914#define RMI_DEV_COMM_EXIT_FLAGS_WAIT_WIDTH UL(1)
915#define RMI_DEV_COMM_EXIT_FLAGS_MULTI_SHIFT UL(3)
916#define RMI_DEV_COMM_EXIT_FLAGS_MULTI_WIDTH UL(1)
917
918/*
919 * RmiDevCommProtocol
920 * Represents the protocol used for device communication.
921 * Width: 8 bits
922 */
923#define RMI_DEV_COMM_PROTOCOL_SPDM U(0)
924#define RMI_DEV_COMM_PROTOCOL_SECURE_SPDM U(1)
925
926/*
927 * RmiDevCommExit
928 * This structure contains data passed from the RMM to the Host during device
929 * communication.
930 * Width: 256 (0x100) bytes.
931 */
932struct rmi_dev_comm_exit {
933 /*
934 * RmiDevCommExitFlags: Flags indicating the actions the host is
935 * requested to perform
936 */
937 SET_MEMBER_RMI(unsigned long flags, 0, 0x8);
938 /*
939 * UInt64: If flags.cache is true, offset in the device response buffer
940 * to the start of data to be cached in bytes.
941 */
942 SET_MEMBER_RMI(unsigned long cache_offset, 0x8, 0x10);
943 /*
944 * UInt64: If flags.cache is true, amount of data to be cached in
945 * bytes.
946 */
947 SET_MEMBER_RMI(unsigned long cache_len, 0x10, 0x18);
948 /* RmiDevCommProtocol: If flags.send is true, type of request */
949 SET_MEMBER_RMI(unsigned char protocol, 0x18, 0x20);
950 /*
951 * UInt64: If flags.send is true, amount of valid data in request buffer
952 * in bytes
953 */
954 SET_MEMBER_RMI(unsigned long req_len, 0x20, 0x28);
955 /*
956 * UInt64: If flags.wait is true, amount of time to wait for device
957 * response in milliseconds
958 */
959 SET_MEMBER_RMI(unsigned long timeout, 0x28, 0x100);
960};
961
962/*
963 * RmiDevCommData
964 * This structure contains data structure shared between Host and RMM for
965 * device communication.
966 * Width: 4096 (0x1000) bytes.
967 */
968#define RMI_DEV_COMM_ENTER_OFFSET 0x0
969#define RMI_DEV_COMM_EXIT_OFFSET 0x800
970#define RMI_DEV_COMM_DATA_SIZE 0x1000
971struct rmi_dev_comm_data {
972 /* RmiDevCommEnter: Entry information */
973 SET_MEMBER_RMI(struct rmi_dev_comm_enter enter,
974 RMI_DEV_COMM_ENTER_OFFSET, RMI_DEV_COMM_EXIT_OFFSET);
975 /* RmiDevCommExit: Exit information */
976 SET_MEMBER_RMI(struct rmi_dev_comm_exit exit,
977 RMI_DEV_COMM_EXIT_OFFSET, RMI_DEV_COMM_DATA_SIZE);
978};
979
980/*
981 * RmiAddressRange
982 * This structure contains base and top value of an address range.
983 * Width: 16 (0x10) bytes.
984 */
985struct rmi_address_range {
986 /* Address: Base of the address range (inclusive) */
987 SET_MEMBER_RMI(unsigned long base, 0, 0x8);
988 /* Address: Top of the address range (exclusive) */
989 SET_MEMBER_RMI(unsigned long top, 0x8, 0x10);
990};
991
992/*
993 * Maximum number of aux granules paramenter passed in rmi_pdev_params during
994 * PDEV createto PDEV create
995 */
996#define PDEV_PARAM_AUX_GRANULES_MAX U(32)
997
998/*
999 * Maximum number of IO coherent RmiAddressRange parameter passed in
1000 * rmi_pdev_params during PDEV create
1001 */
1002#define PDEV_PARAM_IOCOH_ADDR_RANGE_MAX U(16)
1003
1004/*
1005 * Maximum number of fully coherent RmiAddressRange parameter passed in
1006 * rmi_pdev_params during PDEV create
1007 */
1008#define PDEV_PARAM_FCOH_ADDR_RANGE_MAX U(4)
1009
1010/*
1011 * RmiPdevParams
1012 * This structure contains parameters provided by Host during PDEV creation.
1013 * Width: 4096 (0x1000) bytes.
1014 */
1015struct rmi_pdev_params {
1016 /* RmiPdevFlags: Flags */
1017 SET_MEMBER_RMI(unsigned long flags, 0, 0x8);
1018 /* Bits64: Physical device identifier */
1019 SET_MEMBER_RMI(unsigned long pdev_id, 0x8, 0x10);
1020 /* Bits16: Segment ID */
1021 SET_MEMBER_RMI(unsigned short segment_id, 0x10, 0x18);
1022 /* Bits16: Root Port identifier */
1023 SET_MEMBER_RMI(unsigned short root_id, 0x18, 0x20);
1024 /* UInt64: Certificate identifier */
1025 SET_MEMBER_RMI(unsigned long cert_id, 0x20, 0x28);
1026 /* UInt64: Base requester ID range (inclusive) */
1027 SET_MEMBER_RMI(unsigned long rid_base, 0x28, 0x30);
1028 /* UInt64: Top of requester ID range (exclusive) */
1029 SET_MEMBER_RMI(unsigned long rid_top, 0x30, 0x38);
1030 /* RmiHashAlgorithm: Algorithm used to generate device digests */
1031 SET_MEMBER_RMI(unsigned char hash_algo, 0x38, 0x40);
1032 /* UInt64: Number of auxiliary granules */
1033 SET_MEMBER_RMI(unsigned long num_aux, 0x40, 0x48);
1034 /* UInt64: IDE stream identifier */
1035 SET_MEMBER_RMI(unsigned long ide_sid, 0x48, 0x50);
1036 /* UInt64: Number of IO-coherent address ranges */
1037 SET_MEMBER_RMI(unsigned long iocoh_num_addr_range, 0x50, 0x58);
1038 /* UInt64: Number of fully-coherent address ranges */
1039 SET_MEMBER_RMI(unsigned long fcoh_num_addr_range, 0x58, 0x100);
1040
1041 /* Address: Addresses of auxiliary granules */
1042 SET_MEMBER_RMI(unsigned long aux[PDEV_PARAM_AUX_GRANULES_MAX], 0x100,
1043 0x200);
1044 /* RmiAddressRange: IO-coherent address range */
1045 SET_MEMBER_RMI(struct rmi_address_range
1046 iocoh_addr_range[PDEV_PARAM_IOCOH_ADDR_RANGE_MAX],
1047 0x200, 0x300);
1048 /* RmiAddressRange: Fully coherent address range */
1049 SET_MEMBER_RMI(struct rmi_address_range
1050 fcoh_addr_range[PDEV_PARAM_FCOH_ADDR_RANGE_MAX],
1051 0x300, 0x1000);
1052};
1053
1054/*
1055 * RmiVdevFlags
1056 * Fieldset contains flags provided by the Host during VDEV creation.
1057 * Width: 64 bits
1058 */
1059#define RMI_VDEV_FLAGS_RES0_SHIFT UL(0)
1060#define RMI_VDEV_FLAGS_RES0_WIDTH UL(63)
1061
1062/*
1063 * RmiVdevState
1064 * Represents the state of the VDEV
1065 * Width: 8 bits
1066 */
1067#define RMI_VDEV_STATE_READY U(0)
1068#define RMI_VDEV_STATE_COMMUNICATING U(1)
1069#define RMI_VDEV_STATE_STOPPING U(2)
1070#define RMI_VDEV_STATE_STOPPED U(3)
1071#define RMI_VDEV_STATE_ERROR U(4)
1072
1073/* Maximum number of aux granules paramenter passed to VDEV create */
1074#define VDEV_PARAM_AUX_GRANULES_MAX U(32)
1075
1076/*
1077 * RmiVdevParams
1078 * The RmiVdevParams structure contains parameters provided by the Host during
1079 * VDEV creation.
1080 * Width: 4096 (0x1000) bytes.
1081 */
1082struct rmi_vdev_params {
1083 /* RmiVdevFlags: Flags */
1084 SET_MEMBER_RMI(unsigned long flags, 0, 0x8);
1085 /* Bits64: Virtual device identifier */
1086 SET_MEMBER_RMI(unsigned long vdev_id, 0x8, 0x10);
1087 /* Bits64: TDI identifier */
1088 SET_MEMBER_RMI(unsigned long tdi_id, 0x10, 0x18);
1089 /* UInt64: Number of auxiliary granules */
1090 SET_MEMBER_RMI(unsigned long num_aux, 0x18, 0x100);
1091
1092 /* Address: Addresses of auxiliary granules */
1093 SET_MEMBER_RMI(unsigned long aux[VDEV_PARAM_AUX_GRANULES_MAX], 0x100,
1094 0x1000);
1095};
Soby Mathewc9b6ecd2023-01-17 03:40:44 +00001096#endif /* __ASSEMBLER__ */
1097
Soby Mathewb4c6df42022-11-09 11:13:29 +00001098#endif /* SMC_RMI_H */