blob: 30d50b7f30b87c39cfe40cee7b3720d550e8c3b2 [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
Olivier Deprez62d99e32020-01-09 15:58:07 +010013#define FFA_VERSION_MAJOR 0x1
14#define FFA_VERSION_MINOR 0x0
15
16#define FFA_VERSION_MAJOR_OFFSET 16
17
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010018/* clang-format off */
19
20#define FFA_LOW_32_ID 0x84000060
21#define FFA_HIGH_32_ID 0x8400007F
22#define FFA_LOW_64_ID 0xC4000060
Fuad Tabbada72d142020-07-30 09:17:05 +010023#define FFA_HIGH_64_ID 0xC400007F
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010024
25/* FF-A function identifiers. */
26#define FFA_ERROR_32 0x84000060
27#define FFA_SUCCESS_32 0x84000061
Max Shvetsov9c0ebe42020-08-27 12:37:57 +010028#define FFA_SUCCESS_64 0xC4000061
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010029#define FFA_INTERRUPT_32 0x84000062
30#define FFA_VERSION_32 0x84000063
31#define FFA_FEATURES_32 0x84000064
32#define FFA_RX_RELEASE_32 0x84000065
33#define FFA_RXTX_MAP_32 0x84000066
34#define FFA_RXTX_MAP_64 0xC4000066
35#define FFA_RXTX_UNMAP_32 0x84000067
36#define FFA_PARTITION_INFO_GET_32 0x84000068
37#define FFA_ID_GET_32 0x84000069
38#define FFA_MSG_POLL_32 0x8400006A
39#define FFA_MSG_WAIT_32 0x8400006B
40#define FFA_YIELD_32 0x8400006C
41#define FFA_RUN_32 0x8400006D
42#define FFA_MSG_SEND_32 0x8400006E
43#define FFA_MSG_SEND_DIRECT_REQ_32 0x8400006F
44#define FFA_MSG_SEND_DIRECT_RESP_32 0x84000070
45#define FFA_MEM_DONATE_32 0x84000071
46#define FFA_MEM_LEND_32 0x84000072
47#define FFA_MEM_SHARE_32 0x84000073
48#define FFA_MEM_RETRIEVE_REQ_32 0x84000074
49#define FFA_MEM_RETRIEVE_RESP_32 0x84000075
50#define FFA_MEM_RELINQUISH_32 0x84000076
51#define FFA_MEM_RECLAIM_32 0x84000077
Andrew Walbranca808b12020-05-15 17:22:28 +010052#define FFA_MEM_FRAG_RX_32 0x8400007A
53#define FFA_MEM_FRAG_TX_32 0x8400007B
Max Shvetsov9c0ebe42020-08-27 12:37:57 +010054#define FFA_SECONDARY_EP_REGISTER_32 0x84000084
55#define FFA_SECONDARY_EP_REGISTER_64 0xC4000084
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010056
57/* FF-A error codes. */
58#define FFA_NOT_SUPPORTED INT32_C(-1)
59#define FFA_INVALID_PARAMETERS INT32_C(-2)
60#define FFA_NO_MEMORY INT32_C(-3)
61#define FFA_BUSY INT32_C(-4)
62#define FFA_INTERRUPTED INT32_C(-5)
63#define FFA_DENIED INT32_C(-6)
64#define FFA_RETRY INT32_C(-7)
65#define FFA_ABORTED INT32_C(-8)
66
67/* clang-format on */
68
69/* FF-A function specific constants. */
70#define FFA_MSG_RECV_BLOCK 0x1
71#define FFA_MSG_RECV_BLOCK_MASK 0x1
72
73#define FFA_MSG_SEND_NOTIFY 0x1
74#define FFA_MSG_SEND_NOTIFY_MASK 0x1
75
76#define FFA_MEM_RECLAIM_CLEAR 0x1
77
78#define FFA_SLEEP_INDEFINITE 0
79
80/**
81 * For use where the FF-A specification refers explicitly to '4K pages'. Not to
82 * be confused with PAGE_SIZE, which is the translation granule Hafnium is
83 * configured to use.
84 */
85#define FFA_PAGE_SIZE 4096
86
87/* The maximum length possible for a single message. */
88#define FFA_MSG_PAYLOAD_MAX HF_MAILBOX_SIZE
89
90enum ffa_data_access {
91 FFA_DATA_ACCESS_NOT_SPECIFIED,
92 FFA_DATA_ACCESS_RO,
93 FFA_DATA_ACCESS_RW,
94 FFA_DATA_ACCESS_RESERVED,
95};
96
97enum ffa_instruction_access {
98 FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED,
99 FFA_INSTRUCTION_ACCESS_NX,
100 FFA_INSTRUCTION_ACCESS_X,
101 FFA_INSTRUCTION_ACCESS_RESERVED,
102};
103
104enum ffa_memory_type {
105 FFA_MEMORY_NOT_SPECIFIED_MEM,
106 FFA_MEMORY_DEVICE_MEM,
107 FFA_MEMORY_NORMAL_MEM,
108};
109
110enum ffa_memory_cacheability {
111 FFA_MEMORY_CACHE_RESERVED = 0x0,
112 FFA_MEMORY_CACHE_NON_CACHEABLE = 0x1,
113 FFA_MEMORY_CACHE_RESERVED_1 = 0x2,
114 FFA_MEMORY_CACHE_WRITE_BACK = 0x3,
115 FFA_MEMORY_DEV_NGNRNE = 0x0,
116 FFA_MEMORY_DEV_NGNRE = 0x1,
117 FFA_MEMORY_DEV_NGRE = 0x2,
118 FFA_MEMORY_DEV_GRE = 0x3,
119};
120
121enum ffa_memory_shareability {
122 FFA_MEMORY_SHARE_NON_SHAREABLE,
123 FFA_MEMORY_SHARE_RESERVED,
124 FFA_MEMORY_OUTER_SHAREABLE,
125 FFA_MEMORY_INNER_SHAREABLE,
126};
127
128typedef uint8_t ffa_memory_access_permissions_t;
129
130/**
131 * This corresponds to table 44 of the FF-A 1.0 EAC specification, "Memory
132 * region attributes descriptor".
133 */
134typedef uint8_t ffa_memory_attributes_t;
135
136#define FFA_DATA_ACCESS_OFFSET (0x0U)
137#define FFA_DATA_ACCESS_MASK ((0x3U) << FFA_DATA_ACCESS_OFFSET)
138
139#define FFA_INSTRUCTION_ACCESS_OFFSET (0x2U)
140#define FFA_INSTRUCTION_ACCESS_MASK ((0x3U) << FFA_INSTRUCTION_ACCESS_OFFSET)
141
142#define FFA_MEMORY_TYPE_OFFSET (0x4U)
143#define FFA_MEMORY_TYPE_MASK ((0x3U) << FFA_MEMORY_TYPE_OFFSET)
144
145#define FFA_MEMORY_CACHEABILITY_OFFSET (0x2U)
146#define FFA_MEMORY_CACHEABILITY_MASK ((0x3U) << FFA_MEMORY_CACHEABILITY_OFFSET)
147
148#define FFA_MEMORY_SHAREABILITY_OFFSET (0x0U)
149#define FFA_MEMORY_SHAREABILITY_MASK ((0x3U) << FFA_MEMORY_SHAREABILITY_OFFSET)
150
151#define ATTR_FUNCTION_SET(name, container_type, offset, mask) \
152 static inline void ffa_set_##name##_attr(container_type *attr, \
153 const enum ffa_##name perm) \
154 { \
155 *attr = (*attr & ~(mask)) | ((perm << offset) & mask); \
156 }
157
158#define ATTR_FUNCTION_GET(name, container_type, offset, mask) \
159 static inline enum ffa_##name ffa_get_##name##_attr( \
160 container_type attr) \
161 { \
162 return (enum ffa_##name)((attr & mask) >> offset); \
163 }
164
165ATTR_FUNCTION_SET(data_access, ffa_memory_access_permissions_t,
166 FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK)
167ATTR_FUNCTION_GET(data_access, ffa_memory_access_permissions_t,
168 FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK)
169
170ATTR_FUNCTION_SET(instruction_access, ffa_memory_access_permissions_t,
171 FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK)
172ATTR_FUNCTION_GET(instruction_access, ffa_memory_access_permissions_t,
173 FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK)
174
175ATTR_FUNCTION_SET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET,
176 FFA_MEMORY_TYPE_MASK)
177ATTR_FUNCTION_GET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET,
178 FFA_MEMORY_TYPE_MASK)
179
180ATTR_FUNCTION_SET(memory_cacheability, ffa_memory_attributes_t,
181 FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK)
182ATTR_FUNCTION_GET(memory_cacheability, ffa_memory_attributes_t,
183 FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK)
184
185ATTR_FUNCTION_SET(memory_shareability, ffa_memory_attributes_t,
186 FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK)
187ATTR_FUNCTION_GET(memory_shareability, ffa_memory_attributes_t,
188 FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK)
189
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100190/**
191 * A globally-unique ID assigned by the hypervisor for a region of memory being
192 * sent between VMs.
193 */
194typedef uint64_t ffa_memory_handle_t;
195
J-Alves917d2f22020-10-30 18:39:30 +0000196#define FFA_MEMORY_HANDLE_ALLOCATOR_MASK \
197 ((ffa_memory_handle_t)(UINT64_C(1) << 63))
198#define FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR \
199 ((ffa_memory_handle_t)(UINT64_C(1) << 63))
200
201#define FFA_MEMORY_HANDLE_ALLOCATOR_SPMC (UINT64_C(0) << 63)
202#define FFA_MEMORY_HANDLE_INVALID (~UINT64_C(0))
203
204/** The ID of a VM. These are assigned sequentially starting with an offset. */
205typedef uint16_t ffa_vm_id_t;
206
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100207/**
208 * A count of VMs. This has the same range as the VM IDs but we give it a
209 * different name to make the different semantics clear.
210 */
211typedef ffa_vm_id_t ffa_vm_count_t;
212
213/** The index of a vCPU within a particular VM. */
214typedef uint16_t ffa_vcpu_index_t;
215
216/**
217 * A count of vCPUs. This has the same range as the vCPU indices but we give it
218 * a different name to make the different semantics clear.
219 */
220typedef ffa_vcpu_index_t ffa_vcpu_count_t;
221
222/** Parameter and return type of FF-A functions. */
223struct ffa_value {
224 uint64_t func;
225 uint64_t arg1;
226 uint64_t arg2;
227 uint64_t arg3;
228 uint64_t arg4;
229 uint64_t arg5;
230 uint64_t arg6;
231 uint64_t arg7;
232};
233
J-Alves13318e32021-02-22 17:21:00 +0000234static inline int32_t ffa_error_code(struct ffa_value val)
235{
236 return (int32_t)val.arg2;
237}
238
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100239static inline ffa_vm_id_t ffa_msg_send_sender(struct ffa_value args)
240{
241 return (args.arg1 >> 16) & 0xffff;
242}
243
244static inline ffa_vm_id_t ffa_msg_send_receiver(struct ffa_value args)
245{
246 return args.arg1 & 0xffff;
247}
248
249static inline uint32_t ffa_msg_send_size(struct ffa_value args)
250{
251 return args.arg3;
252}
253
254static inline uint32_t ffa_msg_send_attributes(struct ffa_value args)
255{
256 return args.arg4;
257}
258
Andrew Walbran1bbe9402020-04-30 16:47:13 +0100259static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t a1, uint32_t a2)
260{
261 return (uint64_t)a1 | (uint64_t)a2 << 32;
262}
263
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100264static inline ffa_memory_handle_t ffa_mem_success_handle(struct ffa_value args)
265{
Andrew Walbran1bbe9402020-04-30 16:47:13 +0100266 return ffa_assemble_handle(args.arg2, args.arg3);
267}
268
Andrew Walbranca808b12020-05-15 17:22:28 +0100269static inline ffa_memory_handle_t ffa_frag_handle(struct ffa_value args)
270{
271 return ffa_assemble_handle(args.arg1, args.arg2);
272}
273
Andrew Walbran1bbe9402020-04-30 16:47:13 +0100274static inline struct ffa_value ffa_mem_success(ffa_memory_handle_t handle)
275{
276 return (struct ffa_value){.func = FFA_SUCCESS_32,
277 .arg2 = (uint32_t)handle,
278 .arg3 = (uint32_t)(handle >> 32)};
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100279}
280
281static inline ffa_vm_id_t ffa_vm_id(struct ffa_value args)
282{
283 return (args.arg1 >> 16) & 0xffff;
284}
285
286static inline ffa_vcpu_index_t ffa_vcpu_index(struct ffa_value args)
287{
288 return args.arg1 & 0xffff;
289}
290
291static inline uint64_t ffa_vm_vcpu(ffa_vm_id_t vm_id,
292 ffa_vcpu_index_t vcpu_index)
293{
294 return ((uint32_t)vm_id << 16) | vcpu_index;
295}
296
Andrew Walbranca808b12020-05-15 17:22:28 +0100297static inline ffa_vm_id_t ffa_frag_sender(struct ffa_value args)
298{
299 return (args.arg4 >> 16) & 0xffff;
300}
301
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100302/**
Fuad Tabbae4efcc32020-07-16 15:37:27 +0100303 * Holds the UUID in a struct that is mappable directly to the SMCC calling
304 * convention, which is used for FF-A calls.
305 *
306 * Refer to table 84 of the FF-A 1.0 EAC specification as well as section 5.3
307 * of the SMCC Spec 1.2.
308 */
309struct ffa_uuid {
310 uint32_t uuid[4];
311};
312
313static inline void ffa_uuid_init(uint32_t w0, uint32_t w1, uint32_t w2,
314 uint32_t w3, struct ffa_uuid *uuid)
315{
316 uuid->uuid[0] = w0;
317 uuid->uuid[1] = w1;
318 uuid->uuid[2] = w2;
319 uuid->uuid[3] = w3;
320}
321
322static inline bool ffa_uuid_equal(const struct ffa_uuid *uuid1,
323 const struct ffa_uuid *uuid2)
324{
325 return (uuid1->uuid[0] == uuid2->uuid[0]) &&
326 (uuid1->uuid[1] == uuid2->uuid[1]) &&
327 (uuid1->uuid[2] == uuid2->uuid[2]) &&
328 (uuid1->uuid[3] == uuid2->uuid[3]);
329}
330
331static inline bool ffa_uuid_is_null(const struct ffa_uuid *uuid)
332{
333 return (uuid->uuid[0] == 0) && (uuid->uuid[1] == 0) &&
334 (uuid->uuid[2] == 0) && (uuid->uuid[3] == 0);
335}
336
337/**
338 * Flags to determine the partition properties, as required by
339 * FFA_PARTITION_INFO_GET.
340 *
341 * The values of the flags are specified in table 82 of the FF-A 1.0 EAC
342 * specification, "Partition information descriptor, partition properties".
343 */
344typedef uint32_t ffa_partition_properties_t;
345
346/** Partition property: partition supports receipt of direct requests. */
347#define FFA_PARTITION_DIRECT_RECV 0x1
348
349/** Partition property: partition can send direct requests. */
350#define FFA_PARTITION_DIRECT_SEND 0x2
351
352/** Partition property: partition can send and receive indirect messages. */
353#define FFA_PARTITION_INDIRECT_MSG 0x4
354
355/**
356 * Holds information returned for each partition by the FFA_PARTITION_INFO_GET
357 * interface.
358 * This corresponds to table 82 of the FF-A 1.0 EAC specification, "Partition
359 * information descriptor".
360 */
361struct ffa_partition_info {
362 ffa_vm_id_t vm_id;
363 ffa_vcpu_count_t vcpu_count;
364 ffa_partition_properties_t properties;
365};
366
367/**
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100368 * A set of contiguous pages which is part of a memory region. This corresponds
369 * to table 40 of the FF-A 1.0 EAC specification, "Constituent memory region
370 * descriptor".
371 */
372struct ffa_memory_region_constituent {
373 /**
374 * The base IPA of the constituent memory region, aligned to 4 kiB page
375 * size granularity.
376 */
377 uint64_t address;
378 /** The number of 4 kiB pages in the constituent memory region. */
379 uint32_t page_count;
380 /** Reserved field, must be 0. */
381 uint32_t reserved;
382};
383
384/**
385 * A set of pages comprising a memory region. This corresponds to table 39 of
386 * the FF-A 1.0 EAC specification, "Composite memory region descriptor".
387 */
388struct ffa_composite_memory_region {
389 /**
390 * The total number of 4 kiB pages included in this memory region. This
391 * must be equal to the sum of page counts specified in each
392 * `ffa_memory_region_constituent`.
393 */
394 uint32_t page_count;
395 /**
396 * The number of constituents (`ffa_memory_region_constituent`)
397 * included in this memory region range.
398 */
399 uint32_t constituent_count;
400 /** Reserved field, must be 0. */
401 uint64_t reserved_0;
402 /** An array of `constituent_count` memory region constituents. */
403 struct ffa_memory_region_constituent constituents[];
404};
405
406/** Flags to indicate properties of receivers during memory region retrieval. */
407typedef uint8_t ffa_memory_receiver_flags_t;
408
409/**
410 * This corresponds to table 41 of the FF-A 1.0 EAC specification, "Memory
411 * access permissions descriptor".
412 */
413struct ffa_memory_region_attributes {
414 /** The ID of the VM to which the memory is being given or shared. */
415 ffa_vm_id_t receiver;
416 /**
417 * The permissions with which the memory region should be mapped in the
418 * receiver's page table.
419 */
420 ffa_memory_access_permissions_t permissions;
421 /**
422 * Flags used during FFA_MEM_RETRIEVE_REQ and FFA_MEM_RETRIEVE_RESP
423 * for memory regions with multiple borrowers.
424 */
425 ffa_memory_receiver_flags_t flags;
426};
427
428/** Flags to control the behaviour of a memory sharing transaction. */
429typedef uint32_t ffa_memory_region_flags_t;
430
431/**
432 * Clear memory region contents after unmapping it from the sender and before
433 * mapping it for any receiver.
434 */
435#define FFA_MEMORY_REGION_FLAG_CLEAR 0x1
436
437/**
438 * Whether the hypervisor may time slice the memory sharing or retrieval
439 * operation.
440 */
441#define FFA_MEMORY_REGION_FLAG_TIME_SLICE 0x2
442
443/**
444 * Whether the hypervisor should clear the memory region after the receiver
445 * relinquishes it or is aborted.
446 */
447#define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH 0x4
448
449#define FFA_MEMORY_REGION_TRANSACTION_TYPE_MASK ((0x3U) << 3)
450#define FFA_MEMORY_REGION_TRANSACTION_TYPE_UNSPECIFIED ((0x0U) << 3)
451#define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE ((0x1U) << 3)
452#define FFA_MEMORY_REGION_TRANSACTION_TYPE_LEND ((0x2U) << 3)
453#define FFA_MEMORY_REGION_TRANSACTION_TYPE_DONATE ((0x3U) << 3)
454
455/**
456 * This corresponds to table 42 of the FF-A 1.0 EAC specification, "Endpoint
457 * memory access descriptor".
458 */
459struct ffa_memory_access {
460 struct ffa_memory_region_attributes receiver_permissions;
461 /**
462 * Offset in bytes from the start of the outer `ffa_memory_region` to
463 * an `ffa_composite_memory_region` struct.
464 */
465 uint32_t composite_memory_region_offset;
466 uint64_t reserved_0;
467};
468
469/**
470 * Information about a set of pages which are being shared. This corresponds to
471 * table 45 of the FF-A 1.0 EAC specification, "Lend, donate or share memory
472 * transaction descriptor". Note that it is also used for retrieve requests and
473 * responses.
474 */
475struct ffa_memory_region {
476 /**
477 * The ID of the VM which originally sent the memory region, i.e. the
478 * owner.
479 */
480 ffa_vm_id_t sender;
481 ffa_memory_attributes_t attributes;
482 /** Reserved field, must be 0. */
483 uint8_t reserved_0;
484 /** Flags to control behaviour of the transaction. */
485 ffa_memory_region_flags_t flags;
486 ffa_memory_handle_t handle;
487 /**
488 * An implementation defined value associated with the receiver and the
489 * memory region.
490 */
491 uint64_t tag;
492 /** Reserved field, must be 0. */
493 uint32_t reserved_1;
494 /**
495 * The number of `ffa_memory_access` entries included in this
496 * transaction.
497 */
498 uint32_t receiver_count;
499 /**
500 * An array of `attribute_count` endpoint memory access descriptors.
501 * Each one specifies a memory region offset, an endpoint and the
502 * attributes with which this memory region should be mapped in that
503 * endpoint's page table.
504 */
505 struct ffa_memory_access receivers[];
506};
507
508/**
509 * Descriptor used for FFA_MEM_RELINQUISH requests. This corresponds to table
510 * 150 of the FF-A 1.0 EAC specification, "Descriptor to relinquish a memory
511 * region".
512 */
513struct ffa_mem_relinquish {
514 ffa_memory_handle_t handle;
515 ffa_memory_region_flags_t flags;
516 uint32_t endpoint_count;
517 ffa_vm_id_t endpoints[];
518};
519
520/**
521 * Gets the `ffa_composite_memory_region` for the given receiver from an
522 * `ffa_memory_region`, or NULL if it is not valid.
523 */
524static inline struct ffa_composite_memory_region *
525ffa_memory_region_get_composite(struct ffa_memory_region *memory_region,
526 uint32_t receiver_index)
527{
528 uint32_t offset = memory_region->receivers[receiver_index]
529 .composite_memory_region_offset;
530
531 if (offset == 0) {
532 return NULL;
533 }
534
535 return (struct ffa_composite_memory_region *)((uint8_t *)memory_region +
536 offset);
537}
538
539static inline uint32_t ffa_mem_relinquish_init(
540 struct ffa_mem_relinquish *relinquish_request,
541 ffa_memory_handle_t handle, ffa_memory_region_flags_t flags,
542 ffa_vm_id_t sender)
543{
544 relinquish_request->handle = handle;
545 relinquish_request->flags = flags;
546 relinquish_request->endpoint_count = 1;
547 relinquish_request->endpoints[0] = sender;
548 return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_vm_id_t);
549}
550
551uint32_t ffa_memory_region_init(
Andrew Walbranca808b12020-05-15 17:22:28 +0100552 struct ffa_memory_region *memory_region, size_t memory_region_max_size,
553 ffa_vm_id_t sender, ffa_vm_id_t receiver,
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100554 const struct ffa_memory_region_constituent constituents[],
555 uint32_t constituent_count, uint32_t tag,
556 ffa_memory_region_flags_t flags, enum ffa_data_access data_access,
557 enum ffa_instruction_access instruction_access,
558 enum ffa_memory_type type, enum ffa_memory_cacheability cacheability,
Andrew Walbranca808b12020-05-15 17:22:28 +0100559 enum ffa_memory_shareability shareability, uint32_t *fragment_length,
560 uint32_t *total_length);
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100561uint32_t ffa_memory_retrieve_request_init(
562 struct ffa_memory_region *memory_region, ffa_memory_handle_t handle,
563 ffa_vm_id_t sender, ffa_vm_id_t receiver, uint32_t tag,
564 ffa_memory_region_flags_t flags, enum ffa_data_access data_access,
565 enum ffa_instruction_access instruction_access,
566 enum ffa_memory_type type, enum ffa_memory_cacheability cacheability,
567 enum ffa_memory_shareability shareability);
568uint32_t ffa_memory_lender_retrieve_request_init(
569 struct ffa_memory_region *memory_region, ffa_memory_handle_t handle,
570 ffa_vm_id_t sender);
Andrew Walbranca808b12020-05-15 17:22:28 +0100571bool ffa_retrieved_memory_region_init(
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100572 struct ffa_memory_region *response, size_t response_max_size,
573 ffa_vm_id_t sender, ffa_memory_attributes_t attributes,
574 ffa_memory_region_flags_t flags, ffa_memory_handle_t handle,
575 ffa_vm_id_t receiver, ffa_memory_access_permissions_t permissions,
Andrew Walbranca808b12020-05-15 17:22:28 +0100576 uint32_t page_count, uint32_t total_constituent_count,
Andrew Walbranb5ab43c2020-04-30 11:32:54 +0100577 const struct ffa_memory_region_constituent constituents[],
Andrew Walbranca808b12020-05-15 17:22:28 +0100578 uint32_t fragment_constituent_count, uint32_t *total_length,
579 uint32_t *fragment_length);
580uint32_t ffa_memory_fragment_init(
581 struct ffa_memory_region_constituent *fragment,
582 size_t fragment_max_size,
583 const struct ffa_memory_region_constituent constituents[],
584 uint32_t constituent_count, uint32_t *fragment_length);