J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 1 | /* |
Max Shvetsov | 103e056 | 2021-02-04 16:58:31 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, Arm Limited. All rights reserved. |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef FFA_HELPERS_H |
| 8 | #define FFA_HELPERS_H |
| 9 | |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 10 | #include <ffa_svc.h> |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 11 | #include <tftf_lib.h> |
| 12 | #include <utils_def.h> |
| 13 | |
| 14 | /* This error code must be different to the ones used by FFA */ |
| 15 | #define FFA_TFTF_ERROR -42 |
| 16 | |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 17 | typedef unsigned short ffa_id_t; |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 18 | typedef unsigned short ffa_vm_count_t; |
| 19 | typedef unsigned short ffa_vcpu_count_t; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 20 | typedef uint64_t ffa_memory_handle_t; |
| 21 | /** Flags to indicate properties of receivers during memory region retrieval. */ |
| 22 | typedef uint8_t ffa_memory_receiver_flags_t; |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 23 | |
J-Alves | d708c03 | 2020-11-19 12:14:21 +0000 | [diff] [blame] | 24 | struct ffa_uuid { |
| 25 | const uint32_t uuid[4]; |
| 26 | }; |
| 27 | |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 28 | #ifndef __ASSEMBLY__ |
| 29 | |
J-Alves | 18c2805 | 2021-03-09 09:58:53 +0000 | [diff] [blame^] | 30 | #include <cassert.h> |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 31 | #include <stdint.h> |
| 32 | |
Max Shvetsov | 0b7d25f | 2021-03-05 13:46:42 +0000 | [diff] [blame] | 33 | /** Partition property: partition supports receipt of direct requests. */ |
| 34 | #define FFA_PARTITION_DIRECT_REQ_RECV 0x1 |
| 35 | |
| 36 | /** Partition property: partition can send direct requests. */ |
| 37 | #define FFA_PARTITION_DIRECT_REQ_SEND 0x2 |
| 38 | |
| 39 | /** Partition property: partition can send and receive indirect messages. */ |
| 40 | #define FFA_PARTITION_INDIRECT_MSG 0x4 |
| 41 | |
Max Shvetsov | c32f478 | 2020-06-23 09:41:15 +0100 | [diff] [blame] | 42 | struct ffa_partition_info { |
| 43 | /** The ID of the VM the information is about */ |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 44 | ffa_id_t id; |
Max Shvetsov | c32f478 | 2020-06-23 09:41:15 +0100 | [diff] [blame] | 45 | /** The number of execution contexts implemented by the partition */ |
| 46 | uint16_t exec_context; |
| 47 | /** The Partition's properties, e.g. supported messaging methods */ |
| 48 | uint32_t properties; |
| 49 | }; |
| 50 | |
J-Alves | 6cb21d9 | 2021-01-07 15:18:12 +0000 | [diff] [blame] | 51 | static inline uint32_t ffa_func_id(smc_ret_values val) { |
| 52 | return (uint32_t) val.ret0; |
| 53 | } |
| 54 | |
| 55 | static inline int32_t ffa_error_code(smc_ret_values val) { |
| 56 | return (int32_t) val.ret2; |
| 57 | } |
| 58 | |
Daniel Boulby | 198deda | 2021-03-03 11:35:25 +0000 | [diff] [blame] | 59 | static inline ffa_id_t ffa_endpoint_id(smc_ret_values val) { |
| 60 | return (ffa_id_t) val.ret2 & 0xffff; |
| 61 | } |
| 62 | |
J-Alves | 18c2805 | 2021-03-09 09:58:53 +0000 | [diff] [blame^] | 63 | typedef uint64_t ffa_notification_bitmap_t; |
| 64 | |
| 65 | #define FFA_NOTIFICATION(ID) (UINT64_C(1) << ID) |
| 66 | |
| 67 | #define MAX_FFA_NOTIFICATIONS UINT32_C(64) |
| 68 | |
| 69 | #define FFA_NOTIFICATIONS_FLAG_PER_VCPU UINT32_C(0x1 << 0) |
| 70 | |
| 71 | #define FFA_NOTIFICATIONS_FLAGS_VCPU_ID(id) UINT32_C((id & 0xFFFF) << 16) |
| 72 | |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 73 | enum ffa_data_access { |
| 74 | FFA_DATA_ACCESS_NOT_SPECIFIED, |
| 75 | FFA_DATA_ACCESS_RO, |
| 76 | FFA_DATA_ACCESS_RW, |
| 77 | FFA_DATA_ACCESS_RESERVED, |
| 78 | }; |
| 79 | |
| 80 | enum ffa_instruction_access { |
| 81 | FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, |
| 82 | FFA_INSTRUCTION_ACCESS_NX, |
| 83 | FFA_INSTRUCTION_ACCESS_X, |
| 84 | FFA_INSTRUCTION_ACCESS_RESERVED, |
| 85 | }; |
| 86 | |
| 87 | enum ffa_memory_type { |
| 88 | FFA_MEMORY_NOT_SPECIFIED_MEM, |
| 89 | FFA_MEMORY_DEVICE_MEM, |
| 90 | FFA_MEMORY_NORMAL_MEM, |
| 91 | }; |
| 92 | |
| 93 | enum ffa_memory_cacheability { |
| 94 | FFA_MEMORY_CACHE_RESERVED = 0x0, |
| 95 | FFA_MEMORY_CACHE_NON_CACHEABLE = 0x1, |
| 96 | FFA_MEMORY_CACHE_RESERVED_1 = 0x2, |
| 97 | FFA_MEMORY_CACHE_WRITE_BACK = 0x3, |
| 98 | FFA_MEMORY_DEV_NGNRNE = 0x0, |
| 99 | FFA_MEMORY_DEV_NGNRE = 0x1, |
| 100 | FFA_MEMORY_DEV_NGRE = 0x2, |
| 101 | FFA_MEMORY_DEV_GRE = 0x3, |
| 102 | }; |
| 103 | |
| 104 | enum ffa_memory_shareability { |
| 105 | FFA_MEMORY_SHARE_NON_SHAREABLE, |
| 106 | FFA_MEMORY_SHARE_RESERVED, |
| 107 | FFA_MEMORY_OUTER_SHAREABLE, |
| 108 | FFA_MEMORY_INNER_SHAREABLE, |
| 109 | }; |
| 110 | |
| 111 | typedef uint8_t ffa_memory_access_permissions_t; |
| 112 | |
| 113 | /** |
| 114 | * This corresponds to table "Memory region attributes descriptor" of the FF-A |
| 115 | * 1.0 specification. |
| 116 | */ |
| 117 | typedef uint8_t ffa_memory_attributes_t; |
| 118 | |
| 119 | #define FFA_DATA_ACCESS_OFFSET (0x0U) |
| 120 | #define FFA_DATA_ACCESS_MASK ((0x3U) << FFA_DATA_ACCESS_OFFSET) |
| 121 | |
| 122 | #define FFA_INSTRUCTION_ACCESS_OFFSET (0x2U) |
| 123 | #define FFA_INSTRUCTION_ACCESS_MASK ((0x3U) << FFA_INSTRUCTION_ACCESS_OFFSET) |
| 124 | |
| 125 | #define FFA_MEMORY_TYPE_OFFSET (0x4U) |
| 126 | #define FFA_MEMORY_TYPE_MASK ((0x3U) << FFA_MEMORY_TYPE_OFFSET) |
| 127 | |
| 128 | #define FFA_MEMORY_CACHEABILITY_OFFSET (0x2U) |
| 129 | #define FFA_MEMORY_CACHEABILITY_MASK ((0x3U) << FFA_MEMORY_CACHEABILITY_OFFSET) |
| 130 | |
| 131 | #define FFA_MEMORY_SHAREABILITY_OFFSET (0x0U) |
| 132 | #define FFA_MEMORY_SHAREABILITY_MASK ((0x3U) << FFA_MEMORY_SHAREABILITY_OFFSET) |
| 133 | |
| 134 | #define ATTR_FUNCTION_SET(name, container_type, offset, mask) \ |
| 135 | static inline void ffa_set_##name##_attr(container_type *attr, \ |
| 136 | const enum ffa_##name perm) \ |
| 137 | { \ |
| 138 | *attr = (*attr & ~(mask)) | ((perm << offset) & mask); \ |
| 139 | } |
| 140 | |
| 141 | #define ATTR_FUNCTION_GET(name, container_type, offset, mask) \ |
| 142 | static inline enum ffa_##name ffa_get_##name##_attr( \ |
| 143 | container_type attr) \ |
| 144 | { \ |
| 145 | return (enum ffa_##name)((attr & mask) >> offset); \ |
| 146 | } |
| 147 | |
| 148 | ATTR_FUNCTION_SET(data_access, ffa_memory_access_permissions_t, |
| 149 | FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK) |
| 150 | ATTR_FUNCTION_GET(data_access, ffa_memory_access_permissions_t, |
| 151 | FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK) |
| 152 | |
| 153 | ATTR_FUNCTION_SET(instruction_access, ffa_memory_access_permissions_t, |
| 154 | FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK) |
| 155 | ATTR_FUNCTION_GET(instruction_access, ffa_memory_access_permissions_t, |
| 156 | FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK) |
| 157 | |
| 158 | ATTR_FUNCTION_SET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET, |
| 159 | FFA_MEMORY_TYPE_MASK) |
| 160 | ATTR_FUNCTION_GET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET, |
| 161 | FFA_MEMORY_TYPE_MASK) |
| 162 | |
| 163 | ATTR_FUNCTION_SET(memory_cacheability, ffa_memory_attributes_t, |
| 164 | FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK) |
| 165 | ATTR_FUNCTION_GET(memory_cacheability, ffa_memory_attributes_t, |
| 166 | FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK) |
| 167 | |
| 168 | ATTR_FUNCTION_SET(memory_shareability, ffa_memory_attributes_t, |
| 169 | FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK) |
| 170 | ATTR_FUNCTION_GET(memory_shareability, ffa_memory_attributes_t, |
| 171 | FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK) |
| 172 | |
| 173 | #define FFA_MEMORY_HANDLE_ALLOCATOR_MASK \ |
| 174 | ((ffa_memory_handle_t)(UINT64_C(1) << 63)) |
| 175 | #define FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR \ |
| 176 | ((ffa_memory_handle_t)(UINT64_C(1) << 63)) |
| 177 | #define FFA_MEMORY_HANDLE_INVALID (~UINT64_C(0)) |
| 178 | |
| 179 | /** |
| 180 | * A set of contiguous pages which is part of a memory region. This corresponds |
| 181 | * to table "Constituent memory region descriptor" of the FFA 1.0 specification. |
| 182 | */ |
| 183 | struct ffa_memory_region_constituent { |
| 184 | /** |
| 185 | * The base IPA of the constituent memory region, aligned to 4 kiB page |
| 186 | * size granularity. |
| 187 | */ |
| 188 | void *address; |
| 189 | /** The number of 4 kiB pages in the constituent memory region. */ |
| 190 | uint32_t page_count; |
| 191 | /** Reserved field, must be 0. */ |
| 192 | uint32_t reserved; |
| 193 | }; |
| 194 | |
| 195 | /** |
| 196 | * A set of pages comprising a memory region. This corresponds to table |
| 197 | * "Composite memory region descriptor" of the FFA 1.0 specification. |
| 198 | */ |
| 199 | struct ffa_composite_memory_region { |
| 200 | /** |
| 201 | * The total number of 4 kiB pages included in this memory region. This |
| 202 | * must be equal to the sum of page counts specified in each |
| 203 | * `ffa_memory_region_constituent`. |
| 204 | */ |
| 205 | uint32_t page_count; |
| 206 | /** |
| 207 | * The number of constituents (`ffa_memory_region_constituent`) |
| 208 | * included in this memory region range. |
| 209 | */ |
| 210 | uint32_t constituent_count; |
| 211 | /** Reserved field, must be 0. */ |
| 212 | uint64_t reserved_0; |
| 213 | /** An array of `constituent_count` memory region constituents. */ |
| 214 | struct ffa_memory_region_constituent constituents[]; |
| 215 | }; |
| 216 | |
| 217 | /** |
| 218 | * This corresponds to table "Memory access permissions descriptor" of the FFA |
| 219 | * 1.0 specification. |
| 220 | */ |
| 221 | struct ffa_memory_region_attributes { |
| 222 | /** The ID of the VM to which the memory is being given or shared. */ |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 223 | ffa_id_t receiver; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 224 | /** |
| 225 | * The permissions with which the memory region should be mapped in the |
| 226 | * receiver's page table. |
| 227 | */ |
| 228 | ffa_memory_access_permissions_t permissions; |
| 229 | /** |
| 230 | * Flags used during FFA_MEM_RETRIEVE_REQ and FFA_MEM_RETRIEVE_RESP |
| 231 | * for memory regions with multiple borrowers. |
| 232 | */ |
| 233 | ffa_memory_receiver_flags_t flags; |
| 234 | }; |
| 235 | |
| 236 | /** Flags to control the behaviour of a memory sharing transaction. */ |
| 237 | typedef uint32_t ffa_memory_region_flags_t; |
| 238 | |
| 239 | /** |
| 240 | * Clear memory region contents after unmapping it from the sender and before |
| 241 | * mapping it for any receiver. |
| 242 | */ |
| 243 | #define FFA_MEMORY_REGION_FLAG_CLEAR 0x1U |
| 244 | |
| 245 | /** |
| 246 | * Whether the hypervisor may time slice the memory sharing or retrieval |
| 247 | * operation. |
| 248 | */ |
| 249 | #define FFA_MEMORY_REGION_FLAG_TIME_SLICE 0x2U |
| 250 | |
| 251 | /** |
| 252 | * Whether the hypervisor should clear the memory region after the receiver |
| 253 | * relinquishes it or is aborted. |
| 254 | */ |
| 255 | #define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH 0x4U |
| 256 | |
| 257 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_MASK ((0x3U) << 3) |
| 258 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_UNSPECIFIED ((0x0U) << 3) |
| 259 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE ((0x1U) << 3) |
| 260 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_LEND ((0x2U) << 3) |
| 261 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_DONATE ((0x3U) << 3) |
| 262 | |
J-Alves | 0435cae | 2020-11-06 10:49:56 +0000 | [diff] [blame] | 263 | /** The maximum number of recipients a memory region may be sent to. */ |
| 264 | #define MAX_MEM_SHARE_RECIPIENTS 1U |
| 265 | |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 266 | /** |
| 267 | * This corresponds to table "Endpoint memory access descriptor" of the FFA 1.0 |
| 268 | * specification. |
| 269 | */ |
| 270 | struct ffa_memory_access { |
| 271 | struct ffa_memory_region_attributes receiver_permissions; |
| 272 | /** |
| 273 | * Offset in bytes from the start of the outer `ffa_memory_region` to |
| 274 | * an `ffa_composite_memory_region` struct. |
| 275 | */ |
| 276 | uint32_t composite_memory_region_offset; |
| 277 | uint64_t reserved_0; |
| 278 | }; |
| 279 | |
| 280 | /** |
| 281 | * Information about a set of pages which are being shared. This corresponds to |
| 282 | * table "Lend, donate or share memory transaction descriptor" of the FFA |
| 283 | * 1.0 specification. Note that it is also used for retrieve requests and |
| 284 | * responses. |
| 285 | */ |
| 286 | struct ffa_memory_region { |
| 287 | /** |
| 288 | * The ID of the VM which originally sent the memory region, i.e. the |
| 289 | * owner. |
| 290 | */ |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 291 | ffa_id_t sender; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 292 | ffa_memory_attributes_t attributes; |
| 293 | /** Reserved field, must be 0. */ |
| 294 | uint8_t reserved_0; |
| 295 | /** Flags to control behaviour of the transaction. */ |
| 296 | ffa_memory_region_flags_t flags; |
| 297 | ffa_memory_handle_t handle; |
| 298 | /** |
| 299 | * An implementation defined value associated with the receiver and the |
| 300 | * memory region. |
| 301 | */ |
| 302 | uint64_t tag; |
| 303 | /** Reserved field, must be 0. */ |
| 304 | uint32_t reserved_1; |
| 305 | /** |
| 306 | * The number of `ffa_memory_access` entries included in this |
| 307 | * transaction. |
| 308 | */ |
| 309 | uint32_t receiver_count; |
| 310 | /** |
| 311 | * An array of `attribute_count` endpoint memory access descriptors. |
| 312 | * Each one specifies a memory region offset, an endpoint and the |
| 313 | * attributes with which this memory region should be mapped in that |
| 314 | * endpoint's page table. |
| 315 | */ |
| 316 | struct ffa_memory_access receivers[]; |
| 317 | }; |
| 318 | |
| 319 | /** |
| 320 | * Descriptor used for FFA_MEM_RELINQUISH requests. This corresponds to table |
| 321 | * "Descriptor to relinquish a memory region" of the FFA 1.0 specification. |
| 322 | */ |
| 323 | struct ffa_mem_relinquish { |
| 324 | ffa_memory_handle_t handle; |
| 325 | ffa_memory_region_flags_t flags; |
| 326 | uint32_t endpoint_count; |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 327 | ffa_id_t endpoints[]; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 328 | }; |
| 329 | |
| 330 | static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t h1, uint32_t h2) |
| 331 | { |
J-Alves | 18c2805 | 2021-03-09 09:58:53 +0000 | [diff] [blame^] | 332 | return (ffa_notification_bitmap_t)h1 | |
| 333 | (ffa_notification_bitmap_t)h2 << 32; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | static inline ffa_memory_handle_t ffa_mem_success_handle(smc_ret_values r) |
| 337 | { |
| 338 | return ffa_assemble_handle(r.ret2, r.ret3); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Gets the `ffa_composite_memory_region` for the given receiver from an |
| 343 | * `ffa_memory_region`, or NULL if it is not valid. |
| 344 | */ |
| 345 | static inline struct ffa_composite_memory_region * |
| 346 | ffa_memory_region_get_composite(struct ffa_memory_region *memory_region, |
| 347 | uint32_t receiver_index) |
| 348 | { |
| 349 | uint32_t offset = memory_region->receivers[receiver_index] |
| 350 | .composite_memory_region_offset; |
| 351 | |
| 352 | if (offset == 0) { |
| 353 | return NULL; |
| 354 | } |
| 355 | |
| 356 | return (struct ffa_composite_memory_region *)((uint8_t *)memory_region + |
| 357 | offset); |
| 358 | } |
| 359 | |
| 360 | static inline uint32_t ffa_mem_relinquish_init( |
| 361 | struct ffa_mem_relinquish *relinquish_request, |
| 362 | ffa_memory_handle_t handle, ffa_memory_region_flags_t flags, |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 363 | ffa_id_t sender) |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 364 | { |
| 365 | relinquish_request->handle = handle; |
| 366 | relinquish_request->flags = flags; |
| 367 | relinquish_request->endpoint_count = 1; |
| 368 | relinquish_request->endpoints[0] = sender; |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 369 | return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_id_t); |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | uint32_t ffa_memory_retrieve_request_init( |
| 373 | struct ffa_memory_region *memory_region, ffa_memory_handle_t handle, |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 374 | ffa_id_t sender, ffa_id_t receiver, uint32_t tag, |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 375 | ffa_memory_region_flags_t flags, enum ffa_data_access data_access, |
| 376 | enum ffa_instruction_access instruction_access, |
| 377 | enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, |
| 378 | enum ffa_memory_shareability shareability); |
| 379 | |
| 380 | uint32_t ffa_memory_region_init( |
| 381 | struct ffa_memory_region *memory_region, size_t memory_region_max_size, |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 382 | ffa_id_t sender, ffa_id_t receiver, |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 383 | const struct ffa_memory_region_constituent constituents[], |
| 384 | uint32_t constituent_count, uint32_t tag, |
| 385 | ffa_memory_region_flags_t flags, enum ffa_data_access data_access, |
| 386 | enum ffa_instruction_access instruction_access, |
| 387 | enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, |
| 388 | enum ffa_memory_shareability shareability, uint32_t *total_length, |
| 389 | uint32_t *fragment_length); |
| 390 | |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 391 | static inline ffa_id_t ffa_dir_msg_dest(smc_ret_values val) { |
| 392 | return (ffa_id_t)val.ret1 & U(0xFFFF); |
J-Alves | 6cb21d9 | 2021-01-07 15:18:12 +0000 | [diff] [blame] | 393 | } |
| 394 | |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 395 | static inline ffa_id_t ffa_dir_msg_source(smc_ret_values val) { |
| 396 | return (ffa_id_t)(val.ret1 >> 16U); |
J-Alves | 6cb21d9 | 2021-01-07 15:18:12 +0000 | [diff] [blame] | 397 | } |
| 398 | |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 399 | smc_ret_values ffa_msg_send_direct_req64(ffa_id_t source_id, |
| 400 | ffa_id_t dest_id, uint64_t arg0, |
J-Alves | ecd3074 | 2021-02-19 18:31:06 +0000 | [diff] [blame] | 401 | uint64_t arg1, uint64_t arg2, |
| 402 | uint64_t arg3, uint64_t arg4); |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 403 | |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 404 | smc_ret_values ffa_msg_send_direct_req32(ffa_id_t source_id, |
| 405 | ffa_id_t dest_id, uint32_t arg0, |
J-Alves | ecd3074 | 2021-02-19 18:31:06 +0000 | [diff] [blame] | 406 | uint32_t arg1, uint32_t arg2, |
| 407 | uint32_t arg3, uint32_t arg4); |
| 408 | |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 409 | smc_ret_values ffa_msg_send_direct_resp64(ffa_id_t source_id, |
| 410 | ffa_id_t dest_id, uint64_t arg0, |
J-Alves | ecd3074 | 2021-02-19 18:31:06 +0000 | [diff] [blame] | 411 | uint64_t arg1, uint64_t arg2, |
| 412 | uint64_t arg3, uint64_t arg4); |
| 413 | |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 414 | smc_ret_values ffa_msg_send_direct_resp32(ffa_id_t source_id, |
| 415 | ffa_id_t dest_id, uint32_t arg0, |
J-Alves | ecd3074 | 2021-02-19 18:31:06 +0000 | [diff] [blame] | 416 | uint32_t arg1, uint32_t arg2, |
| 417 | uint32_t arg3, uint32_t arg4); |
J-Alves | 035b7d0 | 2021-02-11 10:40:35 +0000 | [diff] [blame] | 418 | |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 419 | smc_ret_values ffa_run(uint32_t dest_id, uint32_t vcpu_id); |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 420 | smc_ret_values ffa_version(uint32_t input_version); |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 421 | smc_ret_values ffa_id_get(void); |
Daniel Boulby | 198deda | 2021-03-03 11:35:25 +0000 | [diff] [blame] | 422 | smc_ret_values ffa_spm_id_get(void); |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 423 | smc_ret_values ffa_msg_wait(void); |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 424 | smc_ret_values ffa_error(int32_t error_code); |
Max Shvetsov | c17c1d3 | 2020-06-11 15:03:01 +0100 | [diff] [blame] | 425 | smc_ret_values ffa_features(uint32_t feature); |
Max Shvetsov | 0b7d25f | 2021-03-05 13:46:42 +0000 | [diff] [blame] | 426 | smc_ret_values ffa_partition_info_get(const struct ffa_uuid uuid); |
Max Shvetsov | c32f478 | 2020-06-23 09:41:15 +0100 | [diff] [blame] | 427 | smc_ret_values ffa_rx_release(void); |
Ruari Phipps | bd0a7e4 | 2020-07-17 16:42:21 +0100 | [diff] [blame] | 428 | smc_ret_values ffa_rxtx_map(uintptr_t send, uintptr_t recv, uint32_t pages); |
Daniel Boulby | e060290 | 2021-07-07 11:14:39 +0100 | [diff] [blame] | 429 | smc_ret_values ffa_rxtx_unmap(void); |
J-Alves | 3ea46d1 | 2020-09-09 11:13:05 +0100 | [diff] [blame] | 430 | smc_ret_values ffa_mem_donate(uint32_t descriptor_length, |
| 431 | uint32_t fragment_length); |
| 432 | smc_ret_values ffa_mem_lend(uint32_t descriptor_length, |
| 433 | uint32_t fragment_length); |
| 434 | smc_ret_values ffa_mem_share(uint32_t descriptor_length, |
| 435 | uint32_t fragment_length); |
| 436 | smc_ret_values ffa_mem_retrieve_req(uint32_t descriptor_length, |
| 437 | uint32_t fragment_length); |
| 438 | smc_ret_values ffa_mem_relinquish(void); |
| 439 | smc_ret_values ffa_mem_reclaim(uint64_t handle, uint32_t flags); |
J-Alves | bcb1f97 | 2021-03-11 14:03:54 +0000 | [diff] [blame] | 440 | smc_ret_values ffa_notification_bitmap_create(ffa_id_t vm_id, |
| 441 | ffa_vcpu_count_t vcpu_count); |
| 442 | smc_ret_values ffa_notification_bitmap_destroy(ffa_id_t vm_id); |
J-Alves | 18c2805 | 2021-03-09 09:58:53 +0000 | [diff] [blame^] | 443 | smc_ret_values ffa_notification_bind(ffa_id_t sender, ffa_id_t receiver, |
| 444 | uint32_t flags, |
| 445 | ffa_notification_bitmap_t notifications); |
| 446 | smc_ret_values ffa_notification_unbind(ffa_id_t sender, ffa_id_t receiver, |
| 447 | ffa_notification_bitmap_t notifications); |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 448 | #endif /* __ASSEMBLY__ */ |
| 449 | |
| 450 | #endif /* FFA_HELPERS_H */ |