blob: c34384de658f22f9831da785c38d203e72f4e4ac [file] [log] [blame]
J-Alves7581c382020-05-07 18:34:20 +01001/*
Karl Meakin92aa7702023-10-11 18:48:01 +01002 * Copyright (c) 2018-2023, Arm Limited. All rights reserved.
J-Alves7581c382020-05-07 18:34:20 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef FFA_HELPERS_H
8#define FFA_HELPERS_H
9
J-Alves8f08a052020-05-26 17:14:40 +010010#include <ffa_svc.h>
J-Alves7581c382020-05-07 18:34:20 +010011#include <tftf_lib.h>
12#include <utils_def.h>
13
J-Alves779fba62024-04-05 14:14:40 +010014#include <xlat_tables_defs.h>
15
J-Alves7581c382020-05-07 18:34:20 +010016/* This error code must be different to the ones used by FFA */
17#define FFA_TFTF_ERROR -42
18
Daniel Boulbye79d2072021-03-03 11:34:53 +000019typedef unsigned short ffa_id_t;
J-Alves5aecd982020-06-11 10:25:33 +010020typedef unsigned short ffa_vm_count_t;
21typedef unsigned short ffa_vcpu_count_t;
J-Alvesf3a393c2020-10-23 16:00:39 +010022typedef uint64_t ffa_memory_handle_t;
23/** Flags to indicate properties of receivers during memory region retrieval. */
24typedef uint8_t ffa_memory_receiver_flags_t;
J-Alves5aecd982020-06-11 10:25:33 +010025
J-Alvesd708c032020-11-19 12:14:21 +000026struct ffa_uuid {
Raghu Krishnamurthyab5321a2023-04-23 16:14:28 -070027 uint32_t uuid[4];
J-Alvesd708c032020-11-19 12:14:21 +000028};
29
J-Alvesda3e6d42022-01-25 10:19:56 +000030/** Length in bytes of the name in boot information descriptor. */
31#define FFA_BOOT_INFO_NAME_LEN 16
32
33/**
34 * The FF-A boot info descriptor, as defined in table 5.8 of section 5.4.1, of
35 * the FF-A v1.1 EAC0 specification.
36 */
37struct ffa_boot_info_desc {
38 char name[FFA_BOOT_INFO_NAME_LEN];
39 uint8_t type;
40 uint8_t reserved;
41 uint16_t flags;
42 uint32_t size;
43 uint64_t content;
44};
45
46/** FF-A boot information type mask. */
47#define FFA_BOOT_INFO_TYPE_SHIFT 7
48#define FFA_BOOT_INFO_TYPE_MASK (0x1U << FFA_BOOT_INFO_TYPE_SHIFT)
49#define FFA_BOOT_INFO_TYPE_STD 0U
50#define FFA_BOOT_INFO_TYPE_IMPDEF 1U
51
52/** Standard boot info type IDs. */
53#define FFA_BOOT_INFO_TYPE_ID_MASK 0x7FU
54#define FFA_BOOT_INFO_TYPE_ID_FDT 0U
55#define FFA_BOOT_INFO_TYPE_ID_HOB 1U
56
57/** FF-A Boot Info descriptors flags. */
58#define FFA_BOOT_INFO_FLAG_MBZ_MASK 0xFFF0U
59
60/** Bits [1:0] encode the format of the name field in ffa_boot_info_desc. */
61#define FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT 0U
62#define FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK \
63 (0x3U << FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT)
64#define FFA_BOOT_INFO_FLAG_NAME_FORMAT_STRING 0x0U
65#define FFA_BOOT_INFO_FLAG_NAME_FORMAT_UUID 0x1U
66
67/** Bits [3:2] encode the format of the content field in ffa_boot_info_desc. */
68#define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT 2
69#define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK \
70 (0x3U << FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT)
71#define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_VALUE 0x1U
72#define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_ADDR 0x0U
73
74static inline uint16_t ffa_boot_info_content_format(
75 struct ffa_boot_info_desc *desc)
76{
77 return (desc->flags & FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK) >>
78 FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT;
79}
80
81static inline uint16_t ffa_boot_info_name_format(
82 struct ffa_boot_info_desc *desc)
83{
84 return (desc->flags & FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK) >>
85 FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT;
86}
87
88static inline uint8_t ffa_boot_info_type_id(struct ffa_boot_info_desc *desc)
89{
90 return desc->type & FFA_BOOT_INFO_TYPE_ID_MASK;
91}
92
93static inline uint8_t ffa_boot_info_type(struct ffa_boot_info_desc *desc)
94{
95 return (desc->type & FFA_BOOT_INFO_TYPE_MASK) >>
96 FFA_BOOT_INFO_TYPE_SHIFT;
97}
98
99/** Length in bytes of the signature in the boot descriptor. */
100#define FFA_BOOT_INFO_HEADER_SIGNATURE_LEN 4
101
102/**
103 * The FF-A boot information header, as defined in table 5.9 of section 5.4.2,
104 * of the FF-A v1.1 EAC0 specification.
105 */
106struct ffa_boot_info_header {
107 uint32_t signature;
108 uint32_t version;
109 uint32_t info_blob_size;
110 uint32_t desc_size;
111 uint32_t desc_count;
112 uint32_t desc_offset;
113 uint64_t reserved;
114 struct ffa_boot_info_desc boot_info[];
115};
116
J-Alves7581c382020-05-07 18:34:20 +0100117#ifndef __ASSEMBLY__
118
J-Alves18c28052021-03-09 09:58:53 +0000119#include <cassert.h>
J-Alves7581c382020-05-07 18:34:20 +0100120#include <stdint.h>
121
J-Alves4439ece2021-11-05 11:52:54 +0000122/**
123 * FF-A Feature ID, to be used with interface FFA_FEATURES.
124 * As defined in the FF-A v1.1 Beta specification, table 13.10, in section
125 * 13.2.
126 */
127
128/** Query interrupt ID of Notification Pending Interrupt. */
129#define FFA_FEATURE_NPI 0x1U
130
131/** Query interrupt ID of Schedule Receiver Interrupt. */
132#define FFA_FEATURE_SRI 0x2U
133
134/** Query interrupt ID of the Managed Exit Interrupt. */
135#define FFA_FEATURE_MEI 0x3U
136
Karl Meakinf2bb5d02024-02-13 17:23:17 +0000137/** Minimum and maximum buffer size reported by FFA_FEATURES(FFA_RXTX_MAP) */
138#define FFA_RXTX_MAP_MIN_BUF_4K 0
139#define FFA_RXTX_MAP_MAX_BUF_PAGE_COUNT 1
140
Max Shvetsov0b7d25f2021-03-05 13:46:42 +0000141/** Partition property: partition supports receipt of direct requests. */
Kathleen Capella7774d6e2022-11-23 19:06:21 -0500142#define FFA_PARTITION_DIRECT_REQ_RECV (UINT32_C(1) << 0)
Max Shvetsov0b7d25f2021-03-05 13:46:42 +0000143
144/** Partition property: partition can send direct requests. */
Kathleen Capella7774d6e2022-11-23 19:06:21 -0500145#define FFA_PARTITION_DIRECT_REQ_SEND (UINT32_C(1) << 1)
Max Shvetsov0b7d25f2021-03-05 13:46:42 +0000146
147/** Partition property: partition can send and receive indirect messages. */
Kathleen Capella7774d6e2022-11-23 19:06:21 -0500148#define FFA_PARTITION_INDIRECT_MSG (UINT32_C(1) << 2)
Max Shvetsov0b7d25f2021-03-05 13:46:42 +0000149
J-Alves4d05dec2021-11-02 11:52:27 +0000150/** Partition property: partition can receive notifications. */
Kathleen Capella7774d6e2022-11-23 19:06:21 -0500151#define FFA_PARTITION_NOTIFICATION (UINT32_C(1) << 3)
J-Alves4d05dec2021-11-02 11:52:27 +0000152
Kathleen Capella7774d6e2022-11-23 19:06:21 -0500153/** Partition property: partition runs in the AArch64 execution state. */
154#define FFA_PARTITION_AARCH64_EXEC (UINT32_C(1) << 8)
155
156/** Partition info descriptor as defined in FF-A v1.1 EAC0 Table 13.37 */
Max Shvetsovc32f4782020-06-23 09:41:15 +0100157struct ffa_partition_info {
158 /** The ID of the VM the information is about */
Daniel Boulbye79d2072021-03-03 11:34:53 +0000159 ffa_id_t id;
Max Shvetsovc32f4782020-06-23 09:41:15 +0100160 /** The number of execution contexts implemented by the partition */
161 uint16_t exec_context;
162 /** The Partition's properties, e.g. supported messaging methods */
163 uint32_t properties;
Daniel Boulby8aa994c2022-01-05 19:44:30 +0000164 /** The uuid of the partition */
165 struct ffa_uuid uuid;
Max Shvetsovc32f4782020-06-23 09:41:15 +0100166};
167
Daniel Boulby2ac55f22022-01-21 12:08:08 +0000168/**
Kathleen Capella7774d6e2022-11-23 19:06:21 -0500169 * Bits[31:3] of partition properties must be zero for FF-A v1.0.
170 * This corresponds to table 8.25 "Partition information descriptor"
171 * in DEN0077A FF-A 1.0 REL specification.
172 */
173#define FFA_PARTITION_v1_0_RES_MASK (~(UINT32_C(0x7)))
174
175/**
Daniel Boulby2ac55f22022-01-21 12:08:08 +0000176 * Partition info descriptor as defined in Table 8.25 of the v1.0
Kathleen Capella7774d6e2022-11-23 19:06:21 -0500177 * FF-A Specification (DEN0077A).
Daniel Boulby2ac55f22022-01-21 12:08:08 +0000178 */
179struct ffa_partition_info_v1_0 {
180 /** The ID of the VM the information is about */
181 ffa_id_t id;
182 /** The number of execution contexts implemented by the partition */
183 uint16_t exec_context;
184 /** The Partition's properties, e.g. supported messaging methods */
185 uint32_t properties;
186};
187
Daniel Boulbyce386b12022-03-29 18:36:36 +0100188struct ffa_value {
189 u_register_t fid;
190 u_register_t arg1;
191 u_register_t arg2;
192 u_register_t arg3;
193 u_register_t arg4;
194 u_register_t arg5;
195 u_register_t arg6;
196 u_register_t arg7;
Raghu Krishnamurthyab5321a2023-04-23 16:14:28 -0700197 u_register_t arg8;
198 u_register_t arg9;
199 u_register_t arg10;
200 u_register_t arg11;
201 u_register_t arg12;
202 u_register_t arg13;
203 u_register_t arg14;
204 u_register_t arg15;
205 u_register_t arg16;
206 u_register_t arg17;
Daniel Boulbyce386b12022-03-29 18:36:36 +0100207};
208
209/* Function to make an SMC or SVC service call depending on the exception
210 * level of the SP.
211 */
212struct ffa_value ffa_service_call(struct ffa_value *args);
213
214/*
215 * Functions to trigger a service call.
216 *
217 * The arguments to pass through the service call must be stored in the
218 * ffa_value structure. The return values of the service call will be stored
219 * in the same structure (overriding the input arguments).
220 *
221 * Return the first return value. It is equivalent to args.fid but is also
222 * provided as the return value for convenience.
223 */
224u_register_t ffa_svc(struct ffa_value *args);
225u_register_t ffa_smc(struct ffa_value *args);
226
227static inline uint32_t ffa_func_id(struct ffa_value val)
J-Alvesf156ae92021-10-08 12:10:05 +0100228{
Daniel Boulbyce386b12022-03-29 18:36:36 +0100229 return (uint32_t)val.fid;
J-Alves6cb21d92021-01-07 15:18:12 +0000230}
231
Daniel Boulbyce386b12022-03-29 18:36:36 +0100232static inline int32_t ffa_error_code(struct ffa_value val)
J-Alvesf156ae92021-10-08 12:10:05 +0100233{
Daniel Boulbyce386b12022-03-29 18:36:36 +0100234 return (int32_t)val.arg2;
J-Alves6cb21d92021-01-07 15:18:12 +0000235}
236
Daniel Boulbyce386b12022-03-29 18:36:36 +0100237static inline ffa_id_t ffa_endpoint_id(struct ffa_value val) {
238 return (ffa_id_t)val.arg2 & 0xffff;
Daniel Boulby198deda2021-03-03 11:35:25 +0000239}
240
Daniel Boulbyce386b12022-03-29 18:36:36 +0100241static inline uint32_t ffa_partition_info_count(struct ffa_value val)
Daniel Boulby2ac55f22022-01-21 12:08:08 +0000242{
Daniel Boulbyce386b12022-03-29 18:36:36 +0100243 return (uint32_t)val.arg2;
Daniel Boulby2ac55f22022-01-21 12:08:08 +0000244}
245
Daniel Boulby07d751e2022-05-30 17:32:00 +0100246static inline uint32_t ffa_partition_info_desc_size(struct ffa_value val)
247{
248 return (uint32_t)val.arg3;
249}
250
Daniel Boulbyce386b12022-03-29 18:36:36 +0100251static inline uint32_t ffa_feature_intid(struct ffa_value val)
J-Alves4439ece2021-11-05 11:52:54 +0000252{
Daniel Boulbyce386b12022-03-29 18:36:36 +0100253 return (uint32_t)val.arg2;
J-Alves4439ece2021-11-05 11:52:54 +0000254}
255
Raghu Krishnamurthyab5321a2023-04-23 16:14:28 -0700256static inline uint16_t ffa_partition_info_regs_get_last_idx(
257 struct ffa_value args)
258{
259 return args.arg2 & 0xFFFF;
260}
261
262static inline uint16_t ffa_partition_info_regs_get_curr_idx(
263 struct ffa_value args)
264{
265 return (args.arg2 >> 16) & 0xFFFF;
266}
267
268static inline uint16_t ffa_partition_info_regs_get_tag(struct ffa_value args)
269{
270 return (args.arg2 >> 32) & 0xFFFF;
271}
272
273static inline uint16_t ffa_partition_info_regs_get_desc_size(
274 struct ffa_value args)
275{
276 return (args.arg2 >> 48);
277}
278
279static inline uint32_t ffa_partition_info_regs_partition_count(
280 struct ffa_value args)
281{
282 return ffa_partition_info_regs_get_last_idx(args) + 1;
283}
284
285static inline uint32_t ffa_partition_info_regs_entry_count(
286 struct ffa_value args, uint16_t start_idx)
287{
288 return (ffa_partition_info_regs_get_curr_idx(args) - start_idx + 1);
289}
290
291static inline uint16_t ffa_partition_info_regs_entry_size(
292 struct ffa_value args)
293{
294 return (args.arg2 >> 48) & 0xFFFFU;
295}
296
J-Alves18c28052021-03-09 09:58:53 +0000297typedef uint64_t ffa_notification_bitmap_t;
298
J-Alves779fba62024-04-05 14:14:40 +0100299/**
300 * Partition message header as specified by table 6.2 from FF-A v1.1 EAC0
301 * specification.
302 */
303struct ffa_partition_rxtx_header {
304 uint32_t flags;
305 /* MBZ */
306 uint32_t reserved;
307 /* Offset from the beginning of the buffer to the message payload. */
308 uint32_t offset;
309 /* Sender(Bits[31:16]) and Receiver(Bits[15:0]) endpoint IDs. */
310 ffa_id_t receiver;
311 ffa_id_t sender;
312 /* Size of message in buffer. */
313 uint32_t size;
314};
315
316#define FFA_RXTX_HEADER_SIZE sizeof(struct ffa_partition_rxtx_header)
317
318static inline void ffa_rxtx_header_init(
319 ffa_id_t sender, ffa_id_t receiver, uint32_t size,
320 struct ffa_partition_rxtx_header *header)
321{
322 header->flags = 0;
323 header->reserved = 0;
324 header->offset = FFA_RXTX_HEADER_SIZE;
325 header->sender = sender;
326 header->receiver = receiver;
327 header->size = size;
328}
329
330/* The maximum length possible for a single message. */
331#define FFA_PARTITION_MSG_PAYLOAD_MAX (PAGE_SIZE - FFA_RXTX_HEADER_SIZE)
332
333struct ffa_partition_msg {
334 struct ffa_partition_rxtx_header header;
335 char payload[FFA_PARTITION_MSG_PAYLOAD_MAX];
336};
337
338/* The maximum length possible for a single message. */
339#define FFA_MSG_PAYLOAD_MAX PAGE_SIZE
340
J-Alves18c28052021-03-09 09:58:53 +0000341#define FFA_NOTIFICATION(ID) (UINT64_C(1) << ID)
342
343#define MAX_FFA_NOTIFICATIONS UINT32_C(64)
344
345#define FFA_NOTIFICATIONS_FLAG_PER_VCPU UINT32_C(0x1 << 0)
346
J-Alvesb0cb5d02021-07-08 11:19:33 +0100347/** Flag to delay Schedule Receiver Interrupt. */
348#define FFA_NOTIFICATIONS_FLAG_DELAY_SRI UINT32_C(0x1 << 1)
349
J-Alves18c28052021-03-09 09:58:53 +0000350#define FFA_NOTIFICATIONS_FLAGS_VCPU_ID(id) UINT32_C((id & 0xFFFF) << 16)
351
J-Alvesf156ae92021-10-08 12:10:05 +0100352#define FFA_NOTIFICATIONS_FLAG_BITMAP_SP UINT32_C(0x1 << 0)
353#define FFA_NOTIFICATIONS_FLAG_BITMAP_VM UINT32_C(0x1 << 1)
354#define FFA_NOTIFICATIONS_FLAG_BITMAP_SPM UINT32_C(0x1 << 2)
355#define FFA_NOTIFICATIONS_FLAG_BITMAP_HYP UINT32_C(0x1 << 3)
356
J-Alvesc6b92d52024-04-05 14:16:00 +0100357#define FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK FFA_NOTIFICATION(0)
358#define FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK FFA_NOTIFICATION(32)
359
J-Alves269118a2021-09-22 09:46:11 +0100360/**
361 * The following is an SGI ID, that the SPMC configures as non-secure, as
362 * suggested by the FF-A v1.1 specification, in section 9.4.1.
363 */
364#define FFA_SCHEDULE_RECEIVER_INTERRUPT_ID 8
365
J-Alvesc6b92d52024-04-05 14:16:00 +0100366/**
367 * Helper function to assemble a 64-bit sized bitmap, from the 32-bit sized lo
368 * and hi.
369 * Helpful as FF-A specification defines that the notifications interfaces
370 * arguments are 32-bit registers.
371 */
372static inline ffa_notification_bitmap_t ffa_notification_bitmap(uint32_t lo,
373 uint32_t hi)
J-Alvesf156ae92021-10-08 12:10:05 +0100374{
J-Alvesc6b92d52024-04-05 14:16:00 +0100375 return (ffa_notification_bitmap_t)hi << 32U | lo;
J-Alvesf156ae92021-10-08 12:10:05 +0100376}
377
J-Alvesc6b92d52024-04-05 14:16:00 +0100378static inline ffa_notification_bitmap_t ffa_notification_get_from_sp(
Daniel Boulbyce386b12022-03-29 18:36:36 +0100379 struct ffa_value val)
J-Alvesf156ae92021-10-08 12:10:05 +0100380{
J-Alvesc6b92d52024-04-05 14:16:00 +0100381 return ffa_notification_bitmap((uint32_t)val.arg2,
382 (uint32_t)val.arg3);
J-Alvesf156ae92021-10-08 12:10:05 +0100383}
384
J-Alvesc6b92d52024-04-05 14:16:00 +0100385static inline ffa_notification_bitmap_t ffa_notification_get_from_vm(
386 struct ffa_value val)
387{
388 return ffa_notification_bitmap((uint32_t)val.arg4,
389 (uint32_t)val.arg5);
390}
391
392static inline ffa_notification_bitmap_t ffa_notification_get_from_framework(
393 struct ffa_value val)
394{
395 return ffa_notification_bitmap((uint32_t)val.arg6,
396 (uint32_t)val.arg7);
397}
398
399 /**
400 * Helper functions to check for buffer full notification.
401 */
402static inline bool is_ffa_hyp_buffer_full_notification(
403 ffa_notification_bitmap_t framework)
404{
405 return (framework & FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK) != 0U;
406}
407
408static inline bool is_ffa_spm_buffer_full_notification(
409 ffa_notification_bitmap_t framework)
410{
411 return (framework & FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK) != 0U;
412}
413
414
J-Alves5bce2502021-06-14 14:27:45 +0100415/*
416 * FFA_NOTIFICATION_INFO_GET is a SMC64 interface.
417 * The following macros are defined for SMC64 implementation.
418 */
419#define FFA_NOTIFICATIONS_INFO_GET_MAX_IDS 20U
420
421#define FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING UINT64_C(0x1)
422
423#define FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT 0x7U
424#define FFA_NOTIFICATIONS_LISTS_COUNT_MASK 0x1FU
425#define FFA_NOTIFICATIONS_LIST_SHIFT(l) (2 * (l - 1) + 12)
426#define FFA_NOTIFICATIONS_LIST_SIZE_MASK 0x3U
427
J-Alvesc6b92d52024-04-05 14:16:00 +0100428static inline uint32_t ffa_notification_info_get_lists_count(
Daniel Boulbyce386b12022-03-29 18:36:36 +0100429 struct ffa_value ret)
J-Alves5bce2502021-06-14 14:27:45 +0100430{
Daniel Boulbyce386b12022-03-29 18:36:36 +0100431 return (uint32_t)(ret.arg2 >> FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT)
J-Alves5bce2502021-06-14 14:27:45 +0100432 & FFA_NOTIFICATIONS_LISTS_COUNT_MASK;
433}
434
J-Alvesc6b92d52024-04-05 14:16:00 +0100435static inline uint32_t ffa_notification_info_get_list_size(
Daniel Boulbyce386b12022-03-29 18:36:36 +0100436 struct ffa_value ret, uint32_t list)
J-Alves5bce2502021-06-14 14:27:45 +0100437{
Daniel Boulbyce386b12022-03-29 18:36:36 +0100438 return (uint32_t)(ret.arg2 >> FFA_NOTIFICATIONS_LIST_SHIFT(list)) &
J-Alves5bce2502021-06-14 14:27:45 +0100439 FFA_NOTIFICATIONS_LIST_SIZE_MASK;
440}
441
J-Alvesc6b92d52024-04-05 14:16:00 +0100442static inline bool ffa_notification_info_get_more_pending(struct ffa_value ret)
J-Alves5bce2502021-06-14 14:27:45 +0100443{
Daniel Boulbyce386b12022-03-29 18:36:36 +0100444 return (ret.arg2 & FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING) != 0U;
J-Alves5bce2502021-06-14 14:27:45 +0100445}
446
J-Alvesf3a393c2020-10-23 16:00:39 +0100447enum ffa_data_access {
448 FFA_DATA_ACCESS_NOT_SPECIFIED,
449 FFA_DATA_ACCESS_RO,
450 FFA_DATA_ACCESS_RW,
451 FFA_DATA_ACCESS_RESERVED,
452};
453
454enum ffa_instruction_access {
455 FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
456 FFA_INSTRUCTION_ACCESS_NX,
457 FFA_INSTRUCTION_ACCESS_X,
458 FFA_INSTRUCTION_ACCESS_RESERVED,
459};
460
461enum ffa_memory_type {
462 FFA_MEMORY_NOT_SPECIFIED_MEM,
463 FFA_MEMORY_DEVICE_MEM,
464 FFA_MEMORY_NORMAL_MEM,
465};
466
467enum ffa_memory_cacheability {
468 FFA_MEMORY_CACHE_RESERVED = 0x0,
469 FFA_MEMORY_CACHE_NON_CACHEABLE = 0x1,
470 FFA_MEMORY_CACHE_RESERVED_1 = 0x2,
471 FFA_MEMORY_CACHE_WRITE_BACK = 0x3,
472 FFA_MEMORY_DEV_NGNRNE = 0x0,
473 FFA_MEMORY_DEV_NGNRE = 0x1,
474 FFA_MEMORY_DEV_NGRE = 0x2,
475 FFA_MEMORY_DEV_GRE = 0x3,
476};
477
478enum ffa_memory_shareability {
479 FFA_MEMORY_SHARE_NON_SHAREABLE,
480 FFA_MEMORY_SHARE_RESERVED,
481 FFA_MEMORY_OUTER_SHAREABLE,
482 FFA_MEMORY_INNER_SHAREABLE,
483};
484
Karl Meakin92aa7702023-10-11 18:48:01 +0100485typedef struct {
486 uint8_t data_access : 2;
487 uint8_t instruction_access : 2;
488} ffa_memory_access_permissions_t;
489
490_Static_assert(sizeof(ffa_memory_access_permissions_t) == sizeof(uint8_t),
491 "ffa_memory_access_permissions_t must be 1 byte wide");
J-Alvesf3a393c2020-10-23 16:00:39 +0100492
493/**
J-Alvesd13d7602023-05-05 14:19:03 +0100494 * FF-A v1.1 REL0 Table 10.18 memory region attributes descriptor NS Bit 6.
495 * Per section 10.10.4.1, NS bit is reserved for FFA_MEM_DONATE/LEND/SHARE
496 * and FFA_MEM_RETRIEVE_REQUEST.
497 */
498enum ffa_memory_security {
499 FFA_MEMORY_SECURITY_UNSPECIFIED = 0,
500 FFA_MEMORY_SECURITY_SECURE = 0,
501 FFA_MEMORY_SECURITY_NON_SECURE,
502};
503
504/**
J-Alvesb42d17f2022-07-04 12:42:13 +0100505 * This corresponds to table 10.18 of the FF-A v1.1 EAC0 specification, "Memory
506 * region attributes descriptor".
J-Alvesf3a393c2020-10-23 16:00:39 +0100507 */
Karl Meakin92aa7702023-10-11 18:48:01 +0100508typedef struct {
509 uint16_t shareability : 2;
510 uint16_t cacheability : 2;
511 uint16_t type : 2;
512 uint16_t security : 1;
513} ffa_memory_attributes_t;
J-Alvesf3a393c2020-10-23 16:00:39 +0100514
Karl Meakin92aa7702023-10-11 18:48:01 +0100515_Static_assert(sizeof(ffa_memory_attributes_t) == sizeof(uint16_t),
516 "ffa_memory_attributes_t must be 2 bytes wide");
J-Alvesf3a393c2020-10-23 16:00:39 +0100517
Karl Meakin0d4f5ff2023-10-13 20:03:16 +0100518#define FFA_MEMORY_HANDLE_ALLOCATOR_MASK UINT64_C(1)
519#define FFA_MEMORY_HANDLE_ALLOCATOR_SHIFT 63U
520#define FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR UINT64_C(1)
521#define FFA_MEMORY_HANDLE_ALLOCATOR_SPMC UINT64_C(0)
J-Alvesf3a393c2020-10-23 16:00:39 +0100522#define FFA_MEMORY_HANDLE_INVALID (~UINT64_C(0))
523
524/**
525 * A set of contiguous pages which is part of a memory region. This corresponds
J-Alvesb42d17f2022-07-04 12:42:13 +0100526 * to table 10.14 of the FF-A v1.1 EAC0 specification, "Constituent memory
527 * region descriptor".
J-Alvesf3a393c2020-10-23 16:00:39 +0100528 */
529struct ffa_memory_region_constituent {
530 /**
531 * The base IPA of the constituent memory region, aligned to 4 kiB page
532 * size granularity.
533 */
534 void *address;
535 /** The number of 4 kiB pages in the constituent memory region. */
536 uint32_t page_count;
537 /** Reserved field, must be 0. */
538 uint32_t reserved;
539};
540
541/**
J-Alvesb42d17f2022-07-04 12:42:13 +0100542 * A set of pages comprising a memory region. This corresponds to table 10.13 of
543 * the FF-A v1.1 EAC0 specification, "Composite memory region descriptor".
J-Alvesf3a393c2020-10-23 16:00:39 +0100544 */
545struct ffa_composite_memory_region {
546 /**
547 * The total number of 4 kiB pages included in this memory region. This
548 * must be equal to the sum of page counts specified in each
549 * `ffa_memory_region_constituent`.
550 */
551 uint32_t page_count;
552 /**
553 * The number of constituents (`ffa_memory_region_constituent`)
554 * included in this memory region range.
555 */
556 uint32_t constituent_count;
557 /** Reserved field, must be 0. */
558 uint64_t reserved_0;
559 /** An array of `constituent_count` memory region constituents. */
560 struct ffa_memory_region_constituent constituents[];
561};
562
563/**
564 * This corresponds to table "Memory access permissions descriptor" of the FFA
565 * 1.0 specification.
566 */
567struct ffa_memory_region_attributes {
568 /** The ID of the VM to which the memory is being given or shared. */
Daniel Boulbye79d2072021-03-03 11:34:53 +0000569 ffa_id_t receiver;
J-Alvesf3a393c2020-10-23 16:00:39 +0100570 /**
571 * The permissions with which the memory region should be mapped in the
572 * receiver's page table.
573 */
574 ffa_memory_access_permissions_t permissions;
575 /**
576 * Flags used during FFA_MEM_RETRIEVE_REQ and FFA_MEM_RETRIEVE_RESP
577 * for memory regions with multiple borrowers.
578 */
579 ffa_memory_receiver_flags_t flags;
580};
581
Karl Meakinbff9b3c2024-01-18 16:08:35 +0000582/**
583 * Endpoint RX/TX descriptor, as defined by Table 13.27 in FF-A v1.1 EAC0.
584 * It's used by the Hypervisor to describe the RX/TX buffers mapped by a VM
585 * to the SPMC, in order to allow indirect messaging.
586 */
587struct ffa_endpoint_rxtx_descriptor {
588 ffa_id_t endpoint_id;
589 uint16_t reserved;
590
591 /*
592 * 8-byte aligned offset from the base address of this descriptor to the
593 * `ffa_composite_memory_region` describing the RX buffer.
594 */
595 uint32_t rx_offset;
596
597 /*
598 * 8-byte aligned offset from the base address of this descriptor to the
599 * `ffa_composite_memory_region` describing the TX buffer.
600 */
601 uint32_t tx_offset;
602
603 /* Pad to align on 16-byte boundary. */
604 uint32_t pad;
605};
606
607_Static_assert(sizeof(struct ffa_endpoint_rxtx_descriptor) == 16,
608 "ffa_endpoint_rx_tx_descriptor must be 16 bytes wide");
609
J-Alvesf3a393c2020-10-23 16:00:39 +0100610/** Flags to control the behaviour of a memory sharing transaction. */
611typedef uint32_t ffa_memory_region_flags_t;
612
613/**
614 * Clear memory region contents after unmapping it from the sender and before
615 * mapping it for any receiver.
616 */
617#define FFA_MEMORY_REGION_FLAG_CLEAR 0x1U
618
619/**
620 * Whether the hypervisor may time slice the memory sharing or retrieval
621 * operation.
622 */
623#define FFA_MEMORY_REGION_FLAG_TIME_SLICE 0x2U
624
625/**
626 * Whether the hypervisor should clear the memory region after the receiver
627 * relinquishes it or is aborted.
628 */
629#define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH 0x4U
630
631#define FFA_MEMORY_REGION_TRANSACTION_TYPE_MASK ((0x3U) << 3)
632#define FFA_MEMORY_REGION_TRANSACTION_TYPE_UNSPECIFIED ((0x0U) << 3)
633#define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE ((0x1U) << 3)
634#define FFA_MEMORY_REGION_TRANSACTION_TYPE_LEND ((0x2U) << 3)
635#define FFA_MEMORY_REGION_TRANSACTION_TYPE_DONATE ((0x3U) << 3)
636
J-Alves0435cae2020-11-06 10:49:56 +0000637/** The maximum number of recipients a memory region may be sent to. */
J-Alvesf3253312024-01-18 17:05:26 +0000638#define MAX_MEM_SHARE_RECIPIENTS 2U
J-Alves0435cae2020-11-06 10:49:56 +0000639
Daniel Boulbya24f23a2023-11-15 18:23:40 +0000640struct ffa_memory_access_impdef {
641 uint64_t val[2];
642};
643
J-Alvesf3a393c2020-10-23 16:00:39 +0100644/**
645 * This corresponds to table "Endpoint memory access descriptor" of the FFA 1.0
646 * specification.
647 */
648struct ffa_memory_access {
649 struct ffa_memory_region_attributes receiver_permissions;
650 /**
651 * Offset in bytes from the start of the outer `ffa_memory_region` to
652 * an `ffa_composite_memory_region` struct.
653 */
654 uint32_t composite_memory_region_offset;
Daniel Boulbya24f23a2023-11-15 18:23:40 +0000655 /* Space for implementation defined information */
656 struct ffa_memory_access_impdef impdef;
J-Alvesf3a393c2020-10-23 16:00:39 +0100657 uint64_t reserved_0;
658};
659
660/**
661 * Information about a set of pages which are being shared. This corresponds to
J-Alvesb42d17f2022-07-04 12:42:13 +0100662 * table 10.20 of the FF-A v1.1 EAC0 specification, "Lend, donate or share
663 * memory transaction descriptor". Note that it is also used for retrieve
664 * requests and responses.
J-Alvesf3a393c2020-10-23 16:00:39 +0100665 */
666struct ffa_memory_region {
667 /**
668 * The ID of the VM which originally sent the memory region, i.e. the
669 * owner.
670 */
Daniel Boulbye79d2072021-03-03 11:34:53 +0000671 ffa_id_t sender;
J-Alvesf3a393c2020-10-23 16:00:39 +0100672 ffa_memory_attributes_t attributes;
J-Alvesf3a393c2020-10-23 16:00:39 +0100673 /** Flags to control behaviour of the transaction. */
674 ffa_memory_region_flags_t flags;
675 ffa_memory_handle_t handle;
676 /**
677 * An implementation defined value associated with the receiver and the
678 * memory region.
679 */
680 uint64_t tag;
J-Alvesb42d17f2022-07-04 12:42:13 +0100681 /** Size of the memory access descriptor. */
682 uint32_t memory_access_desc_size;
J-Alvesf3a393c2020-10-23 16:00:39 +0100683 /**
684 * The number of `ffa_memory_access` entries included in this
685 * transaction.
686 */
687 uint32_t receiver_count;
688 /**
J-Alvesb42d17f2022-07-04 12:42:13 +0100689 * Offset of the 'receivers' field, which relates to the memory access
690 * descriptors.
691 */
692 uint32_t receivers_offset;
693 /** Reserved field (12 bytes) must be 0. */
694 uint32_t reserved[3];
695 /**
696 * An array of `receiver_count` endpoint memory access descriptors.
J-Alvesf3a393c2020-10-23 16:00:39 +0100697 * Each one specifies a memory region offset, an endpoint and the
698 * attributes with which this memory region should be mapped in that
699 * endpoint's page table.
700 */
701 struct ffa_memory_access receivers[];
702};
703
704/**
705 * Descriptor used for FFA_MEM_RELINQUISH requests. This corresponds to table
J-Alvesb42d17f2022-07-04 12:42:13 +0100706 * 16.25 of the FF-A v1.1 EAC0 specification, "Descriptor to relinquish a memory
707 * region".
J-Alvesf3a393c2020-10-23 16:00:39 +0100708 */
709struct ffa_mem_relinquish {
710 ffa_memory_handle_t handle;
711 ffa_memory_region_flags_t flags;
712 uint32_t endpoint_count;
Daniel Boulbye79d2072021-03-03 11:34:53 +0000713 ffa_id_t endpoints[];
J-Alvesf3a393c2020-10-23 16:00:39 +0100714};
715
716static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t h1, uint32_t h2)
717{
J-Alves18c28052021-03-09 09:58:53 +0000718 return (ffa_notification_bitmap_t)h1 |
719 (ffa_notification_bitmap_t)h2 << 32;
J-Alvesf3a393c2020-10-23 16:00:39 +0100720}
721
Daniel Boulbyce386b12022-03-29 18:36:36 +0100722static inline ffa_memory_handle_t ffa_mem_success_handle(struct ffa_value r)
J-Alvesf3a393c2020-10-23 16:00:39 +0100723{
Daniel Boulbyce386b12022-03-29 18:36:36 +0100724 return ffa_assemble_handle(r.arg2, r.arg3);
J-Alvesf3a393c2020-10-23 16:00:39 +0100725}
726
Karl Meakin0d4f5ff2023-10-13 20:03:16 +0100727static inline ffa_memory_handle_t ffa_frag_handle(struct ffa_value r)
728{
729 return ffa_assemble_handle(r.arg1, r.arg2);
730}
731
732static inline ffa_id_t ffa_frag_sender(struct ffa_value args)
733{
734 return (args.arg4 >> 16) & 0xffff;
735}
736
J-Alvesf3a393c2020-10-23 16:00:39 +0100737/**
J-Alvesf0b3bd62024-01-18 17:01:37 +0000738 * To maintain forwards compatability we can't make assumptions about the size
739 * of the endpoint memory access descriptor so provide a helper function
740 * to get a receiver from the receiver array using the memory access descriptor
741 * size field from the memory region descriptor struct.
742 * Returns NULL if we cannot return the receiver.
743 */
744static inline struct ffa_memory_access *ffa_memory_region_get_receiver(
745 struct ffa_memory_region *memory_region, uint32_t receiver_index)
746{
747 uint32_t memory_access_desc_size =
748 memory_region->memory_access_desc_size;
749
750 if (receiver_index >= memory_region->receiver_count) {
751 return NULL;
752 }
753
754 /*
755 * Memory access descriptor size cannot be greater than the size of
756 * the memory access descriptor defined by the current FF-A version.
757 */
758 if (memory_access_desc_size > sizeof(struct ffa_memory_access)) {
759 return NULL;
760 }
761
762 /* Check we cannot use receivers offset to cause overflow. */
763 if (memory_region->receivers_offset !=
764 sizeof(struct ffa_memory_region)) {
765 return NULL;
766 }
767
768 return (struct ffa_memory_access *)((uint8_t *)memory_region +
769 memory_region->receivers_offset +
770 (receiver_index *
771 memory_access_desc_size));
772}
773
774/**
J-Alvesf3a393c2020-10-23 16:00:39 +0100775 * Gets the `ffa_composite_memory_region` for the given receiver from an
776 * `ffa_memory_region`, or NULL if it is not valid.
777 */
778static inline struct ffa_composite_memory_region *
779ffa_memory_region_get_composite(struct ffa_memory_region *memory_region,
780 uint32_t receiver_index)
781{
782 uint32_t offset = memory_region->receivers[receiver_index]
783 .composite_memory_region_offset;
784
785 if (offset == 0) {
786 return NULL;
787 }
788
789 return (struct ffa_composite_memory_region *)((uint8_t *)memory_region +
790 offset);
791}
792
793static inline uint32_t ffa_mem_relinquish_init(
794 struct ffa_mem_relinquish *relinquish_request,
795 ffa_memory_handle_t handle, ffa_memory_region_flags_t flags,
Daniel Boulbye79d2072021-03-03 11:34:53 +0000796 ffa_id_t sender)
J-Alvesf3a393c2020-10-23 16:00:39 +0100797{
798 relinquish_request->handle = handle;
799 relinquish_request->flags = flags;
800 relinquish_request->endpoint_count = 1;
801 relinquish_request->endpoints[0] = sender;
Daniel Boulbye79d2072021-03-03 11:34:53 +0000802 return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_id_t);
J-Alvesf3a393c2020-10-23 16:00:39 +0100803}
804
805uint32_t ffa_memory_retrieve_request_init(
806 struct ffa_memory_region *memory_region, ffa_memory_handle_t handle,
Karl Meakin1331a8c2023-09-14 16:25:15 +0100807 ffa_id_t sender, struct ffa_memory_access receivers[],
808 uint32_t receiver_count, uint32_t tag, ffa_memory_region_flags_t flags,
J-Alvesf3a393c2020-10-23 16:00:39 +0100809 enum ffa_memory_type type, enum ffa_memory_cacheability cacheability,
810 enum ffa_memory_shareability shareability);
811
Karl Meakin3d879b82023-06-16 10:32:08 +0100812void ffa_hypervisor_retrieve_request_init(struct ffa_memory_region *region,
813 ffa_memory_handle_t handle);
814
J-Alvesf3a393c2020-10-23 16:00:39 +0100815uint32_t ffa_memory_region_init(
816 struct ffa_memory_region *memory_region, size_t memory_region_max_size,
Karl Meakin1331a8c2023-09-14 16:25:15 +0100817 ffa_id_t sender, struct ffa_memory_access receivers[],
818 uint32_t receiver_count,
J-Alvesf3a393c2020-10-23 16:00:39 +0100819 const struct ffa_memory_region_constituent constituents[],
820 uint32_t constituent_count, uint32_t tag,
Karl Meakin1331a8c2023-09-14 16:25:15 +0100821 ffa_memory_region_flags_t flags, enum ffa_memory_type type,
822 enum ffa_memory_cacheability cacheability,
J-Alvesf3a393c2020-10-23 16:00:39 +0100823 enum ffa_memory_shareability shareability, uint32_t *total_length,
824 uint32_t *fragment_length);
825
Karl Meakin0d4f5ff2023-10-13 20:03:16 +0100826uint32_t ffa_memory_fragment_init(
827 struct ffa_memory_region_constituent *fragment,
828 size_t fragment_max_size,
829 const struct ffa_memory_region_constituent constituents[],
830 uint32_t constituent_count, uint32_t *fragment_length);
831
Daniel Boulbyce386b12022-03-29 18:36:36 +0100832static inline ffa_id_t ffa_dir_msg_dest(struct ffa_value val) {
833 return (ffa_id_t)val.arg1 & U(0xFFFF);
J-Alves6cb21d92021-01-07 15:18:12 +0000834}
835
Daniel Boulbyce386b12022-03-29 18:36:36 +0100836static inline ffa_id_t ffa_dir_msg_source(struct ffa_value val) {
837 return (ffa_id_t)(val.arg1 >> 16U);
J-Alves6cb21d92021-01-07 15:18:12 +0000838}
839
Daniel Boulbyce386b12022-03-29 18:36:36 +0100840struct ffa_value ffa_msg_send_direct_req64(ffa_id_t source_id,
841 ffa_id_t dest_id, uint64_t arg0,
842 uint64_t arg1, uint64_t arg2,
843 uint64_t arg3, uint64_t arg4);
J-Alvesd1aae292020-10-08 17:16:58 +0100844
Daniel Boulbyce386b12022-03-29 18:36:36 +0100845struct ffa_value ffa_msg_send_direct_req32(ffa_id_t source_id,
846 ffa_id_t dest_id, uint32_t arg0,
847 uint32_t arg1, uint32_t arg2,
848 uint32_t arg3, uint32_t arg4);
J-Alvesecd30742021-02-19 18:31:06 +0000849
Daniel Boulbyce386b12022-03-29 18:36:36 +0100850struct ffa_value ffa_msg_send_direct_resp64(ffa_id_t source_id,
851 ffa_id_t dest_id, uint64_t arg0,
852 uint64_t arg1, uint64_t arg2,
853 uint64_t arg3, uint64_t arg4);
J-Alvesecd30742021-02-19 18:31:06 +0000854
Daniel Boulbyce386b12022-03-29 18:36:36 +0100855struct ffa_value ffa_msg_send_direct_resp32(ffa_id_t source_id,
856 ffa_id_t dest_id, uint32_t arg0,
857 uint32_t arg1, uint32_t arg2,
858 uint32_t arg3, uint32_t arg4);
J-Alves035b7d02021-02-11 10:40:35 +0000859
Daniel Boulbyce386b12022-03-29 18:36:36 +0100860struct ffa_value ffa_run(uint32_t dest_id, uint32_t vcpu_id);
861struct ffa_value ffa_version(uint32_t input_version);
862struct ffa_value ffa_id_get(void);
863struct ffa_value ffa_spm_id_get(void);
864struct ffa_value ffa_msg_wait(void);
865struct ffa_value ffa_error(int32_t error_code);
866struct ffa_value ffa_features(uint32_t feature);
Karl Meakin31b81772023-03-14 15:38:17 +0000867struct ffa_value ffa_features_with_input_property(uint32_t feature,
868 uint32_t param);
Daniel Boulbyce386b12022-03-29 18:36:36 +0100869struct ffa_value ffa_partition_info_get(const struct ffa_uuid uuid);
J-Alves067daca2024-04-08 17:31:54 +0100870struct ffa_value ffa_rx_release_with_id(ffa_id_t vm_id);
Daniel Boulbyce386b12022-03-29 18:36:36 +0100871struct ffa_value ffa_rx_release(void);
872struct ffa_value ffa_rxtx_map(uintptr_t send, uintptr_t recv, uint32_t pages);
Karl Meakinbff9b3c2024-01-18 16:08:35 +0000873struct ffa_value ffa_rxtx_unmap_with_id(uint32_t id);
Daniel Boulbyce386b12022-03-29 18:36:36 +0100874struct ffa_value ffa_rxtx_unmap(void);
J-Alves779fba62024-04-05 14:14:40 +0100875struct ffa_value ffa_msg_send2(uint32_t flags);
Daniel Boulbyce386b12022-03-29 18:36:36 +0100876struct ffa_value ffa_mem_donate(uint32_t descriptor_length,
877 uint32_t fragment_length);
878struct ffa_value ffa_mem_lend(uint32_t descriptor_length,
J-Alves3ea46d12020-09-09 11:13:05 +0100879 uint32_t fragment_length);
Daniel Boulbyce386b12022-03-29 18:36:36 +0100880struct ffa_value ffa_mem_share(uint32_t descriptor_length,
881 uint32_t fragment_length);
882struct ffa_value ffa_mem_retrieve_req(uint32_t descriptor_length,
883 uint32_t fragment_length);
884struct ffa_value ffa_mem_relinquish(void);
885struct ffa_value ffa_mem_reclaim(uint64_t handle, uint32_t flags);
Karl Meakin0d4f5ff2023-10-13 20:03:16 +0100886struct ffa_value ffa_mem_frag_rx(ffa_memory_handle_t handle,
887 uint32_t fragment_length);
888struct ffa_value ffa_mem_frag_tx(ffa_memory_handle_t handle,
889 uint32_t fragment_length);
Daniel Boulbyce386b12022-03-29 18:36:36 +0100890struct ffa_value ffa_notification_bitmap_create(ffa_id_t vm_id,
891 ffa_vcpu_count_t vcpu_count);
892struct ffa_value ffa_notification_bitmap_destroy(ffa_id_t vm_id);
893struct ffa_value ffa_notification_bind(ffa_id_t sender, ffa_id_t receiver,
894 uint32_t flags,
J-Alves18c28052021-03-09 09:58:53 +0000895 ffa_notification_bitmap_t notifications);
Daniel Boulbyce386b12022-03-29 18:36:36 +0100896struct ffa_value ffa_notification_unbind(ffa_id_t sender, ffa_id_t receiver,
897 ffa_notification_bitmap_t notifications);
898struct ffa_value ffa_notification_set(ffa_id_t sender, ffa_id_t receiver,
899 uint32_t flags,
900 ffa_notification_bitmap_t bitmap);
901struct ffa_value ffa_notification_get(ffa_id_t receiver, uint32_t vcpu_id,
902 uint32_t flags);
903struct ffa_value ffa_notification_info_get(void);
Maksims Svecovs0b452232022-05-24 11:30:34 +0100904
905struct ffa_value ffa_console_log(const char* message, size_t char_count);
Raghu Krishnamurthyab5321a2023-04-23 16:14:28 -0700906struct ffa_value ffa_partition_info_get_regs(const struct ffa_uuid uuid,
907 const uint16_t start_index,
908 const uint16_t tag);
Karl Meakin367ff542023-11-01 15:05:37 +0000909
Daniel Boulbya24f23a2023-11-15 18:23:40 +0000910struct ffa_memory_access ffa_memory_access_init(
Karl Meakin367ff542023-11-01 15:05:37 +0000911 ffa_id_t receiver_id, enum ffa_data_access data_access,
912 enum ffa_instruction_access instruction_access,
Daniel Boulbya24f23a2023-11-15 18:23:40 +0000913 ffa_memory_receiver_flags_t flags,
914 struct ffa_memory_access_impdef *impdef);
Karl Meakin367ff542023-11-01 15:05:37 +0000915
Karl Meakinbff9b3c2024-01-18 16:08:35 +0000916void ffa_endpoint_rxtx_descriptor_init(
917 struct ffa_endpoint_rxtx_descriptor *desc, ffa_id_t endpoint_id,
918 void *rx_address, void *tx_address);
919
920struct ffa_value ffa_rxtx_map_forward(
921 struct ffa_endpoint_rxtx_descriptor *desc, ffa_id_t endpoint_id,
922 void *rx_address, void *tx_address);
923
J-Alves7581c382020-05-07 18:34:20 +0100924#endif /* __ASSEMBLY__ */
925
926#endif /* FFA_HELPERS_H */