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