blob: 6da304d21bf526efcd44639f6c1a29546c55df67 [file] [log] [blame]
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001/*
J-Alves13318e32021-02-22 17:21:00 +00002 * Copyright 2021 The Hafnium Authors.
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01003 *
Andrew Walbrane959ec12020-06-17 15:01:09 +01004 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/BSD-3-Clause.
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01007 */
8
9#pragma once
10
11#include "hf/types.h"
12
Karl Meakin0e617d92024-04-05 12:55:22 +010013/**
14 * The version number of a Firmware Framework implementation is a 31-bit
15 * unsigned integer, with the upper 15 bits denoting the major revision,
16 * and the lower 16 bits denoting the minor revision.
17 *
18 * See FF-A specification v1.2 ALP1, section 13.2.1.
19 */
Karl Meakin0dba87e2025-03-24 17:36:04 +000020enum ffa_version : uint32_t {
Karl Meakin0e617d92024-04-05 12:55:22 +010021 FFA_VERSION_1_0 = 0x10000,
22 FFA_VERSION_1_1 = 0x10001,
23 FFA_VERSION_1_2 = 0x10002,
Karl Meakin59352b32025-02-25 12:19:45 +000024/*
25 * Use the value of `FFA_VERSION` passed by the build system, otherwise default
26 * to latest FF-A version.
27 */
28#ifdef FFA_VERSION
29 FFA_VERSION_COMPILED = FFA_VERSION,
30#else
Karl Meakin0e617d92024-04-05 12:55:22 +010031 FFA_VERSION_COMPILED = FFA_VERSION_1_2,
Karl Meakin59352b32025-02-25 12:19:45 +000032#endif
Karl Meakin0e617d92024-04-05 12:55:22 +010033};
Daniel Boulby6e32c612021-02-17 15:09:41 +000034
Karl Meakin59352b32025-02-25 12:19:45 +000035static_assert((FFA_VERSION_1_0 <= FFA_VERSION_COMPILED) &&
36 (FFA_VERSION_1_2 >= FFA_VERSION_COMPILED),
37 "FFA_VERSION_COMPILED must be between v1.0 and v1.2");
38
Karl Meakin0e617d92024-04-05 12:55:22 +010039#define FFA_VERSION_MBZ_BIT (1U << 31U)
40#define FFA_VERSION_MAJOR_SHIFT (16U)
41#define FFA_VERSION_MAJOR_MASK (0x7FFFU)
42#define FFA_VERSION_MINOR_SHIFT (0U)
43#define FFA_VERSION_MINOR_MASK (0xFFFFU)
44
45/** Return true if the version is valid (i.e. bit 31 is 0). */
46static inline bool ffa_version_is_valid(uint32_t version)
47{
48 return (version & FFA_VERSION_MBZ_BIT) == 0;
49}
50
51/** Construct a version from a pair of major and minor components. */
52static inline enum ffa_version make_ffa_version(uint16_t major, uint16_t minor)
53{
54 return (enum ffa_version)((major << FFA_VERSION_MAJOR_SHIFT) |
55 (minor << FFA_VERSION_MINOR_SHIFT));
56}
57
58/** Get the major component of the version. */
59static inline uint16_t ffa_version_get_major(enum ffa_version version)
60{
61 return (version >> FFA_VERSION_MAJOR_SHIFT) & FFA_VERSION_MAJOR_MASK;
62}
63
64/** Get the minor component of the version. */
65static inline uint16_t ffa_version_get_minor(enum ffa_version version)
66{
67 return (version >> FFA_VERSION_MINOR_SHIFT) & FFA_VERSION_MINOR_MASK;
68}
Olivier Deprez62d99e32020-01-09 15:58:07 +010069
Daniel Boulbyc7dc9322023-10-27 15:12:07 +010070/**
71 * Check major versions are equal and the minor version of the caller is
72 * less than or equal to the minor version of the callee.
73 */
Karl Meakin0e617d92024-04-05 12:55:22 +010074static inline bool ffa_versions_are_compatible(enum ffa_version caller,
75 enum ffa_version callee)
76{
77 return ffa_version_get_major(caller) == ffa_version_get_major(callee) &&
78 ffa_version_get_minor(caller) <= ffa_version_get_minor(callee);
79}
Daniel Boulbyc7dc9322023-10-27 15:12:07 +010080
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010081/* clang-format off */
82
83#define FFA_LOW_32_ID 0x84000060
84#define FFA_HIGH_32_ID 0x8400007F
85#define FFA_LOW_64_ID 0xC4000060
Fuad Tabbada72d142020-07-30 09:17:05 +010086#define FFA_HIGH_64_ID 0xC400007F
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010087
Karl Meakinf51a35f2023-08-07 17:53:52 +010088/**
89 * FF-A function identifiers.
90 * Don't forget to update `ffa_func_name` if you add a new one.
91 */
Karl Meakinadf6daf2025-03-19 15:29:31 +000092enum ffa_function : uint32_t {
93 FFA_ERROR_32 = 0x84000060,
94 FFA_SUCCESS_32 = 0x84000061,
95 FFA_SUCCESS_64 = 0xC4000061,
96 FFA_INTERRUPT_32 = 0x84000062,
97 FFA_VERSION_32 = 0x84000063,
98 FFA_FEATURES_32 = 0x84000064,
99 FFA_RX_RELEASE_32 = 0x84000065,
100 FFA_RXTX_MAP_32 = 0x84000066,
101 FFA_RXTX_MAP_64 = 0xC4000066,
102 FFA_RXTX_UNMAP_32 = 0x84000067,
103 FFA_PARTITION_INFO_GET_32 = 0x84000068,
104 FFA_ID_GET_32 = 0x84000069,
105 FFA_MSG_POLL_32 = 0x8400006A, /* Legacy FF-A v1.0 */
106 FFA_MSG_WAIT_32 = 0x8400006B,
107 FFA_YIELD_32 = 0x8400006C,
108 FFA_RUN_32 = 0x8400006D,
109 FFA_MSG_SEND_32 = 0x8400006E, /* Legacy FF-A v1.0 */
110 FFA_MSG_SEND_DIRECT_REQ_32 = 0x8400006F,
111 FFA_MSG_SEND_DIRECT_REQ_64 = 0xC400006F,
112 FFA_MSG_SEND_DIRECT_RESP_32 = 0x84000070,
113 FFA_MSG_SEND_DIRECT_RESP_64 = 0xC4000070,
114 FFA_MEM_DONATE_32 = 0x84000071,
115 FFA_MEM_DONATE_64 = 0xC4000071,
116 FFA_MEM_LEND_32 = 0x84000072,
117 FFA_MEM_LEND_64 = 0xC4000072,
118 FFA_MEM_SHARE_32 = 0x84000073,
119 FFA_MEM_SHARE_64 = 0xC4000073,
120 FFA_MEM_RETRIEVE_REQ_32 = 0x84000074,
121 FFA_MEM_RETRIEVE_REQ_64 = 0xC4000074,
122 FFA_MEM_RETRIEVE_RESP_32 = 0x84000075,
123 FFA_MEM_RELINQUISH_32 = 0x84000076,
124 FFA_MEM_RECLAIM_32 = 0x84000077,
125 FFA_MEM_FRAG_RX_32 = 0x8400007A,
126 FFA_MEM_FRAG_TX_32 = 0x8400007B,
127 FFA_NORMAL_WORLD_RESUME = 0x8400007C,
J-Alves3829fc02021-03-18 12:49:18 +0000128
Karl Meakinadf6daf2025-03-19 15:29:31 +0000129 /* FF-A v1.1 */
130 FFA_NOTIFICATION_BITMAP_CREATE_32 = 0x8400007D,
131 FFA_NOTIFICATION_BITMAP_DESTROY_32 = 0x8400007E,
132 FFA_NOTIFICATION_BIND_32 = 0x8400007F,
133 FFA_NOTIFICATION_UNBIND_32 = 0x84000080,
134 FFA_NOTIFICATION_SET_32 = 0x84000081,
135 FFA_NOTIFICATION_GET_32 = 0x84000082,
136 FFA_NOTIFICATION_INFO_GET_64 = 0xC4000083,
137 FFA_RX_ACQUIRE_32 = 0x84000084,
138 FFA_SPM_ID_GET_32 = 0x84000085,
139 FFA_MSG_SEND2_32 = 0x84000086,
140 FFA_SECONDARY_EP_REGISTER_64 = 0xC4000087,
141 FFA_MEM_PERM_GET_32 = 0x84000088,
142 FFA_MEM_PERM_SET_32 = 0x84000089,
143 FFA_MEM_PERM_GET_64 = 0xC4000088,
144 FFA_MEM_PERM_SET_64 = 0xC4000089,
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100145
Karl Meakinadf6daf2025-03-19 15:29:31 +0000146 /* FF-A v1.2 */
147 FFA_CONSOLE_LOG_32 = 0x8400008A,
148 FFA_CONSOLE_LOG_64 = 0xC400008A,
149 FFA_PARTITION_INFO_GET_REGS_64 = 0xC400008B,
150 FFA_EL3_INTR_HANDLE_32 = 0x8400008C,
151 FFA_MSG_SEND_DIRECT_REQ2_64 = 0xC400008D,
152 FFA_MSG_SEND_DIRECT_RESP2_64 = 0xC400008E,
Madhukar Pappireddy04cf9e82025-03-17 17:32:02 -0500153
154 /*
155 * FF-A v1.3 ALP2 spec introduces a new ABI to abort a partition when
156 * it's execution context encounters a fatal error.
157 */
158 FFA_ABORT_32 = 0x84000090,
159 FFA_ABORT_64 = 0xC4000090,
Karl Meakinadf6daf2025-03-19 15:29:31 +0000160};
Maksims Svecovs71b76702022-05-20 15:32:58 +0100161
Karl Meakinf51a35f2023-08-07 17:53:52 +0100162/**
163 * FF-A error codes.
164 * Don't forget to update `ffa_error_name` if you add a new one.
Karl Meakin0dba87e2025-03-24 17:36:04 +0000165 *
166 * NOTE: Error codes have negative values, but we set the underlying type of the
167 * enum to `uint32_t` because it is more convenient to treat them as unsigned
168 * values: the SMCC calling convention specifies that signed 32 bit values must
169 * be zero-extended when passed in 64-bit registers (ie the upper 32 bits must
170 * be zero).
Karl Meakinf51a35f2023-08-07 17:53:52 +0100171 */
Karl Meakin0dba87e2025-03-24 17:36:04 +0000172enum ffa_error : uint32_t {
173 FFA_NOT_SUPPORTED = UINT32_C(-1),
174 FFA_INVALID_PARAMETERS = UINT32_C(-2),
175 FFA_NO_MEMORY = UINT32_C(-3),
176 FFA_BUSY = UINT32_C(-4),
177 FFA_INTERRUPTED = UINT32_C(-5),
178 FFA_DENIED = UINT32_C(-6),
179 FFA_RETRY = UINT32_C(-7),
180 FFA_ABORTED = UINT32_C(-8),
181 FFA_NO_DATA = UINT32_C(-9),
182 FFA_NOT_READY = UINT32_C(-10),
Karl Meakindc759f52024-05-07 16:08:02 +0100183};
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100184
185/* clang-format on */
186
Karl Meakinf51a35f2023-08-07 17:53:52 +0100187/* Return the name of the function identifier. */
Karl Meakinadf6daf2025-03-19 15:29:31 +0000188static inline const char *ffa_func_name(enum ffa_function func)
Karl Meakinf51a35f2023-08-07 17:53:52 +0100189{
190 switch (func) {
191 case FFA_ERROR_32:
192 return "FFA_ERROR_32";
193 case FFA_SUCCESS_32:
194 return "FFA_SUCCESS_32";
195 case FFA_SUCCESS_64:
196 return "FFA_SUCCESS_64";
197 case FFA_INTERRUPT_32:
198 return "FFA_INTERRUPT_32";
199 case FFA_VERSION_32:
200 return "FFA_VERSION_32";
201 case FFA_FEATURES_32:
202 return "FFA_FEATURES_32";
203 case FFA_RX_RELEASE_32:
204 return "FFA_RX_RELEASE_32";
205 case FFA_RXTX_MAP_32:
206 return "FFA_RXTX_MAP_32";
207 case FFA_RXTX_MAP_64:
208 return "FFA_RXTX_MAP_64";
209 case FFA_RXTX_UNMAP_32:
210 return "FFA_RXTX_UNMAP_32";
211 case FFA_PARTITION_INFO_GET_32:
212 return "FFA_PARTITION_INFO_GET_32";
213 case FFA_ID_GET_32:
214 return "FFA_ID_GET_32";
215 case FFA_MSG_POLL_32:
216 return "FFA_MSG_POLL_32";
217 case FFA_MSG_WAIT_32:
218 return "FFA_MSG_WAIT_32";
219 case FFA_YIELD_32:
220 return "FFA_YIELD_32";
221 case FFA_RUN_32:
222 return "FFA_RUN_32";
223 case FFA_MSG_SEND_32:
224 return "FFA_MSG_SEND_32";
225 case FFA_MSG_SEND_DIRECT_REQ_32:
226 return "FFA_MSG_SEND_DIRECT_REQ_32";
227 case FFA_MSG_SEND_DIRECT_REQ_64:
228 return "FFA_MSG_SEND_DIRECT_REQ_64";
229 case FFA_MSG_SEND_DIRECT_RESP_32:
230 return "FFA_MSG_SEND_DIRECT_RESP_32";
231 case FFA_MSG_SEND_DIRECT_RESP_64:
232 return "FFA_MSG_SEND_DIRECT_RESP_64";
233 case FFA_MEM_DONATE_32:
234 return "FFA_MEM_DONATE_32";
235 case FFA_MEM_LEND_32:
236 return "FFA_MEM_LEND_32";
237 case FFA_MEM_SHARE_32:
238 return "FFA_MEM_SHARE_32";
239 case FFA_MEM_RETRIEVE_REQ_32:
240 return "FFA_MEM_RETRIEVE_REQ_32";
J-Alves95fbb312024-03-20 15:19:16 +0000241 case FFA_MEM_DONATE_64:
242 return "FFA_MEM_DONATE_64";
243 case FFA_MEM_LEND_64:
244 return "FFA_MEM_LEND_64";
245 case FFA_MEM_SHARE_64:
246 return "FFA_MEM_SHARE_64";
247 case FFA_MEM_RETRIEVE_REQ_64:
248 return "FFA_MEM_RETRIEVE_REQ_64";
Karl Meakinf51a35f2023-08-07 17:53:52 +0100249 case FFA_MEM_RETRIEVE_RESP_32:
250 return "FFA_MEM_RETRIEVE_RESP_32";
251 case FFA_MEM_RELINQUISH_32:
252 return "FFA_MEM_RELINQUISH_32";
253 case FFA_MEM_RECLAIM_32:
254 return "FFA_MEM_RECLAIM_32";
255 case FFA_MEM_FRAG_RX_32:
256 return "FFA_MEM_FRAG_RX_32";
257 case FFA_MEM_FRAG_TX_32:
258 return "FFA_MEM_FRAG_TX_32";
259 case FFA_NORMAL_WORLD_RESUME:
260 return "FFA_NORMAL_WORLD_RESUME";
261
262 /* FF-A v1.1 */
263 case FFA_NOTIFICATION_BITMAP_CREATE_32:
264 return "FFA_NOTIFICATION_BITMAP_CREATE_32";
265 case FFA_NOTIFICATION_BITMAP_DESTROY_32:
266 return "FFA_NOTIFICATION_BITMAP_DESTROY_32";
267 case FFA_NOTIFICATION_BIND_32:
268 return "FFA_NOTIFICATION_BIND_32";
269 case FFA_NOTIFICATION_UNBIND_32:
270 return "FFA_NOTIFICATION_UNBIND_32";
271 case FFA_NOTIFICATION_SET_32:
272 return "FFA_NOTIFICATION_SET_32";
273 case FFA_NOTIFICATION_GET_32:
274 return "FFA_NOTIFICATION_GET_32";
275 case FFA_NOTIFICATION_INFO_GET_64:
276 return "FFA_NOTIFICATION_INFO_GET_64";
277 case FFA_RX_ACQUIRE_32:
278 return "FFA_RX_ACQUIRE_32";
279 case FFA_SPM_ID_GET_32:
280 return "FFA_SPM_ID_GET_32";
281 case FFA_MSG_SEND2_32:
282 return "FFA_MSG_SEND2_32";
283 case FFA_SECONDARY_EP_REGISTER_64:
284 return "FFA_SECONDARY_EP_REGISTER_64";
285 case FFA_MEM_PERM_GET_32:
286 return "FFA_MEM_PERM_GET_32";
287 case FFA_MEM_PERM_SET_32:
288 return "FFA_MEM_PERM_SET_32";
289 case FFA_MEM_PERM_GET_64:
290 return "FFA_MEM_PERM_GET_64";
291 case FFA_MEM_PERM_SET_64:
292 return "FFA_MEM_PERM_SET_64";
293
294 /* Implementation-defined ABIs. */
295 case FFA_CONSOLE_LOG_32:
296 return "FFA_CONSOLE_LOG_32";
297 case FFA_CONSOLE_LOG_64:
298 return "FFA_CONSOLE_LOG_64";
299 case FFA_PARTITION_INFO_GET_REGS_64:
300 return "FFA_PARTITION_INFO_GET_REGS_64";
301 case FFA_EL3_INTR_HANDLE_32:
302 return "FFA_EL3_INTR_HANDLE_32";
Karl Meakinadf6daf2025-03-19 15:29:31 +0000303 case FFA_MSG_SEND_DIRECT_REQ2_64:
304 return "FFA_MSG_SEND_DIRECT_REQ2_64";
305 case FFA_MSG_SEND_DIRECT_RESP2_64:
306 return "FFA_MSG_SEND_DIRECT_REQ2_64 ";
Madhukar Pappireddy04cf9e82025-03-17 17:32:02 -0500307 case FFA_ABORT_32:
308 return "FFA_ABORT_32";
309 case FFA_ABORT_64:
310 return "FFA_ABORT_64";
Karl Meakinf51a35f2023-08-07 17:53:52 +0100311 }
Karl Meakinadf6daf2025-03-19 15:29:31 +0000312 return "UNKNOWN";
Karl Meakinf51a35f2023-08-07 17:53:52 +0100313}
314
315/* Return the name of the error code. */
Karl Meakindc759f52024-05-07 16:08:02 +0100316static inline const char *ffa_error_name(enum ffa_error error)
Karl Meakinf51a35f2023-08-07 17:53:52 +0100317{
318 switch (error) {
319 case FFA_NOT_SUPPORTED:
320 return "FFA_NOT_SUPPORTED";
321 case FFA_INVALID_PARAMETERS:
322 return "FFA_INVALID_PARAMETERS";
323 case FFA_NO_MEMORY:
324 return "FFA_NO_MEMORY";
325 case FFA_BUSY:
326 return "FFA_BUSY";
327 case FFA_INTERRUPTED:
328 return "FFA_INTERRUPTED";
329 case FFA_DENIED:
330 return "FFA_DENIED";
331 case FFA_RETRY:
332 return "FFA_RETRY";
333 case FFA_ABORTED:
334 return "FFA_ABORTED";
335 case FFA_NO_DATA:
336 return "FFA_NO_DATA";
Karl Meakindc759f52024-05-07 16:08:02 +0100337 case FFA_NOT_READY:
338 return "FFA_NOT_READY";
Karl Meakinf51a35f2023-08-07 17:53:52 +0100339 }
Karl Meakindc759f52024-05-07 16:08:02 +0100340 return "UNKNOWN";
Karl Meakinf51a35f2023-08-07 17:53:52 +0100341}
342
J-Alves6f72ca82021-11-01 12:34:58 +0000343/**
Karl Meakin49ec1e42024-05-10 13:08:24 +0100344 * Defined in Table 3.1 in the FF-A v.1.2 memory management supplement.
345 * Input properties:
346 * - Bits[31:2] and Bit[0] are reserved (SBZ).
347 * Output properties:
348 * - Bit[0]: dynamically allocated buffer support.
349 * - Bit[1]: NS bit handling.
350 * - Bit[2]: support for retrieval by hypervisor.
351 * - Bits[31:3] are reserved (MBZ).
J-Alves6f72ca82021-11-01 12:34:58 +0000352 */
Karl Meakin49ec1e42024-05-10 13:08:24 +0100353#define FFA_FEATURES_MEM_RETRIEVE_REQ_BUFFER_SUPPORT (0U << 0U)
354#define FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT (1U << 1U)
355#define FFA_FEATURES_MEM_RETRIEVE_REQ_HYPERVISOR_SUPPORT (1U << 2U)
J-Alves6f72ca82021-11-01 12:34:58 +0000356
Karl Meakin49ec1e42024-05-10 13:08:24 +0100357#define FFA_FEATURES_MEM_RETRIEVE_REQ_MBZ_HI_BIT (31U)
358#define FFA_FEATURES_MEM_RETRIEVE_REQ_MBZ_LO_BIT (2U)
359#define FFA_FEATURES_MEM_RETRIEVE_REQ_MBZ_BIT (0U)
J-Alves6f72ca82021-11-01 12:34:58 +0000360
Karl Meakin0dba87e2025-03-24 17:36:04 +0000361enum ffa_feature_id : uint32_t {
Karl Meakin49ec1e42024-05-10 13:08:24 +0100362 /* Query interrupt ID of Notification Pending Interrupt. */
363 FFA_FEATURE_NPI = 1,
Karl Meakin34b8ae92023-01-13 13:33:07 +0000364
Karl Meakin49ec1e42024-05-10 13:08:24 +0100365 /* Query interrupt ID of Schedule Receiver Interrupt. */
366 FFA_FEATURE_SRI = 2,
J-Alves6f72ca82021-11-01 12:34:58 +0000367
Karl Meakin49ec1e42024-05-10 13:08:24 +0100368 /* Query interrupt ID of the Managed Exit Interrupt. */
369 FFA_FEATURE_MEI = 3,
370};
J-Alves6f72ca82021-11-01 12:34:58 +0000371
Karl Meakin49ec1e42024-05-10 13:08:24 +0100372/** Constants for bitmasks used in FFA_FEATURES. */
373#define FFA_FEATURES_FEATURE_BIT (31U)
374#define FFA_FEATURES_FEATURE_MBZ_HI_BIT (30U)
375#define FFA_FEATURES_FEATURE_MBZ_LO_BIT (8U)
376
377#define FFA_FEATURES_NS_SUPPORT_BIT (1U)
J-Alves6f72ca82021-11-01 12:34:58 +0000378
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100379/* FF-A function specific constants. */
380#define FFA_MSG_RECV_BLOCK 0x1
381#define FFA_MSG_RECV_BLOCK_MASK 0x1
382
383#define FFA_MSG_SEND_NOTIFY 0x1
384#define FFA_MSG_SEND_NOTIFY_MASK 0x1
385
386#define FFA_MEM_RECLAIM_CLEAR 0x1
387
388#define FFA_SLEEP_INDEFINITE 0
389
Karl Meakin80220052025-02-20 14:43:34 +0000390/*
391 * The type of memory permissions used by `FFA_MEM_PERM_GET` and
392 * `FFA_MEM_PERM_SET`.
393 */
Karl Meakin0dba87e2025-03-24 17:36:04 +0000394enum ffa_mem_perm : uint32_t {
Karl Meakin80220052025-02-20 14:43:34 +0000395 FFA_MEM_PERM_RO = 0x7,
396 FFA_MEM_PERM_RW = 0x5,
397 FFA_MEM_PERM_RX = 0x3,
398};
Raghu Krishnamurthyea6d25f2021-09-14 15:27:06 -0700399
Kathleen Capella7253bd52024-08-14 17:36:09 -0400400#define FFA_MSG_WAIT_FLAG_RETAIN_RX UINT32_C(0x1)
Daniel Boulbyb46cad12021-12-13 17:47:21 +0000401/*
Olivier Deprez013f4d62022-11-21 15:46:20 +0100402 * Defined in Table 13.34 in the FF-A v1.1 EAC0 specification.
Daniel Boulbyb46cad12021-12-13 17:47:21 +0000403 * The Partition count flag is used by FFA_PARTITION_INFO_GET to specify
404 * if partition info descriptors should be returned or just the count.
405 */
Olivier Deprez013f4d62022-11-21 15:46:20 +0100406#define FFA_PARTITION_COUNT_FLAG UINT32_C(0x1)
407#define FFA_PARTITION_COUNT_FLAG_MASK (UINT32_C(0x1) << 0)
Daniel Boulbyb46cad12021-12-13 17:47:21 +0000408
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100409/**
410 * For use where the FF-A specification refers explicitly to '4K pages'. Not to
411 * be confused with PAGE_SIZE, which is the translation granule Hafnium is
412 * configured to use.
413 */
J-Alves715d6232023-02-16 16:33:28 +0000414#define FFA_PAGE_SIZE ((size_t)4096)
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100415
Federico Recanatifc0295e2022-02-08 19:37:39 +0100416/** The ID of a VM. These are assigned sequentially starting with an offset. */
J-Alves19e20cf2023-08-02 12:48:55 +0100417typedef uint16_t ffa_id_t;
Federico Recanatifc0295e2022-02-08 19:37:39 +0100418
419/**
J-Alves661e1b72023-08-02 13:39:40 +0100420 * The FF-A v1.2 ALP0, section 6.1 defines that partition IDs are split into two
421 * parts:
422 * - Bit15 -> partition type identifier.
423 * - b'0 -> ID relates to a VM ID.
424 * - b'1 -> ID relates to an SP ID.
425 */
426#define FFA_ID_MASK ((ffa_id_t)0x8000)
427#define FFA_VM_ID_MASK ((ffa_id_t)0x0000)
428
429/**
430 * Helper to check if FF-A ID is a VM ID, managed by the hypervisor.
431 */
432static inline bool ffa_is_vm_id(ffa_id_t id)
433{
434 return (FFA_ID_MASK & id) == FFA_VM_ID_MASK;
435}
436
437/**
Karl Meakinc88c8e92024-11-29 16:13:55 +0000438 * Holds the UUID in a struct that is mappable directly to the SMCC calling
439 * convention, which is used for FF-A calls.
440 *
441 * Refer to table 84 of the FF-A 1.0 EAC specification as well as section 5.3
442 * of the SMCC Spec 1.2.
443 */
444struct ffa_uuid {
445 uint32_t uuid[4];
446};
447
448static inline void ffa_uuid_init(uint32_t w0, uint32_t w1, uint32_t w2,
449 uint32_t w3, struct ffa_uuid *uuid)
450{
451 uuid->uuid[0] = w0;
452 uuid->uuid[1] = w1;
453 uuid->uuid[2] = w2;
454 uuid->uuid[3] = w3;
455}
456
457static inline bool ffa_uuid_equal(const struct ffa_uuid *uuid1,
458 const struct ffa_uuid *uuid2)
459{
460 return (uuid1->uuid[0] == uuid2->uuid[0]) &&
461 (uuid1->uuid[1] == uuid2->uuid[1]) &&
462 (uuid1->uuid[2] == uuid2->uuid[2]) &&
463 (uuid1->uuid[3] == uuid2->uuid[3]);
464}
465
466static inline bool ffa_uuid_is_null(const struct ffa_uuid *uuid)
467{
468 struct ffa_uuid null = {0};
469
470 return ffa_uuid_equal(uuid, &null);
471}
472
473static inline void ffa_uuid_from_u64x2(uint64_t uuid_lo, uint64_t uuid_hi,
474 struct ffa_uuid *uuid)
475{
476 ffa_uuid_init((uint32_t)(uuid_lo & 0xFFFFFFFFU),
477 (uint32_t)(uuid_lo >> 32),
478 (uint32_t)(uuid_hi & 0xFFFFFFFFU),
479 (uint32_t)(uuid_hi >> 32), uuid);
480}
481
482/**
483 * Split `uuid` into two u64s.
484 * This function writes to pointer parameters because C does not allow returning
485 * arrays from functions.
486 */
487static inline void ffa_uuid_to_u64x2(uint64_t *lo, uint64_t *hi,
488 const struct ffa_uuid *uuid)
489{
490 *lo = (uint64_t)uuid->uuid[1] << 32 | uuid->uuid[0];
491 *hi = (uint64_t)uuid->uuid[3] << 32 | uuid->uuid[2];
492}
493
494/**
495 * Partition message header as specified by table 7.1 from FF-A v1.3 ALP0
Federico Recanatifc0295e2022-02-08 19:37:39 +0100496 * specification.
497 */
498struct ffa_partition_rxtx_header {
Karl Meakinbf580c22024-12-12 14:31:06 +0000499 /* Reserved (SBZ). */
500 uint32_t flags;
501 /* Reserved (SBZ). */
502 uint32_t reserved_1;
Federico Recanatifc0295e2022-02-08 19:37:39 +0100503 /* Offset from the beginning of the buffer to the message payload. */
504 uint32_t offset;
Karl Meakin9ca05512024-11-29 17:02:32 +0000505 /* Receiver endpoint ID. */
506 ffa_id_t receiver;
507 /* Sender endpoint ID. */
508 ffa_id_t sender;
Federico Recanatifc0295e2022-02-08 19:37:39 +0100509 /* Size of message in buffer. */
510 uint32_t size;
Karl Meakinbf580c22024-12-12 14:31:06 +0000511 /* Reserved (SBZ). Added in v1.2. */
512 uint32_t reserved_2;
513 /* UUID identifying the communication protocol. Added in v1.2. */
514 struct ffa_uuid uuid;
Federico Recanatifc0295e2022-02-08 19:37:39 +0100515};
516
Karl Meakinbf580c22024-12-12 14:31:06 +0000517#define FFA_RXTX_HEADER_SIZE_V1_1 \
518 offsetof(struct ffa_partition_rxtx_header, reserved_2)
Federico Recanatifc0295e2022-02-08 19:37:39 +0100519#define FFA_RXTX_HEADER_SIZE sizeof(struct ffa_partition_rxtx_header)
J-Alves70079932022-12-07 17:32:20 +0000520#define FFA_RXTX_ALLOCATOR_SHIFT 16
Federico Recanatifc0295e2022-02-08 19:37:39 +0100521
Karl Meakin895007c2025-01-13 15:48:07 +0000522/**
Karl Meakinbf580c22024-12-12 14:31:06 +0000523 * Initialize a partition message header, with the default values for `flags`,
524 * `offset` and `uuid` and the v1.1 payload offset.
525 */
526static inline void ffa_rxtx_header_init_v1_1(
527 struct ffa_partition_rxtx_header *header, ffa_id_t sender,
528 ffa_id_t receiver, uint32_t payload_size)
529{
530 header->flags = 0;
531 header->reserved_1 = 0;
532 header->offset = FFA_RXTX_HEADER_SIZE_V1_1;
533 header->sender = sender;
534 header->receiver = receiver;
535 header->size = payload_size;
536 header->reserved_2 = 0;
537 header->uuid = (struct ffa_uuid){0};
538}
539
540/**
541 * Initialize a partition message header, with the default values for `flags`,
542 * `offset` and `uuid`.
Karl Meakin895007c2025-01-13 15:48:07 +0000543 */
Federico Recanatifc0295e2022-02-08 19:37:39 +0100544static inline void ffa_rxtx_header_init(
Karl Meakin895007c2025-01-13 15:48:07 +0000545 struct ffa_partition_rxtx_header *header, ffa_id_t sender,
546 ffa_id_t receiver, uint32_t payload_size)
Federico Recanatifc0295e2022-02-08 19:37:39 +0100547{
548 header->flags = 0;
Karl Meakinbf580c22024-12-12 14:31:06 +0000549 header->reserved_1 = 0;
Federico Recanatifc0295e2022-02-08 19:37:39 +0100550 header->offset = FFA_RXTX_HEADER_SIZE;
Karl Meakin9ca05512024-11-29 17:02:32 +0000551 header->sender = sender;
552 header->receiver = receiver;
Karl Meakin895007c2025-01-13 15:48:07 +0000553 header->size = payload_size;
Karl Meakinbf580c22024-12-12 14:31:06 +0000554 header->reserved_2 = 0;
555 header->uuid = (struct ffa_uuid){0};
556}
557
558/**
559 * Initialize a partition message header, with the default values for `flags`
560 * and `offset`.
561 */
562static inline void ffa_rxtx_header_init_with_uuid(
563 struct ffa_partition_rxtx_header *header, ffa_id_t sender,
564 ffa_id_t receiver, uint32_t size, struct ffa_uuid uuid)
565{
566 header->flags = 0;
567 header->reserved_1 = 0;
568 header->offset = FFA_RXTX_HEADER_SIZE;
569 header->sender = sender;
570 header->receiver = receiver;
571 header->size = size;
572 header->reserved_2 = 0;
573 header->uuid = uuid;
Federico Recanatifc0295e2022-02-08 19:37:39 +0100574}
575
Federico Recanatifc0295e2022-02-08 19:37:39 +0100576/* The maximum length possible for a single message. */
Karl Meakinbf580c22024-12-12 14:31:06 +0000577#define FFA_PARTITION_MSG_PAYLOAD_MAX_V1_1 \
578 (HF_MAILBOX_SIZE - FFA_RXTX_HEADER_SIZE_V1_1)
Federico Recanatifc0295e2022-02-08 19:37:39 +0100579#define FFA_PARTITION_MSG_PAYLOAD_MAX (HF_MAILBOX_SIZE - FFA_RXTX_HEADER_SIZE)
580
581struct ffa_partition_msg {
582 struct ffa_partition_rxtx_header header;
Karl Meakinbf580c22024-12-12 14:31:06 +0000583 /**
584 * Prefer using `ffa_partition_msg_payload` to accessing this field
585 * directly, because the offset does not necessarily correspond to the
586 * offset of this field.
587 */
Federico Recanatifc0295e2022-02-08 19:37:39 +0100588 char payload[FFA_PARTITION_MSG_PAYLOAD_MAX];
589};
590
Karl Meakinbf580c22024-12-12 14:31:06 +0000591static_assert(sizeof(struct ffa_partition_msg) == HF_MAILBOX_SIZE,
592 "FF-A message size must match mailbox size");
593
Karl Meakin891eb882025-01-17 19:11:20 +0000594/**
595 * Get the partition message's payload, according to the header's `offset`
596 * field.
597 */
598static inline void *ffa_partition_msg_payload(struct ffa_partition_msg *msg)
599{
600 return (char *)msg + msg->header.offset;
601}
602
603static inline const void *ffa_partition_msg_payload_const(
604 const struct ffa_partition_msg *msg)
605{
606 return (const char *)msg + msg->header.offset;
607}
608
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100609/* The maximum length possible for a single message. */
610#define FFA_MSG_PAYLOAD_MAX HF_MAILBOX_SIZE
611
Karl Meakin0dba87e2025-03-24 17:36:04 +0000612enum ffa_data_access : uint8_t {
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100613 FFA_DATA_ACCESS_NOT_SPECIFIED,
614 FFA_DATA_ACCESS_RO,
615 FFA_DATA_ACCESS_RW,
616 FFA_DATA_ACCESS_RESERVED,
617};
618
Karl Meakinf98b2aa2023-10-12 16:09:59 +0100619static inline const char *ffa_data_access_name(enum ffa_data_access data_access)
620{
621 switch (data_access) {
622 case FFA_DATA_ACCESS_NOT_SPECIFIED:
623 return "FFA_DATA_ACCESS_NOT_SPECIFIED";
624 case FFA_DATA_ACCESS_RO:
625 return "FFA_DATA_ACCESS_RO";
626 case FFA_DATA_ACCESS_RW:
627 return "FFA_DATA_ACCESS_RW";
628 case FFA_DATA_ACCESS_RESERVED:
629 return "FFA_DATA_ACCESS_RESERVED";
630 }
631}
632
Karl Meakin0dba87e2025-03-24 17:36:04 +0000633enum ffa_instruction_access : uint8_t {
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100634 FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
635 FFA_INSTRUCTION_ACCESS_NX,
636 FFA_INSTRUCTION_ACCESS_X,
637 FFA_INSTRUCTION_ACCESS_RESERVED,
638};
639
Karl Meakinf98b2aa2023-10-12 16:09:59 +0100640static inline const char *ffa_instruction_access_name(
641 enum ffa_instruction_access instruction_access)
642{
643 switch (instruction_access) {
644 case FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED:
645 return "FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED";
646 case FFA_INSTRUCTION_ACCESS_NX:
647 return "FFA_INSTRUCTION_ACCESS_NX";
648 case FFA_INSTRUCTION_ACCESS_X:
649 return "FFA_INSTRUCTION_ACCESS_X";
650 case FFA_INSTRUCTION_ACCESS_RESERVED:
651 return "FFA_INSTRUCTION_ACCESS_RESERVED";
652 }
653}
654
Karl Meakin0dba87e2025-03-24 17:36:04 +0000655enum ffa_memory_type : uint8_t {
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100656 FFA_MEMORY_NOT_SPECIFIED_MEM,
657 FFA_MEMORY_DEVICE_MEM,
658 FFA_MEMORY_NORMAL_MEM,
659};
660
Karl Meakinf98b2aa2023-10-12 16:09:59 +0100661static inline const char *ffa_memory_type_name(enum ffa_memory_type type)
662{
663 switch (type) {
664 case FFA_MEMORY_NOT_SPECIFIED_MEM:
665 return "FFA_MEMORY_NOT_SPECIFIED_MEM";
666 case FFA_MEMORY_DEVICE_MEM:
667 return "FFA_MEMORY_DEVICE_MEM";
668 case FFA_MEMORY_NORMAL_MEM:
669 return "FFA_MEMORY_NORMAL_MEM";
670 }
671}
672
Karl Meakin0dba87e2025-03-24 17:36:04 +0000673enum ffa_memory_cacheability : uint8_t {
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100674 FFA_MEMORY_CACHE_RESERVED = 0x0,
675 FFA_MEMORY_CACHE_NON_CACHEABLE = 0x1,
676 FFA_MEMORY_CACHE_RESERVED_1 = 0x2,
677 FFA_MEMORY_CACHE_WRITE_BACK = 0x3,
678 FFA_MEMORY_DEV_NGNRNE = 0x0,
679 FFA_MEMORY_DEV_NGNRE = 0x1,
680 FFA_MEMORY_DEV_NGRE = 0x2,
681 FFA_MEMORY_DEV_GRE = 0x3,
682};
683
Karl Meakinf98b2aa2023-10-12 16:09:59 +0100684static inline const char *ffa_memory_cacheability_name(
685 enum ffa_memory_cacheability cacheability)
686{
687 switch (cacheability) {
688 case FFA_MEMORY_CACHE_RESERVED:
689 return "FFA_MEMORY_CACHE_RESERVED";
690 case FFA_MEMORY_CACHE_NON_CACHEABLE:
691 return "FFA_MEMORY_CACHE_NON_CACHEABLE";
692 case FFA_MEMORY_CACHE_RESERVED_1:
693 return "FFA_MEMORY_CACHE_RESERVED_1";
694 case FFA_MEMORY_CACHE_WRITE_BACK:
695 return "FFA_MEMORY_CACHE_WRITE_BACK";
696 }
697}
698
Daniel Boulby9764ff62024-01-30 17:47:39 +0000699static inline const char *ffa_device_memory_cacheability_name(
700 enum ffa_memory_cacheability cacheability)
701{
702 switch (cacheability) {
703 case FFA_MEMORY_DEV_NGNRNE:
704 return "FFA_MEMORY_DEV_NGNRNE";
705 case FFA_MEMORY_DEV_NGNRE:
706 return "FFA_MEMORY_DEV_NGNRE";
707 case FFA_MEMORY_DEV_NGRE:
708 return "FFA_MEMORY_DEV_NGRE";
709 case FFA_MEMORY_DEV_GRE:
710 return "FFA_MEMORY_DEV_GRE";
711 }
712}
713
Karl Meakin0dba87e2025-03-24 17:36:04 +0000714enum ffa_memory_shareability : uint8_t {
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100715 FFA_MEMORY_SHARE_NON_SHAREABLE,
716 FFA_MEMORY_SHARE_RESERVED,
717 FFA_MEMORY_OUTER_SHAREABLE,
718 FFA_MEMORY_INNER_SHAREABLE,
719};
720
Karl Meakinf98b2aa2023-10-12 16:09:59 +0100721static inline const char *ffa_memory_shareability_name(
722 enum ffa_memory_shareability shareability)
723{
724 switch (shareability) {
725 case FFA_MEMORY_SHARE_NON_SHAREABLE:
726 return "FFA_MEMORY_SHARE_NON_SHAREABLE";
727 case FFA_MEMORY_SHARE_RESERVED:
728 return "FFA_MEMORY_SHARE_RESERVED";
729 case FFA_MEMORY_OUTER_SHAREABLE:
730 return "FFA_MEMORY_OUTER_SHAREABLE";
731 case FFA_MEMORY_INNER_SHAREABLE:
732 return "FFA_MEMORY_INNER_SHAREABLE";
733 }
734}
735
Olivier Deprez4342a3c2022-02-28 09:37:25 +0100736/**
737 * FF-A v1.1 REL0 Table 10.18 memory region attributes descriptor NS Bit 6.
738 * Per section 10.10.4.1, NS bit is reserved for FFA_MEM_DONATE/LEND/SHARE
739 * and FFA_MEM_RETRIEVE_REQUEST.
740 */
Karl Meakin0dba87e2025-03-24 17:36:04 +0000741enum ffa_memory_security : uint8_t {
Olivier Deprez4342a3c2022-02-28 09:37:25 +0100742 FFA_MEMORY_SECURITY_UNSPECIFIED = 0,
743 FFA_MEMORY_SECURITY_SECURE = 0,
744 FFA_MEMORY_SECURITY_NON_SECURE,
745};
746
Karl Meakinf98b2aa2023-10-12 16:09:59 +0100747static inline const char *ffa_memory_security_name(
748 enum ffa_memory_security security)
749{
750 switch (security) {
751 case FFA_MEMORY_SECURITY_UNSPECIFIED:
752 return "FFA_MEMORY_SECURITY_UNSPECIFIED";
753 case FFA_MEMORY_SECURITY_NON_SECURE:
754 return "FFA_MEMORY_SECURITY_NON_SECURE";
755 }
756}
757
Karl Meakin84710f32023-10-12 15:14:49 +0100758typedef struct {
Karl Meakin0dba87e2025-03-24 17:36:04 +0000759 enum ffa_data_access data_access : 2;
760 enum ffa_instruction_access instruction_access : 2;
Karl Meakin84710f32023-10-12 15:14:49 +0100761} ffa_memory_access_permissions_t;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100762
Karl Meakin0dba87e2025-03-24 17:36:04 +0000763static_assert(sizeof(ffa_memory_access_permissions_t) == sizeof(uint8_t),
764 "ffa_memory_access_permissions_t must be 8 bits wide");
765
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100766/**
J-Alves0b6653d2022-04-22 13:17:38 +0100767 * This corresponds to table 10.18 of the FF-A v1.1 EAC0 specification, "Memory
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100768 * region attributes descriptor".
769 */
Karl Meakin84710f32023-10-12 15:14:49 +0100770typedef struct {
Karl Meakin0dba87e2025-03-24 17:36:04 +0000771 enum ffa_memory_shareability shareability : 2;
772 enum ffa_memory_cacheability cacheability : 2;
773 enum ffa_memory_type type : 2;
774 enum ffa_memory_security security : 2;
Karl Meakin84710f32023-10-12 15:14:49 +0100775 uint8_t : 8;
776} ffa_memory_attributes_t;
J-Alves0b6653d2022-04-22 13:17:38 +0100777
Karl Meakin0dba87e2025-03-24 17:36:04 +0000778static_assert(sizeof(ffa_memory_attributes_t) == sizeof(uint16_t),
779 "ffa_memory_attributes_t must be 16 bits wide");
780
J-Alves0b6653d2022-04-22 13:17:38 +0100781/* FF-A v1.1 EAC0 states bit [15:7] Must Be Zero. */
782#define FFA_MEMORY_ATTRIBUTES_MBZ_MASK 0xFF80U
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100783
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100784/**
785 * A globally-unique ID assigned by the hypervisor for a region of memory being
786 * sent between VMs.
787 */
788typedef uint64_t ffa_memory_handle_t;
789
Karl Meakin1a760e72024-07-25 18:58:37 +0100790enum ffa_memory_handle_allocator {
791 FFA_MEMORY_HANDLE_ALLOCATOR_SPMC = 0,
792 FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR = 1,
793};
J-Alves917d2f22020-10-30 18:39:30 +0000794
Karl Meakin1a760e72024-07-25 18:58:37 +0100795#define FFA_MEMORY_HANDLE_ALLOCATOR_BIT UINT64_C(63)
796#define FFA_MEMORY_HANDLE_ALLOCATOR_MASK \
797 (UINT64_C(1) << FFA_MEMORY_HANDLE_ALLOCATOR_BIT)
J-Alves917d2f22020-10-30 18:39:30 +0000798#define FFA_MEMORY_HANDLE_INVALID (~UINT64_C(0))
799
Karl Meakin1a760e72024-07-25 18:58:37 +0100800static inline ffa_memory_handle_t ffa_memory_handle_make(
801 uint64_t index, enum ffa_memory_handle_allocator allocator)
802{
803 return index | ((uint64_t)allocator << FFA_MEMORY_HANDLE_ALLOCATOR_BIT);
804}
805
806static inline uint64_t ffa_memory_handle_index(ffa_memory_handle_t handle)
807{
808 return handle & ~FFA_MEMORY_HANDLE_ALLOCATOR_MASK;
809}
810
811static inline enum ffa_memory_handle_allocator ffa_memory_handle_allocator(
812 ffa_memory_handle_t handle)
813{
814 return ((handle & FFA_MEMORY_HANDLE_ALLOCATOR_MASK) != 0)
815 ? FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR
816 : FFA_MEMORY_HANDLE_ALLOCATOR_SPMC;
817}
818
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100819/**
820 * A count of VMs. This has the same range as the VM IDs but we give it a
821 * different name to make the different semantics clear.
822 */
J-Alves19e20cf2023-08-02 12:48:55 +0100823typedef ffa_id_t ffa_vm_count_t;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100824
825/** The index of a vCPU within a particular VM. */
826typedef uint16_t ffa_vcpu_index_t;
827
828/**
829 * A count of vCPUs. This has the same range as the vCPU indices but we give it
830 * a different name to make the different semantics clear.
831 */
832typedef ffa_vcpu_index_t ffa_vcpu_count_t;
833
834/** Parameter and return type of FF-A functions. */
835struct ffa_value {
836 uint64_t func;
837 uint64_t arg1;
838 uint64_t arg2;
839 uint64_t arg3;
840 uint64_t arg4;
841 uint64_t arg5;
842 uint64_t arg6;
843 uint64_t arg7;
Raghu Krishnamurthy567068e2022-12-26 07:46:38 -0800844
845 struct {
846 uint64_t arg8;
847 uint64_t arg9;
848 uint64_t arg10;
849 uint64_t arg11;
850 uint64_t arg12;
851 uint64_t arg13;
852 uint64_t arg14;
853 uint64_t arg15;
854 uint64_t arg16;
855 uint64_t arg17;
856 bool valid;
857 } extended_val;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100858};
859
Olivier Depreze562e542020-06-11 17:31:54 +0200860static inline uint32_t ffa_func_id(struct ffa_value args)
861{
862 return args.func;
863}
864
Karl Meakindc759f52024-05-07 16:08:02 +0100865static inline enum ffa_error ffa_error_code(struct ffa_value val)
J-Alves13318e32021-02-22 17:21:00 +0000866{
Karl Meakin66a38bd2024-05-28 16:00:56 +0100867 /* NOLINTNEXTLINE(EnumCastOutOfRange) */
Karl Meakindc759f52024-05-07 16:08:02 +0100868 return (enum ffa_error)val.arg2;
J-Alves13318e32021-02-22 17:21:00 +0000869}
870
J-Alves19e20cf2023-08-02 12:48:55 +0100871static inline ffa_id_t ffa_sender(struct ffa_value args)
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100872{
873 return (args.arg1 >> 16) & 0xffff;
874}
875
J-Alves19e20cf2023-08-02 12:48:55 +0100876static inline ffa_id_t ffa_receiver(struct ffa_value args)
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100877{
878 return args.arg1 & 0xffff;
879}
880
881static inline uint32_t ffa_msg_send_size(struct ffa_value args)
882{
883 return args.arg3;
884}
885
Federico Recanati25053ee2022-03-14 15:01:53 +0100886static inline uint32_t ffa_msg_send2_flags(struct ffa_value args)
887{
888 return args.arg2;
889}
890
Olivier Depreze562e542020-06-11 17:31:54 +0200891static inline uint32_t ffa_partition_info_get_count(struct ffa_value args)
892{
893 return args.arg2;
894}
895
Raghu Krishnamurthy2957b922022-12-27 10:29:12 -0800896static inline uint16_t ffa_partition_info_regs_get_last_idx(
897 struct ffa_value args)
898{
899 return args.arg2 & 0xFFFF;
900}
901
902static inline uint16_t ffa_partition_info_regs_get_curr_idx(
903 struct ffa_value args)
904{
905 return (args.arg2 >> 16) & 0xFFFF;
906}
907
908static inline uint16_t ffa_partition_info_regs_get_tag(struct ffa_value args)
909{
910 return (args.arg2 >> 32) & 0xFFFF;
911}
912
913static inline uint16_t ffa_partition_info_regs_get_desc_size(
914 struct ffa_value args)
915{
916 return (args.arg2 >> 48);
917}
918
Andrew Walbran1bbe9402020-04-30 16:47:13 +0100919static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t a1, uint32_t a2)
920{
921 return (uint64_t)a1 | (uint64_t)a2 << 32;
922}
923
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100924static inline ffa_memory_handle_t ffa_mem_success_handle(struct ffa_value args)
925{
Andrew Walbran1bbe9402020-04-30 16:47:13 +0100926 return ffa_assemble_handle(args.arg2, args.arg3);
927}
928
Andrew Walbranca808b12020-05-15 17:22:28 +0100929static inline ffa_memory_handle_t ffa_frag_handle(struct ffa_value args)
930{
931 return ffa_assemble_handle(args.arg1, args.arg2);
932}
933
Andrew Walbran1bbe9402020-04-30 16:47:13 +0100934static inline struct ffa_value ffa_mem_success(ffa_memory_handle_t handle)
935{
936 return (struct ffa_value){.func = FFA_SUCCESS_32,
937 .arg2 = (uint32_t)handle,
938 .arg3 = (uint32_t)(handle >> 32)};
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100939}
940
J-Alves19e20cf2023-08-02 12:48:55 +0100941static inline ffa_id_t ffa_vm_id(struct ffa_value args)
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100942{
943 return (args.arg1 >> 16) & 0xffff;
944}
945
946static inline ffa_vcpu_index_t ffa_vcpu_index(struct ffa_value args)
947{
948 return args.arg1 & 0xffff;
949}
950
J-Alves19e20cf2023-08-02 12:48:55 +0100951static inline uint64_t ffa_vm_vcpu(ffa_id_t vm_id, ffa_vcpu_index_t vcpu_index)
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100952{
953 return ((uint32_t)vm_id << 16) | vcpu_index;
954}
955
J-Alves19e20cf2023-08-02 12:48:55 +0100956static inline ffa_id_t ffa_frag_sender(struct ffa_value args)
Andrew Walbranca808b12020-05-15 17:22:28 +0100957{
958 return (args.arg4 >> 16) & 0xffff;
959}
960
J-Alves6f72ca82021-11-01 12:34:58 +0000961static inline uint32_t ffa_feature_intid(struct ffa_value args)
962{
963 return (uint32_t)args.arg2;
964}
965
Karl Meakind0356f82024-09-04 13:34:31 +0100966#define FFA_FRAMEWORK_MSG_BIT (UINT64_C(1) << 31)
967#define FFA_FRAMEWORK_MSG_FUNC_MASK UINT64_C(0xFF)
968
969/**
Madhukar Pappireddy8afab732025-02-10 09:39:36 -0600970 * Identifies FF-A framework messages. See sections 18.2 and 18.3 of v1.2 FF-A
Karl Meakind0356f82024-09-04 13:34:31 +0100971 * specification.
972 */
Karl Meakin0dba87e2025-03-24 17:36:04 +0000973enum ffa_framework_msg_func : uint32_t {
Madhukar Pappireddy8afab732025-02-10 09:39:36 -0600974 /* Power management framework messages. */
975 FFA_FRAMEWORK_MSG_PSCI_REQ = 0,
976 FFA_FRAMEWORK_MSG_PSCI_RESP = 2,
977
978 /* The VM availability messages. */
Karl Meakind0356f82024-09-04 13:34:31 +0100979 FFA_FRAMEWORK_MSG_VM_CREATION_REQ = 4,
980 FFA_FRAMEWORK_MSG_VM_CREATION_RESP = 5,
Karl Meakind0356f82024-09-04 13:34:31 +0100981 FFA_FRAMEWORK_MSG_VM_DESTRUCTION_REQ = 6,
982 FFA_FRAMEWORK_MSG_VM_DESTRUCTION_RESP = 7,
Madhukar Pappireddy8afab732025-02-10 09:39:36 -0600983
984 SPMD_FRAMEWORK_MSG_FFA_VERSION_REQ = 8,
985 SPMD_FRAMEWORK_MSG_FFA_VERSION_RESP = 9,
986
987 FFA_FRAMEWORK_MSG_INVALID = 0xFF,
Karl Meakind0356f82024-09-04 13:34:31 +0100988};
989
Karl Meakin06e8b732024-09-20 18:26:49 +0100990#define FFA_VM_AVAILABILITY_MESSAGE_SBZ_LO 16
991#define FFA_VM_AVAILABILITY_MESSAGE_SBZ_HI 31
992
Karl Meakind0356f82024-09-04 13:34:31 +0100993/** Get the `flags` field of a framework message */
994static inline uint32_t ffa_framework_msg_flags(struct ffa_value args)
Daniel Boulbyefa381f2022-01-18 14:49:40 +0000995{
996 return (uint32_t)args.arg2;
997}
998
Karl Meakind0356f82024-09-04 13:34:31 +0100999/** Is `args` a framework message? */
1000static inline bool ffa_is_framework_msg(struct ffa_value args)
1001{
Karl Meakin06e8b732024-09-20 18:26:49 +01001002 return (args.func != FFA_MSG_SEND_DIRECT_REQ2_64) &&
1003 (args.func != FFA_MSG_SEND_DIRECT_RESP2_64) &&
1004 ((ffa_framework_msg_flags(args) & FFA_FRAMEWORK_MSG_BIT) != 0);
Karl Meakind0356f82024-09-04 13:34:31 +01001005}
1006
Karl Meakina1a02352024-09-20 18:27:18 +01001007/**
1008 * Get the ID of the VM that has been created/destroyed from VM availability
1009 * message
1010 */
1011static inline ffa_id_t ffa_vm_availability_message_vm_id(struct ffa_value args)
1012{
1013 return args.arg5 & 0xFFFF;
1014}
1015
Karl Meakind0356f82024-09-04 13:34:31 +01001016/** Get the function ID from a framework message */
Madhukar Pappireddy984e99a2025-02-10 09:55:27 -06001017static inline uint32_t ffa_framework_msg_get_func(struct ffa_value args)
Karl Meakind0356f82024-09-04 13:34:31 +01001018{
1019 return ffa_framework_msg_flags(args) & FFA_FRAMEWORK_MSG_FUNC_MASK;
1020}
1021
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001022/**
Fuad Tabbae4efcc32020-07-16 15:37:27 +01001023 * Flags to determine the partition properties, as required by
1024 * FFA_PARTITION_INFO_GET.
1025 *
Kathleen Capellaf71dee42023-08-08 16:24:14 -04001026 * The values of the flags are specified in table 6.2 of DEN0077A FF-A 1.2 ALP0
Fuad Tabbae4efcc32020-07-16 15:37:27 +01001027 * specification, "Partition information descriptor, partition properties".
1028 */
1029typedef uint32_t ffa_partition_properties_t;
1030
Kathleen Capellaf71dee42023-08-08 16:24:14 -04001031/**
1032 * Partition property: partition supports receipt of direct requests via the
1033 * FFA_MSG_SEND_DIRECT_REQ ABI.
1034 */
Kathleen Capella402fa852022-11-09 16:16:51 -05001035#define FFA_PARTITION_DIRECT_REQ_RECV (UINT32_C(1) << 0)
Fuad Tabbae4efcc32020-07-16 15:37:27 +01001036
Kathleen Capellaf71dee42023-08-08 16:24:14 -04001037/**
1038 * Partition property: partition can send direct requests via the
1039 * FFA_MSG_SEND_DIRECT_REQ ABI.
1040 */
Kathleen Capella402fa852022-11-09 16:16:51 -05001041#define FFA_PARTITION_DIRECT_REQ_SEND (UINT32_C(1) << 1)
Fuad Tabbae4efcc32020-07-16 15:37:27 +01001042
1043/** Partition property: partition can send and receive indirect messages. */
Kathleen Capella402fa852022-11-09 16:16:51 -05001044#define FFA_PARTITION_INDIRECT_MSG (UINT32_C(1) << 2)
Fuad Tabbae4efcc32020-07-16 15:37:27 +01001045
J-Alves09ff9d82021-11-02 11:55:20 +00001046/** Partition property: partition can receive notifications. */
Kathleen Capella402fa852022-11-09 16:16:51 -05001047#define FFA_PARTITION_NOTIFICATION (UINT32_C(1) << 3)
1048
Karl Meakina603e082024-08-02 17:57:27 +01001049/**
1050 * Partition property: partition must be informed about each VM that is created
1051 * by the Hypervisor.
1052 */
1053#define FFA_PARTITION_VM_CREATED (UINT32_C(1) << 6)
1054
1055/**
1056 * Partition property: partition must be informed about each VM that is
1057 * destroyed by the Hypervisor.
1058 */
1059#define FFA_PARTITION_VM_DESTROYED (UINT32_C(1) << 7)
1060
Kathleen Capella402fa852022-11-09 16:16:51 -05001061/** Partition property: partition runs in the AArch64 execution state. */
1062#define FFA_PARTITION_AARCH64_EXEC (UINT32_C(1) << 8)
J-Alves09ff9d82021-11-02 11:55:20 +00001063
Fuad Tabbae4efcc32020-07-16 15:37:27 +01001064/**
Kathleen Capellaf71dee42023-08-08 16:24:14 -04001065 * Partition property: partition supports receipt of direct requests via the
1066 * FFA_MSG_SEND_DIRECT_REQ2 ABI.
1067 */
1068#define FFA_PARTITION_DIRECT_REQ2_RECV (UINT32_C(1) << 9)
1069
1070/**
1071 * Partition property: partition can send direct requests via the
1072 * FFA_MSG_SEND_DIRECT_REQ2 ABI.
1073 */
1074#define FFA_PARTITION_DIRECT_REQ2_SEND (UINT32_C(1) << 10)
1075
1076/**
Fuad Tabbae4efcc32020-07-16 15:37:27 +01001077 * Holds information returned for each partition by the FFA_PARTITION_INFO_GET
1078 * interface.
Kathleen Capella402fa852022-11-09 16:16:51 -05001079 * This corresponds to table 13.37 "Partition information descriptor"
1080 * in FF-A 1.1 EAC0 specification.
Daniel Boulby1ddb3d72021-12-16 18:16:50 +00001081 */
1082struct ffa_partition_info {
J-Alves19e20cf2023-08-02 12:48:55 +01001083 ffa_id_t vm_id;
Daniel Boulby1ddb3d72021-12-16 18:16:50 +00001084 ffa_vcpu_count_t vcpu_count;
1085 ffa_partition_properties_t properties;
1086 struct ffa_uuid uuid;
1087};
1088
J-Alvesdd1ad572022-01-25 17:58:26 +00001089/** Length in bytes of the name in boot information descriptor. */
1090#define FFA_BOOT_INFO_NAME_LEN 16
1091
J-Alves240d84c2022-04-22 12:19:34 +01001092/**
1093 * The FF-A boot info descriptor, as defined in table 5.8 of section 5.4.1, of
1094 * the FF-A v1.1 EAC0 specification.
1095 */
J-Alvesdd1ad572022-01-25 17:58:26 +00001096struct ffa_boot_info_desc {
1097 char name[FFA_BOOT_INFO_NAME_LEN];
1098 uint8_t type;
1099 uint8_t reserved;
1100 uint16_t flags;
1101 uint32_t size;
1102 uint64_t content;
1103};
1104
1105/** FF-A boot information type mask. */
1106#define FFA_BOOT_INFO_TYPE_SHIFT 7
1107#define FFA_BOOT_INFO_TYPE_MASK (0x1U << FFA_BOOT_INFO_TYPE_SHIFT)
1108#define FFA_BOOT_INFO_TYPE_STD 0U
1109#define FFA_BOOT_INFO_TYPE_IMPDEF 1U
1110
1111/** Standard boot info type IDs. */
1112#define FFA_BOOT_INFO_TYPE_ID_MASK 0x7FU
1113#define FFA_BOOT_INFO_TYPE_ID_FDT 0U
1114#define FFA_BOOT_INFO_TYPE_ID_HOB 1U
1115
1116/** FF-A Boot Info descriptors flags. */
1117#define FFA_BOOT_INFO_FLAG_MBZ_MASK 0xFFF0U
1118
1119/** Bits [1:0] encode the format of the name field in ffa_boot_info_desc. */
1120#define FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT 0U
1121#define FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK \
1122 (0x3U << FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT)
1123#define FFA_BOOT_INFO_FLAG_NAME_FORMAT_STRING 0x0U
1124#define FFA_BOOT_INFO_FLAG_NAME_FORMAT_UUID 0x1U
1125
1126/** Bits [3:2] encode the format of the content field in ffa_boot_info_desc. */
1127#define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT 2
1128#define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK \
1129 (0x3U << FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT)
1130#define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_VALUE 0x1U
1131#define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_ADDR 0x0U
1132
1133static inline uint16_t ffa_boot_info_content_format(
1134 struct ffa_boot_info_desc *desc)
1135{
1136 return (desc->flags & FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK) >>
1137 FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT;
1138}
1139
1140static inline uint16_t ffa_boot_info_name_format(
1141 struct ffa_boot_info_desc *desc)
1142{
1143 return (desc->flags & FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK) >>
1144 FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT;
1145}
1146
1147static inline uint8_t ffa_boot_info_type_id(struct ffa_boot_info_desc *desc)
1148{
1149 return desc->type & FFA_BOOT_INFO_TYPE_ID_MASK;
1150}
1151
1152static inline uint8_t ffa_boot_info_type(struct ffa_boot_info_desc *desc)
1153{
1154 return (desc->type & FFA_BOOT_INFO_TYPE_MASK) >>
1155 FFA_BOOT_INFO_TYPE_SHIFT;
1156}
1157
1158/** Length in bytes of the signature in the boot descriptor. */
1159#define FFA_BOOT_INFO_HEADER_SIGNATURE_LEN 4
1160
J-Alves240d84c2022-04-22 12:19:34 +01001161/**
1162 * The FF-A boot information header, as defined in table 5.9 of section 5.4.2,
1163 * of the FF-A v1.1 EAC0 specification.
1164 */
J-Alvesdd1ad572022-01-25 17:58:26 +00001165struct ffa_boot_info_header {
1166 uint32_t signature;
1167 uint32_t version;
1168 uint32_t info_blob_size;
1169 uint32_t desc_size;
1170 uint32_t desc_count;
1171 uint32_t desc_offset;
1172 uint64_t reserved;
1173 struct ffa_boot_info_desc boot_info[];
1174};
1175
Fuad Tabbae4efcc32020-07-16 15:37:27 +01001176/**
J-Alves980d1992021-03-18 12:49:18 +00001177 * FF-A v1.1 specification restricts the number of notifications to a maximum
1178 * of 64. Following all possible bitmaps.
1179 */
Karl Meakin2ad6b662024-07-29 20:45:40 +01001180#define FFA_NOTIFICATION_MASK(ID) (UINT64_C(1) << (ID))
J-Alves980d1992021-03-18 12:49:18 +00001181
1182typedef uint64_t ffa_notifications_bitmap_t;
1183
1184#define MAX_FFA_NOTIFICATIONS 64U
1185
1186/**
J-Alvesc003a7a2021-03-18 13:06:53 +00001187 * Flag for notification bind and set, to specify call is about per-vCPU
1188 * notifications.
1189 */
Olivier Deprezb76307d2022-06-09 17:17:45 +02001190#define FFA_NOTIFICATION_FLAG_PER_VCPU (UINT32_C(1) << 0)
J-Alvesc003a7a2021-03-18 13:06:53 +00001191
Federico Recanatie73d2832022-04-20 11:10:52 +02001192#define FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK FFA_NOTIFICATION_MASK(0)
1193#define FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK FFA_NOTIFICATION_MASK(32)
1194
1195/**
1196 * Helper functions to check for buffer full notification.
1197 */
1198static inline bool is_ffa_hyp_buffer_full_notification(
1199 ffa_notifications_bitmap_t framework)
1200{
1201 return (framework & FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK) != 0;
1202}
1203
1204static inline bool is_ffa_spm_buffer_full_notification(
1205 ffa_notifications_bitmap_t framework)
1206{
1207 return (framework & FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK) != 0;
1208}
1209
J-Alvesc003a7a2021-03-18 13:06:53 +00001210/**
J-Alves980d1992021-03-18 12:49:18 +00001211 * Helper function to assemble a 64-bit sized bitmap, from the 32-bit sized lo
1212 * and hi.
1213 * Helpful as FF-A specification defines that the notifications interfaces
1214 * arguments are 32-bit registers.
1215 */
1216static inline ffa_notifications_bitmap_t ffa_notifications_bitmap(uint32_t lo,
1217 uint32_t hi)
1218{
1219 return (ffa_notifications_bitmap_t)hi << 32U | lo;
1220}
1221
J-Alves98ff9562021-09-09 14:39:41 +01001222static inline ffa_notifications_bitmap_t ffa_notification_get_from_sp(
1223 struct ffa_value val)
1224{
1225 return ffa_notifications_bitmap((uint32_t)val.arg2, (uint32_t)val.arg3);
1226}
1227
1228static inline ffa_notifications_bitmap_t ffa_notification_get_from_vm(
1229 struct ffa_value val)
1230{
1231 return ffa_notifications_bitmap((uint32_t)val.arg4, (uint32_t)val.arg5);
1232}
1233
Federico Recanatie73d2832022-04-20 11:10:52 +02001234static inline ffa_notifications_bitmap_t ffa_notification_get_from_framework(
1235 struct ffa_value val)
1236{
1237 return ffa_notifications_bitmap((uint32_t)val.arg6, (uint32_t)val.arg7);
1238}
1239
Karl Meakinf9c73ce2024-07-30 17:37:13 +01001240typedef uint32_t ffa_notification_flags_t;
1241
1242/** Flags used in calls to FFA_NOTIFICATION_BIND interface. */
1243#define FFA_NOTIFICATIONS_FLAG_PER_VCPU (UINT32_C(1) << 0)
1244
1245/** Flags used in calls to FFA_NOTIFICATION_GET interface. */
Olivier Deprezb76307d2022-06-09 17:17:45 +02001246#define FFA_NOTIFICATION_FLAG_BITMAP_SP (UINT32_C(1) << 0)
1247#define FFA_NOTIFICATION_FLAG_BITMAP_VM (UINT32_C(1) << 1)
1248#define FFA_NOTIFICATION_FLAG_BITMAP_SPM (UINT32_C(1) << 2)
1249#define FFA_NOTIFICATION_FLAG_BITMAP_HYP (UINT32_C(1) << 3)
J-Alvesaa79c012021-07-09 14:29:45 +01001250
Karl Meakinf9c73ce2024-07-30 17:37:13 +01001251/** Flags used in calls to FFA_NOTIFICATION_SET interface. */
Olivier Deprezb76307d2022-06-09 17:17:45 +02001252#define FFA_NOTIFICATIONS_FLAG_PER_VCPU (UINT32_C(1) << 0)
Olivier Deprezb76307d2022-06-09 17:17:45 +02001253#define FFA_NOTIFICATIONS_FLAG_DELAY_SRI (UINT32_C(1) << 1)
Olivier Deprezb76307d2022-06-09 17:17:45 +02001254#define FFA_NOTIFICATIONS_FLAGS_VCPU_ID(id) \
1255 ((((uint32_t)(id)) & UINT32_C(0xffff)) << 16)
Karl Meakinf9c73ce2024-07-30 17:37:13 +01001256#define FFA_NOTIFICATIONS_FLAGS_GET_VCPU_ID(flags) \
1257 ((ffa_vcpu_index_t)((flags) >> 16))
J-Alves13394022021-06-30 13:48:49 +01001258
J-Alvesbe6e3032021-11-30 14:54:12 +00001259static inline ffa_vcpu_index_t ffa_notifications_get_vcpu(struct ffa_value args)
J-Alvesaa79c012021-07-09 14:29:45 +01001260{
Karl Meakinf9c73ce2024-07-30 17:37:13 +01001261 return FFA_NOTIFICATIONS_FLAGS_GET_VCPU_ID(args.arg1);
J-Alvesaa79c012021-07-09 14:29:45 +01001262}
1263
1264/**
J-Alvesc8e8a222021-06-08 17:33:52 +01001265 * The max number of IDs for return of FFA_NOTIFICATION_INFO_GET.
1266 */
1267#define FFA_NOTIFICATIONS_INFO_GET_MAX_IDS 20U
1268
1269/**
1270 * Number of registers to use in successfull return of interface
1271 * FFA_NOTIFICATION_INFO_GET.
1272 */
1273#define FFA_NOTIFICATIONS_INFO_GET_REGS_RET 5U
1274
1275#define FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING 0x1U
1276
1277/**
1278 * Helper macros for return parameter encoding as described in section 17.7.1
1279 * of the FF-A v1.1 Beta0 specification.
1280 */
1281#define FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT 0x7U
1282#define FFA_NOTIFICATIONS_LISTS_COUNT_MASK 0x1fU
Karl Meakin2ad6b662024-07-29 20:45:40 +01001283#define FFA_NOTIFICATIONS_LIST_SHIFT(l) (2 * ((l) - 1) + 12)
J-Alvesc8e8a222021-06-08 17:33:52 +01001284#define FFA_NOTIFICATIONS_LIST_SIZE_MASK 0x3U
Daniel Boulby1308a632024-09-11 15:19:16 +01001285#define FFA_NOTIFICATIONS_LIST_MAX_SIZE 0x4U
Daniel Boulbyedfdf282025-01-02 18:51:19 +00001286#define FFA_NOTIFICATIONS_LIST_MAX_VCPU_IDS \
1287 (FFA_NOTIFICATIONS_LIST_MAX_SIZE - 1)
J-Alvesc8e8a222021-06-08 17:33:52 +01001288
1289static inline uint32_t ffa_notification_info_get_lists_count(
1290 struct ffa_value args)
1291{
1292 return (uint32_t)(args.arg2 >> FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT) &
1293 FFA_NOTIFICATIONS_LISTS_COUNT_MASK;
1294}
1295
1296static inline uint32_t ffa_notification_info_get_list_size(
1297 struct ffa_value args, unsigned int list_idx)
1298{
1299 return ((uint32_t)args.arg2 >> FFA_NOTIFICATIONS_LIST_SHIFT(list_idx)) &
1300 FFA_NOTIFICATIONS_LIST_SIZE_MASK;
1301}
1302
1303static inline bool ffa_notification_info_get_more_pending(struct ffa_value args)
1304{
1305 return (args.arg2 & FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING) != 0U;
1306}
1307
Daniel Boulby1308a632024-09-11 15:19:16 +01001308void ffa_notification_info_get_and_check(
1309 const uint32_t expected_lists_count,
1310 const uint32_t *const expected_lists_sizes,
1311 const uint16_t *const expected_ids);
1312
J-Alvesc8e8a222021-06-08 17:33:52 +01001313/**
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001314 * A set of contiguous pages which is part of a memory region. This corresponds
J-Alves0b6653d2022-04-22 13:17:38 +01001315 * to table 10.14 of the FF-A v1.1 EAC0 specification, "Constituent memory
1316 * region descriptor".
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001317 */
1318struct ffa_memory_region_constituent {
1319 /**
1320 * The base IPA of the constituent memory region, aligned to 4 kiB page
1321 * size granularity.
1322 */
1323 uint64_t address;
1324 /** The number of 4 kiB pages in the constituent memory region. */
1325 uint32_t page_count;
1326 /** Reserved field, must be 0. */
1327 uint32_t reserved;
1328};
1329
1330/**
J-Alves0b6653d2022-04-22 13:17:38 +01001331 * A set of pages comprising a memory region. This corresponds to table 10.13 of
1332 * the FF-A v1.1 EAC0 specification, "Composite memory region descriptor".
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001333 */
1334struct ffa_composite_memory_region {
1335 /**
1336 * The total number of 4 kiB pages included in this memory region. This
1337 * must be equal to the sum of page counts specified in each
1338 * `ffa_memory_region_constituent`.
1339 */
1340 uint32_t page_count;
1341 /**
1342 * The number of constituents (`ffa_memory_region_constituent`)
1343 * included in this memory region range.
1344 */
1345 uint32_t constituent_count;
1346 /** Reserved field, must be 0. */
1347 uint64_t reserved_0;
1348 /** An array of `constituent_count` memory region constituents. */
1349 struct ffa_memory_region_constituent constituents[];
1350};
1351
1352/** Flags to indicate properties of receivers during memory region retrieval. */
1353typedef uint8_t ffa_memory_receiver_flags_t;
1354
1355/**
J-Alves0b6653d2022-04-22 13:17:38 +01001356 * This corresponds to table 10.15 of the FF-A v1.1 EAC0 specification, "Memory
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001357 * access permissions descriptor".
1358 */
1359struct ffa_memory_region_attributes {
1360 /** The ID of the VM to which the memory is being given or shared. */
J-Alves19e20cf2023-08-02 12:48:55 +01001361 ffa_id_t receiver;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001362 /**
1363 * The permissions with which the memory region should be mapped in the
1364 * receiver's page table.
1365 */
1366 ffa_memory_access_permissions_t permissions;
1367 /**
1368 * Flags used during FFA_MEM_RETRIEVE_REQ and FFA_MEM_RETRIEVE_RESP
1369 * for memory regions with multiple borrowers.
1370 */
1371 ffa_memory_receiver_flags_t flags;
1372};
1373
1374/** Flags to control the behaviour of a memory sharing transaction. */
1375typedef uint32_t ffa_memory_region_flags_t;
1376
1377/**
1378 * Clear memory region contents after unmapping it from the sender and before
1379 * mapping it for any receiver.
1380 */
1381#define FFA_MEMORY_REGION_FLAG_CLEAR 0x1
1382
1383/**
1384 * Whether the hypervisor may time slice the memory sharing or retrieval
1385 * operation.
1386 */
1387#define FFA_MEMORY_REGION_FLAG_TIME_SLICE 0x2
1388
1389/**
1390 * Whether the hypervisor should clear the memory region after the receiver
1391 * relinquishes it or is aborted.
1392 */
1393#define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH 0x4
1394
J-Alves3456e032023-07-20 12:20:05 +01001395/**
1396 * On retrieve request, bypass the multi-borrower check.
1397 */
1398#define FFA_MEMORY_REGION_FLAG_BYPASS_BORROWERS_CHECK (0x1U << 10)
1399
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001400#define FFA_MEMORY_REGION_TRANSACTION_TYPE_MASK ((0x3U) << 3)
1401#define FFA_MEMORY_REGION_TRANSACTION_TYPE_UNSPECIFIED ((0x0U) << 3)
1402#define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE ((0x1U) << 3)
1403#define FFA_MEMORY_REGION_TRANSACTION_TYPE_LEND ((0x2U) << 3)
1404#define FFA_MEMORY_REGION_TRANSACTION_TYPE_DONATE ((0x3U) << 3)
1405
Federico Recanati85090c42021-12-15 13:17:54 +01001406#define FFA_MEMORY_REGION_ADDRESS_RANGE_HINT_VALID ((0x1U) << 9)
1407#define FFA_MEMORY_REGION_ADDRESS_RANGE_HINT_MASK ((0xFU) << 5)
1408
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001409/**
Daniel Boulbyde974ca2023-12-12 13:53:31 +00001410 * Struct to store the impdef value seen in Table 11.16 of the
1411 * FF-A v1.2 ALP0 specification "Endpoint memory access descriptor".
1412 */
1413struct ffa_memory_access_impdef {
1414 uint64_t val[2];
1415};
1416
Daniel Boulbye0ca9a02024-03-05 18:40:59 +00001417static inline struct ffa_memory_access_impdef ffa_memory_access_impdef_init(
1418 uint64_t impdef_hi, uint64_t impdef_lo)
1419{
1420 return (struct ffa_memory_access_impdef){{impdef_hi, impdef_lo}};
1421}
1422
Daniel Boulbyde974ca2023-12-12 13:53:31 +00001423/**
J-Alves0b6653d2022-04-22 13:17:38 +01001424 * This corresponds to table 10.16 of the FF-A v1.1 EAC0 specification,
1425 * "Endpoint memory access descriptor".
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001426 */
1427struct ffa_memory_access {
1428 struct ffa_memory_region_attributes receiver_permissions;
1429 /**
1430 * Offset in bytes from the start of the outer `ffa_memory_region` to
1431 * an `ffa_composite_memory_region` struct.
1432 */
1433 uint32_t composite_memory_region_offset;
Daniel Boulbyde974ca2023-12-12 13:53:31 +00001434 struct ffa_memory_access_impdef impdef;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001435 uint64_t reserved_0;
1436};
1437
J-Alves363f5722022-04-25 17:37:37 +01001438/** The maximum number of recipients a memory region may be sent to. */
J-Alvesba0e6172022-04-25 17:41:40 +01001439#define MAX_MEM_SHARE_RECIPIENTS UINT32_C(2)
J-Alves363f5722022-04-25 17:37:37 +01001440
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001441/**
1442 * Information about a set of pages which are being shared. This corresponds to
J-Alves0b6653d2022-04-22 13:17:38 +01001443 * table 10.20 of the FF-A v1.1 EAC0 specification, "Lend, donate or share
1444 * memory transaction descriptor". Note that it is also used for retrieve
1445 * requests and responses.
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001446 */
1447struct ffa_memory_region {
1448 /**
1449 * The ID of the VM which originally sent the memory region, i.e. the
1450 * owner.
1451 */
J-Alves19e20cf2023-08-02 12:48:55 +01001452 ffa_id_t sender;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001453 ffa_memory_attributes_t attributes;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001454 /** Flags to control behaviour of the transaction. */
1455 ffa_memory_region_flags_t flags;
1456 ffa_memory_handle_t handle;
1457 /**
1458 * An implementation defined value associated with the receiver and the
1459 * memory region.
1460 */
1461 uint64_t tag;
J-Alves0b6653d2022-04-22 13:17:38 +01001462 /* Size of the memory access descriptor. */
1463 uint32_t memory_access_desc_size;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001464 /**
1465 * The number of `ffa_memory_access` entries included in this
1466 * transaction.
1467 */
1468 uint32_t receiver_count;
1469 /**
J-Alves0b6653d2022-04-22 13:17:38 +01001470 * Offset of the 'receivers' field, which relates to the memory access
1471 * descriptors.
1472 */
1473 uint32_t receivers_offset;
1474 /** Reserved field (12 bytes) must be 0. */
1475 uint32_t reserved[3];
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001476};
1477
1478/**
1479 * Descriptor used for FFA_MEM_RELINQUISH requests. This corresponds to table
J-Alves0b6653d2022-04-22 13:17:38 +01001480 * 16.25 of the FF-A v1.1 EAC0 specification, "Descriptor to relinquish a memory
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001481 * region".
1482 */
1483struct ffa_mem_relinquish {
1484 ffa_memory_handle_t handle;
1485 ffa_memory_region_flags_t flags;
1486 uint32_t endpoint_count;
J-Alves19e20cf2023-08-02 12:48:55 +01001487 ffa_id_t endpoints[];
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001488};
1489
1490/**
Daniel Boulby59ffee92023-11-02 18:26:26 +00001491 * Returns the first FF-A version that matches the memory access descriptor
1492 * size.
Daniel Boulbyde974ca2023-12-12 13:53:31 +00001493 */
Karl Meakin0e617d92024-04-05 12:55:22 +01001494enum ffa_version ffa_version_from_memory_access_desc_size(
Daniel Boulbyc7dc9322023-10-27 15:12:07 +01001495 uint32_t memory_access_desc_size);
1496
1497/**
Daniel Boulbyd5ae44b2023-12-12 12:18:11 +00001498 * To maintain forwards compatability we can't make assumptions about the size
1499 * of the endpoint memory access descriptor so provide a helper function
1500 * to get a receiver from the receiver array using the memory access descriptor
1501 * size field from the memory region descriptor struct.
1502 * Returns NULL if we cannot return the receiver.
1503 */
1504static inline struct ffa_memory_access *ffa_memory_region_get_receiver(
1505 struct ffa_memory_region *memory_region, uint32_t receiver_index)
1506{
1507 uint32_t memory_access_desc_size =
1508 memory_region->memory_access_desc_size;
1509
1510 if (receiver_index >= memory_region->receiver_count) {
1511 return NULL;
1512 }
1513
1514 /*
1515 * Memory access descriptor size cannot be greater than the size of
1516 * the memory access descriptor defined by the current FF-A version.
1517 */
1518 if (memory_access_desc_size > sizeof(struct ffa_memory_access)) {
1519 return NULL;
1520 }
1521
Daniel Boulby41ef8ba2023-10-13 17:01:22 +01001522 /* Check we cannot use receivers offset to cause overflow. */
1523 if (memory_region->receivers_offset !=
1524 sizeof(struct ffa_memory_region)) {
1525 return NULL;
1526 }
1527
Karl Meakin2ad6b662024-07-29 20:45:40 +01001528 return (struct ffa_memory_access
1529 *)((uint8_t *)memory_region +
1530 (size_t)memory_region->receivers_offset +
1531 (size_t)(receiver_index * memory_access_desc_size));
Daniel Boulbyd5ae44b2023-12-12 12:18:11 +00001532}
1533
1534/**
Daniel Boulby59ffee92023-11-02 18:26:26 +00001535 * Gets the receiver's access permissions from 'struct ffa_memory_region' and
1536 * returns its index in the receiver's array. If receiver's ID doesn't exist
1537 * in the array, return the region's 'receivers_count'.
1538 */
1539static inline uint32_t ffa_memory_region_get_receiver_index(
1540 struct ffa_memory_region *memory_region, ffa_id_t receiver_id)
1541{
1542 uint32_t i;
1543
1544 for (i = 0U; i < memory_region->receiver_count; i++) {
1545 struct ffa_memory_access *receiver =
1546 ffa_memory_region_get_receiver(memory_region, i);
1547 if (receiver->receiver_permissions.receiver == receiver_id) {
1548 break;
1549 }
1550 }
1551
1552 return i;
1553}
1554
1555/**
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001556 * Gets the `ffa_composite_memory_region` for the given receiver from an
1557 * `ffa_memory_region`, or NULL if it is not valid.
1558 */
1559static inline struct ffa_composite_memory_region *
1560ffa_memory_region_get_composite(struct ffa_memory_region *memory_region,
1561 uint32_t receiver_index)
1562{
Daniel Boulbyd5ae44b2023-12-12 12:18:11 +00001563 struct ffa_memory_access *receiver =
1564 ffa_memory_region_get_receiver(memory_region, receiver_index);
1565 uint32_t offset;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001566
Daniel Boulbyd5ae44b2023-12-12 12:18:11 +00001567 if (receiver == NULL) {
1568 return NULL;
1569 }
1570
1571 offset = receiver->composite_memory_region_offset;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001572 if (offset == 0) {
1573 return NULL;
1574 }
1575
1576 return (struct ffa_composite_memory_region *)((uint8_t *)memory_region +
1577 offset);
1578}
1579
1580static inline uint32_t ffa_mem_relinquish_init(
1581 struct ffa_mem_relinquish *relinquish_request,
1582 ffa_memory_handle_t handle, ffa_memory_region_flags_t flags,
J-Alves19e20cf2023-08-02 12:48:55 +01001583 ffa_id_t sender)
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001584{
1585 relinquish_request->handle = handle;
1586 relinquish_request->flags = flags;
1587 relinquish_request->endpoint_count = 1;
1588 relinquish_request->endpoints[0] = sender;
J-Alves19e20cf2023-08-02 12:48:55 +01001589 return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_id_t);
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001590}
1591
J-Alves126ab502022-09-29 11:37:33 +01001592void ffa_copy_memory_region_constituents(
1593 struct ffa_memory_region_constituent *dest,
1594 const struct ffa_memory_region_constituent *src);
1595
Karl Meakin0fd67292024-02-06 17:33:05 +00001596struct ffa_features_rxtx_map_params {
1597 /*
1598 * Bit[0:1]:
1599 * Minimum buffer size and alignment boundary:
1600 * 0b00: 4K
1601 * 0b01: 64K
1602 * 0b10: 16K
1603 * 0b11: Reserved
1604 */
1605 uint8_t min_buf_size : 2;
1606 /*
1607 * Bit[2:15]:
1608 * Reserved (MBZ)
1609 */
1610 uint16_t mbz : 14;
1611 /*
1612 * Bit[16:32]:
1613 * Maximum buffer size in number of pages
1614 * Only present on version 1.2 or later
1615 */
1616 uint16_t max_buf_size : 16;
1617};
1618
Karl Meakin49ec1e42024-05-10 13:08:24 +01001619enum ffa_features_rxtx_map_buf_size {
1620 FFA_RXTX_MAP_MIN_BUF_4K = 0,
1621 FFA_RXTX_MAP_MAX_BUF_PAGE_COUNT = 1,
1622};
Karl Meakin0fd67292024-02-06 17:33:05 +00001623
Karl Meakinf7861302024-02-20 14:39:33 +00001624static inline struct ffa_features_rxtx_map_params ffa_features_rxtx_map_params(
1625 struct ffa_value args)
1626{
1627 struct ffa_features_rxtx_map_params params;
1628 uint32_t arg2 = args.arg2;
1629
1630 params = *(struct ffa_features_rxtx_map_params *)(&arg2);
1631
1632 return params;
1633}
1634
Federico Recanati392be392022-02-08 20:53:03 +01001635/**
1636 * Endpoint RX/TX descriptor, as defined by Table 13.27 in FF-A v1.1 EAC0.
1637 * It's used by the Hypervisor to describe the RX/TX buffers mapped by a VM
1638 * to the SPMC, in order to allow indirect messaging.
1639 */
1640struct ffa_endpoint_rx_tx_descriptor {
J-Alves19e20cf2023-08-02 12:48:55 +01001641 ffa_id_t endpoint_id;
Federico Recanati392be392022-02-08 20:53:03 +01001642 uint16_t reserved;
1643
1644 /*
1645 * 8-byte aligned offset from the base address of this descriptor to the
1646 * `ffa_composite_memory_region` describing the RX buffer.
1647 */
1648 uint32_t rx_offset;
1649
1650 /*
1651 * 8-byte aligned offset from the base address of this descriptor to the
1652 * `ffa_composite_memory_region` describing the TX buffer.
1653 */
1654 uint32_t tx_offset;
1655
1656 /* Pad to align on 16-byte boundary. */
1657 uint32_t pad;
1658};
1659
1660static inline struct ffa_composite_memory_region *
Karl Meakinb9705e22024-04-05 13:58:28 +01001661ffa_endpoint_get_rx_memory_region(struct ffa_endpoint_rx_tx_descriptor *desc)
Federico Recanati392be392022-02-08 20:53:03 +01001662{
Karl Meakin2ad6b662024-07-29 20:45:40 +01001663 return (struct ffa_composite_memory_region *)((char *)desc +
Federico Recanati392be392022-02-08 20:53:03 +01001664 desc->rx_offset);
1665}
1666
1667static inline struct ffa_composite_memory_region *
Karl Meakinb9705e22024-04-05 13:58:28 +01001668ffa_endpoint_get_tx_memory_region(struct ffa_endpoint_rx_tx_descriptor *desc)
Federico Recanati392be392022-02-08 20:53:03 +01001669{
Karl Meakin2ad6b662024-07-29 20:45:40 +01001670 return (struct ffa_composite_memory_region *)((char *)desc +
Federico Recanati392be392022-02-08 20:53:03 +01001671 desc->tx_offset);
1672}
1673
J-Alves2d8457f2022-10-05 11:06:41 +01001674void ffa_memory_region_init_header(struct ffa_memory_region *memory_region,
J-Alves19e20cf2023-08-02 12:48:55 +01001675 ffa_id_t sender,
J-Alves2d8457f2022-10-05 11:06:41 +01001676 ffa_memory_attributes_t attributes,
1677 ffa_memory_region_flags_t flags,
1678 ffa_memory_handle_t handle, uint32_t tag,
Daniel Boulbyd5ae44b2023-12-12 12:18:11 +00001679 uint32_t receiver_count,
1680 uint32_t receiver_desc_size);
Daniel Boulby59ffee92023-11-02 18:26:26 +00001681void ffa_memory_access_init(struct ffa_memory_access *receiver,
1682 ffa_id_t receiver_id,
1683 enum ffa_data_access data_access,
1684 enum ffa_instruction_access instruction_access,
1685 ffa_memory_receiver_flags_t flags,
1686 struct ffa_memory_access_impdef *impdef_val);
J-Alves45085432022-04-22 16:19:20 +01001687uint32_t ffa_memory_region_init_single_receiver(
Andrew Walbranca808b12020-05-15 17:22:28 +01001688 struct ffa_memory_region *memory_region, size_t memory_region_max_size,
J-Alves19e20cf2023-08-02 12:48:55 +01001689 ffa_id_t sender, ffa_id_t receiver,
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001690 const struct ffa_memory_region_constituent constituents[],
1691 uint32_t constituent_count, uint32_t tag,
1692 ffa_memory_region_flags_t flags, enum ffa_data_access data_access,
1693 enum ffa_instruction_access instruction_access,
1694 enum ffa_memory_type type, enum ffa_memory_cacheability cacheability,
Daniel Boulby59ffee92023-11-02 18:26:26 +00001695 enum ffa_memory_shareability shareability,
1696 struct ffa_memory_access_impdef *impdef_val, uint32_t *fragment_length,
Andrew Walbranca808b12020-05-15 17:22:28 +01001697 uint32_t *total_length);
J-Alvesf4eecf72022-07-20 16:05:34 +01001698uint32_t ffa_memory_region_init(
1699 struct ffa_memory_region *memory_region, size_t memory_region_max_size,
J-Alves19e20cf2023-08-02 12:48:55 +01001700 ffa_id_t sender, struct ffa_memory_access receivers[],
Daniel Boulbyd5ae44b2023-12-12 12:18:11 +00001701 uint32_t receiver_count, uint32_t receiver_desc_size,
J-Alvesf4eecf72022-07-20 16:05:34 +01001702 const struct ffa_memory_region_constituent constituents[],
1703 uint32_t constituent_count, uint32_t tag,
1704 ffa_memory_region_flags_t flags, enum ffa_memory_type type,
1705 enum ffa_memory_cacheability cacheability,
1706 enum ffa_memory_shareability shareability, uint32_t *fragment_length,
1707 uint32_t *total_length);
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001708uint32_t ffa_memory_retrieve_request_init(
1709 struct ffa_memory_region *memory_region, ffa_memory_handle_t handle,
J-Alves19e20cf2023-08-02 12:48:55 +01001710 ffa_id_t sender, struct ffa_memory_access receivers[],
Daniel Boulbyd5ae44b2023-12-12 12:18:11 +00001711 uint32_t receiver_count, uint32_t receiver_desc_size, uint32_t tag,
1712 ffa_memory_region_flags_t flags, enum ffa_memory_type type,
1713 enum ffa_memory_cacheability cacheability,
J-Alves9b24ed82022-08-04 13:12:45 +01001714 enum ffa_memory_shareability shareability);
1715uint32_t ffa_memory_retrieve_request_init_single_receiver(
1716 struct ffa_memory_region *memory_region, ffa_memory_handle_t handle,
J-Alves19e20cf2023-08-02 12:48:55 +01001717 ffa_id_t sender, ffa_id_t receiver, uint32_t tag,
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001718 ffa_memory_region_flags_t flags, enum ffa_data_access data_access,
1719 enum ffa_instruction_access instruction_access,
1720 enum ffa_memory_type type, enum ffa_memory_cacheability cacheability,
Daniel Boulby59ffee92023-11-02 18:26:26 +00001721 enum ffa_memory_shareability shareability,
1722 struct ffa_memory_access_impdef *impdef_val);
Andrew Walbranb5ab43c2020-04-30 11:32:54 +01001723uint32_t ffa_memory_lender_retrieve_request_init(
1724 struct ffa_memory_region *memory_region, ffa_memory_handle_t handle,
J-Alves19e20cf2023-08-02 12:48:55 +01001725 ffa_id_t sender);
Andrew Walbranca808b12020-05-15 17:22:28 +01001726uint32_t ffa_memory_fragment_init(
1727 struct ffa_memory_region_constituent *fragment,
1728 size_t fragment_max_size,
1729 const struct ffa_memory_region_constituent constituents[],
1730 uint32_t constituent_count, uint32_t *fragment_length);
Federico Recanati392be392022-02-08 20:53:03 +01001731void ffa_endpoint_rx_tx_descriptor_init(
J-Alves19e20cf2023-08-02 12:48:55 +01001732 struct ffa_endpoint_rx_tx_descriptor *desc, ffa_id_t endpoint_id,
Federico Recanati392be392022-02-08 20:53:03 +01001733 uint64_t rx_address, uint64_t tx_address);