Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1 | /* |
J-Alves | 13318e3 | 2021-02-22 17:21:00 +0000 | [diff] [blame] | 2 | * Copyright 2021 The Hafnium Authors. |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 3 | * |
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 4 | * 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 Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "hf/types.h" |
| 12 | |
Olivier Deprez | 62d99e3 | 2020-01-09 15:58:07 +0100 | [diff] [blame] | 13 | #define FFA_VERSION_MAJOR 0x1 |
Olivier Deprez | 62d99e3 | 2020-01-09 15:58:07 +0100 | [diff] [blame] | 14 | #define FFA_VERSION_MAJOR_OFFSET 16 |
Daniel Boulby | 6e32c61 | 2021-02-17 15:09:41 +0000 | [diff] [blame] | 15 | #define FFA_VERSION_MAJOR_MASK 0x7FFF |
J-Alves | 3829fc0 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 16 | #define FFA_VERSION_MINOR 0x1 |
Daniel Boulby | 6e32c61 | 2021-02-17 15:09:41 +0000 | [diff] [blame] | 17 | #define FFA_VERSION_MINOR_OFFSET 0 |
| 18 | #define FFA_VERSION_MINOR_MASK 0xFFFF |
| 19 | |
| 20 | #define MAKE_FFA_VERSION(major, minor) \ |
| 21 | ((((major)&FFA_VERSION_MAJOR_MASK) << FFA_VERSION_MAJOR_OFFSET) | \ |
| 22 | (((minor)&FFA_VERSION_MINOR_MASK) << FFA_VERSION_MINOR_OFFSET)) |
| 23 | #define FFA_VERSION_COMPILED \ |
| 24 | MAKE_FFA_VERSION(FFA_VERSION_MAJOR, FFA_VERSION_MINOR) |
Olivier Deprez | 62d99e3 | 2020-01-09 15:58:07 +0100 | [diff] [blame] | 25 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 26 | /* clang-format off */ |
| 27 | |
| 28 | #define FFA_LOW_32_ID 0x84000060 |
| 29 | #define FFA_HIGH_32_ID 0x8400007F |
| 30 | #define FFA_LOW_64_ID 0xC4000060 |
Fuad Tabba | da72d14 | 2020-07-30 09:17:05 +0100 | [diff] [blame] | 31 | #define FFA_HIGH_64_ID 0xC400007F |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 32 | |
| 33 | /* FF-A function identifiers. */ |
J-Alves | 3829fc0 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 34 | #define FFA_ERROR_32 0x84000060 |
| 35 | #define FFA_SUCCESS_32 0x84000061 |
| 36 | #define FFA_SUCCESS_64 0xC4000061 |
| 37 | #define FFA_INTERRUPT_32 0x84000062 |
| 38 | #define FFA_VERSION_32 0x84000063 |
| 39 | #define FFA_FEATURES_32 0x84000064 |
| 40 | #define FFA_RX_RELEASE_32 0x84000065 |
| 41 | #define FFA_RXTX_MAP_32 0x84000066 |
| 42 | #define FFA_RXTX_MAP_64 0xC4000066 |
| 43 | #define FFA_RXTX_UNMAP_32 0x84000067 |
| 44 | #define FFA_PARTITION_INFO_GET_32 0x84000068 |
| 45 | #define FFA_ID_GET_32 0x84000069 |
| 46 | #define FFA_MSG_POLL_32 0x8400006A /* Legacy FF-A v1.0 */ |
| 47 | #define FFA_MSG_WAIT_32 0x8400006B |
| 48 | #define FFA_YIELD_32 0x8400006C |
| 49 | #define FFA_RUN_32 0x8400006D |
| 50 | #define FFA_MSG_SEND_32 0x8400006E /* Legacy FF-A v1.0 */ |
| 51 | #define FFA_MSG_SEND_DIRECT_REQ_32 0x8400006F |
| 52 | #define FFA_MSG_SEND_DIRECT_REQ_64 0xC400006F |
| 53 | #define FFA_MSG_SEND_DIRECT_RESP_32 0x84000070 |
| 54 | #define FFA_MSG_SEND_DIRECT_RESP_64 0xC4000070 |
| 55 | #define FFA_MEM_DONATE_32 0x84000071 |
| 56 | #define FFA_MEM_LEND_32 0x84000072 |
| 57 | #define FFA_MEM_SHARE_32 0x84000073 |
| 58 | #define FFA_MEM_RETRIEVE_REQ_32 0x84000074 |
| 59 | #define FFA_MEM_RETRIEVE_RESP_32 0x84000075 |
| 60 | #define FFA_MEM_RELINQUISH_32 0x84000076 |
| 61 | #define FFA_MEM_RECLAIM_32 0x84000077 |
| 62 | #define FFA_MEM_FRAG_RX_32 0x8400007A |
| 63 | #define FFA_MEM_FRAG_TX_32 0x8400007B |
| 64 | #define FFA_NORMAL_WORLD_RESUME 0x8400007C |
| 65 | |
| 66 | /* FF-A v1.1 */ |
| 67 | #define FFA_NOTIFICATION_BITMAP_CREATE_32 0x8400007D |
| 68 | #define FFA_NOTIFICATION_BITMAP_DESTROY_32 0x8400007E |
| 69 | #define FFA_NOTIFICATION_BIND_32 0x8400007F |
| 70 | #define FFA_NOTIFICATION_UNBIND_32 0x84000080 |
| 71 | #define FFA_NOTIFICATION_SET_32 0x84000081 |
| 72 | #define FFA_NOTIFICATION_GET_32 0x84000082 |
| 73 | #define FFA_NOTIFICATION_INFO_GET_64 0xC4000083 |
| 74 | #define FFA_RX_ACQUIRE_32 0x84000084 |
| 75 | #define FFA_SPM_ID_GET_32 0x84000085 |
| 76 | #define FFA_MSG_SEND2_32 0x84000086 |
| 77 | #define FFA_SECONDARY_EP_REGISTER_64 0xC4000087 |
| 78 | #define FFA_MEM_PERM_GET_32 0x84000088 |
| 79 | #define FFA_MEM_PERM_SET_32 0x84000089 |
Raghu Krishnamurthy | ea6d25f | 2021-09-14 15:27:06 -0700 | [diff] [blame] | 80 | #define FFA_MEM_PERM_GET_64 0xC4000088 |
| 81 | #define FFA_MEM_PERM_SET_64 0xC4000089 |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 82 | |
Maksims Svecovs | 71b7670 | 2022-05-20 15:32:58 +0100 | [diff] [blame] | 83 | /* Implementation-defined ABIs. */ |
| 84 | #define FFA_CONSOLE_LOG_32 0x8400008A |
| 85 | #define FFA_CONSOLE_LOG_64 0xC400008A |
Raghu Krishnamurthy | 7592bcb | 2022-12-25 13:09:00 -0800 | [diff] [blame] | 86 | #define FFA_PARTITION_INFO_GET_REGS_64 0xC400008B |
Madhukar Pappireddy | 77d3bcd | 2023-03-01 17:26:22 -0600 | [diff] [blame] | 87 | #define FFA_EL3_INTR_HANDLE_32 0x8400008C |
Maksims Svecovs | 71b7670 | 2022-05-20 15:32:58 +0100 | [diff] [blame] | 88 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 89 | /* FF-A error codes. */ |
| 90 | #define FFA_NOT_SUPPORTED INT32_C(-1) |
| 91 | #define FFA_INVALID_PARAMETERS INT32_C(-2) |
| 92 | #define FFA_NO_MEMORY INT32_C(-3) |
| 93 | #define FFA_BUSY INT32_C(-4) |
| 94 | #define FFA_INTERRUPTED INT32_C(-5) |
| 95 | #define FFA_DENIED INT32_C(-6) |
| 96 | #define FFA_RETRY INT32_C(-7) |
| 97 | #define FFA_ABORTED INT32_C(-8) |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 98 | #define FFA_NO_DATA INT32_C(-9) |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 99 | |
| 100 | /* clang-format on */ |
| 101 | |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 102 | /** |
| 103 | * FF-A Feature ID, to be used with interface FFA_FEATURES. |
| 104 | * As defined in the FF-A v1.1 Beta specification, table 13.10, in section |
| 105 | * 13.2. |
| 106 | */ |
| 107 | |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 108 | #define FFA_FEATURES_FUNC_ID_MASK (UINT32_C(1) << 31) |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 109 | #define FFA_FEATURES_FEATURE_ID_MASK UINT32_C(0x7F) |
| 110 | |
Karl Meakin | 34b8ae9 | 2023-01-13 13:33:07 +0000 | [diff] [blame] | 111 | /** |
| 112 | * Defined in Table 13.14 in the FF-A v.1.1 REL0 specification. |
| 113 | * Bits[31:2] and Bit[0] of input are reserved (must be zero). |
| 114 | * Bit[0]: dynamically allocated buffer support. |
| 115 | * Bit[1]: NS bit handling. |
| 116 | * Bit[2]: support for retrieval by hypervisor. |
| 117 | */ |
| 118 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_BUFFER_SUPPORT 0 |
| 119 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT (UINT32_C(1) << 1) |
| 120 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_HYPERVISOR_SUPPORT (UINT32_C(1) << 2) |
| 121 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_MBZ_MASK \ |
| 122 | (~(FFA_FEATURES_MEM_RETRIEVE_REQ_BUFFER_SUPPORT | \ |
| 123 | FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT | \ |
| 124 | FFA_FEATURES_MEM_RETRIEVE_REQ_HYPERVISOR_SUPPORT)) |
| 125 | |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 126 | /* Query interrupt ID of Notification Pending Interrupt. */ |
| 127 | #define FFA_FEATURE_NPI 0x1U |
| 128 | |
| 129 | /* Query interrupt ID of Schedule Receiver Interrupt. */ |
| 130 | #define FFA_FEATURE_SRI 0x2U |
| 131 | |
| 132 | /* Query interrupt ID of the Managed Exit Interrupt. */ |
| 133 | #define FFA_FEATURE_MEI 0x3U |
| 134 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 135 | /* FF-A function specific constants. */ |
| 136 | #define FFA_MSG_RECV_BLOCK 0x1 |
| 137 | #define FFA_MSG_RECV_BLOCK_MASK 0x1 |
| 138 | |
| 139 | #define FFA_MSG_SEND_NOTIFY 0x1 |
| 140 | #define FFA_MSG_SEND_NOTIFY_MASK 0x1 |
| 141 | |
| 142 | #define FFA_MEM_RECLAIM_CLEAR 0x1 |
| 143 | |
| 144 | #define FFA_SLEEP_INDEFINITE 0 |
| 145 | |
Raghu Krishnamurthy | ea6d25f | 2021-09-14 15:27:06 -0700 | [diff] [blame] | 146 | #define FFA_MEM_PERM_RO UINT32_C(0x7) |
| 147 | #define FFA_MEM_PERM_RW UINT32_C(0x5) |
| 148 | #define FFA_MEM_PERM_RX UINT32_C(0x3) |
| 149 | |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 150 | /* |
Olivier Deprez | 013f4d6 | 2022-11-21 15:46:20 +0100 | [diff] [blame] | 151 | * Defined in Table 13.34 in the FF-A v1.1 EAC0 specification. |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 152 | * The Partition count flag is used by FFA_PARTITION_INFO_GET to specify |
| 153 | * if partition info descriptors should be returned or just the count. |
| 154 | */ |
Olivier Deprez | 013f4d6 | 2022-11-21 15:46:20 +0100 | [diff] [blame] | 155 | #define FFA_PARTITION_COUNT_FLAG UINT32_C(0x1) |
| 156 | #define FFA_PARTITION_COUNT_FLAG_MASK (UINT32_C(0x1) << 0) |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 157 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 158 | /** |
| 159 | * For use where the FF-A specification refers explicitly to '4K pages'. Not to |
| 160 | * be confused with PAGE_SIZE, which is the translation granule Hafnium is |
| 161 | * configured to use. |
| 162 | */ |
J-Alves | 715d623 | 2023-02-16 16:33:28 +0000 | [diff] [blame] | 163 | #define FFA_PAGE_SIZE ((size_t)4096) |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 164 | |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 165 | /** The ID of a VM. These are assigned sequentially starting with an offset. */ |
| 166 | typedef uint16_t ffa_vm_id_t; |
| 167 | |
| 168 | /** |
| 169 | * Partition message header as specified by table 6.2 from FF-A v1.1 EAC0 |
| 170 | * specification. |
| 171 | */ |
| 172 | struct ffa_partition_rxtx_header { |
| 173 | uint32_t flags; /* MBZ */ |
| 174 | uint32_t reserved; |
| 175 | /* Offset from the beginning of the buffer to the message payload. */ |
| 176 | uint32_t offset; |
| 177 | /* Sender(Bits[31:16]) and Receiver(Bits[15:0]) endpoint IDs. */ |
| 178 | uint32_t sender_receiver; |
| 179 | /* Size of message in buffer. */ |
| 180 | uint32_t size; |
| 181 | }; |
| 182 | |
| 183 | #define FFA_RXTX_HEADER_SIZE sizeof(struct ffa_partition_rxtx_header) |
| 184 | #define FFA_RXTX_SENDER_SHIFT (0x10U) |
J-Alves | 7007993 | 2022-12-07 17:32:20 +0000 | [diff] [blame] | 185 | #define FFA_RXTX_ALLOCATOR_SHIFT 16 |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 186 | |
| 187 | static inline void ffa_rxtx_header_init( |
| 188 | ffa_vm_id_t sender, ffa_vm_id_t receiver, uint32_t size, |
| 189 | struct ffa_partition_rxtx_header *header) |
| 190 | { |
| 191 | header->flags = 0; |
| 192 | header->reserved = 0; |
| 193 | header->offset = FFA_RXTX_HEADER_SIZE; |
| 194 | header->sender_receiver = |
| 195 | (uint32_t)(receiver | (sender << FFA_RXTX_SENDER_SHIFT)); |
| 196 | header->size = size; |
| 197 | } |
| 198 | |
| 199 | static inline ffa_vm_id_t ffa_rxtx_header_sender( |
| 200 | const struct ffa_partition_rxtx_header *h) |
| 201 | { |
| 202 | return (ffa_vm_id_t)(h->sender_receiver >> FFA_RXTX_SENDER_SHIFT); |
| 203 | } |
| 204 | |
| 205 | static inline ffa_vm_id_t ffa_rxtx_header_receiver( |
| 206 | const struct ffa_partition_rxtx_header *h) |
| 207 | { |
| 208 | return (ffa_vm_id_t)(h->sender_receiver); |
| 209 | } |
| 210 | |
| 211 | /* The maximum length possible for a single message. */ |
| 212 | #define FFA_PARTITION_MSG_PAYLOAD_MAX (HF_MAILBOX_SIZE - FFA_RXTX_HEADER_SIZE) |
| 213 | |
| 214 | struct ffa_partition_msg { |
| 215 | struct ffa_partition_rxtx_header header; |
| 216 | char payload[FFA_PARTITION_MSG_PAYLOAD_MAX]; |
| 217 | }; |
| 218 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 219 | /* The maximum length possible for a single message. */ |
| 220 | #define FFA_MSG_PAYLOAD_MAX HF_MAILBOX_SIZE |
| 221 | |
| 222 | enum ffa_data_access { |
| 223 | FFA_DATA_ACCESS_NOT_SPECIFIED, |
| 224 | FFA_DATA_ACCESS_RO, |
| 225 | FFA_DATA_ACCESS_RW, |
| 226 | FFA_DATA_ACCESS_RESERVED, |
| 227 | }; |
| 228 | |
| 229 | enum ffa_instruction_access { |
| 230 | FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, |
| 231 | FFA_INSTRUCTION_ACCESS_NX, |
| 232 | FFA_INSTRUCTION_ACCESS_X, |
| 233 | FFA_INSTRUCTION_ACCESS_RESERVED, |
| 234 | }; |
| 235 | |
| 236 | enum ffa_memory_type { |
| 237 | FFA_MEMORY_NOT_SPECIFIED_MEM, |
| 238 | FFA_MEMORY_DEVICE_MEM, |
| 239 | FFA_MEMORY_NORMAL_MEM, |
| 240 | }; |
| 241 | |
| 242 | enum ffa_memory_cacheability { |
| 243 | FFA_MEMORY_CACHE_RESERVED = 0x0, |
| 244 | FFA_MEMORY_CACHE_NON_CACHEABLE = 0x1, |
| 245 | FFA_MEMORY_CACHE_RESERVED_1 = 0x2, |
| 246 | FFA_MEMORY_CACHE_WRITE_BACK = 0x3, |
| 247 | FFA_MEMORY_DEV_NGNRNE = 0x0, |
| 248 | FFA_MEMORY_DEV_NGNRE = 0x1, |
| 249 | FFA_MEMORY_DEV_NGRE = 0x2, |
| 250 | FFA_MEMORY_DEV_GRE = 0x3, |
| 251 | }; |
| 252 | |
| 253 | enum ffa_memory_shareability { |
| 254 | FFA_MEMORY_SHARE_NON_SHAREABLE, |
| 255 | FFA_MEMORY_SHARE_RESERVED, |
| 256 | FFA_MEMORY_OUTER_SHAREABLE, |
| 257 | FFA_MEMORY_INNER_SHAREABLE, |
| 258 | }; |
| 259 | |
Olivier Deprez | 4342a3c | 2022-02-28 09:37:25 +0100 | [diff] [blame] | 260 | /** |
| 261 | * FF-A v1.1 REL0 Table 10.18 memory region attributes descriptor NS Bit 6. |
| 262 | * Per section 10.10.4.1, NS bit is reserved for FFA_MEM_DONATE/LEND/SHARE |
| 263 | * and FFA_MEM_RETRIEVE_REQUEST. |
| 264 | */ |
| 265 | enum ffa_memory_security { |
| 266 | FFA_MEMORY_SECURITY_UNSPECIFIED = 0, |
| 267 | FFA_MEMORY_SECURITY_SECURE = 0, |
| 268 | FFA_MEMORY_SECURITY_NON_SECURE, |
| 269 | }; |
| 270 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 271 | typedef uint8_t ffa_memory_access_permissions_t; |
| 272 | |
| 273 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 274 | * This corresponds to table 10.18 of the FF-A v1.1 EAC0 specification, "Memory |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 275 | * region attributes descriptor". |
| 276 | */ |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 277 | typedef uint16_t ffa_memory_attributes_t; |
| 278 | |
| 279 | /* FF-A v1.1 EAC0 states bit [15:7] Must Be Zero. */ |
| 280 | #define FFA_MEMORY_ATTRIBUTES_MBZ_MASK 0xFF80U |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 281 | |
| 282 | #define FFA_DATA_ACCESS_OFFSET (0x0U) |
| 283 | #define FFA_DATA_ACCESS_MASK ((0x3U) << FFA_DATA_ACCESS_OFFSET) |
| 284 | |
| 285 | #define FFA_INSTRUCTION_ACCESS_OFFSET (0x2U) |
| 286 | #define FFA_INSTRUCTION_ACCESS_MASK ((0x3U) << FFA_INSTRUCTION_ACCESS_OFFSET) |
| 287 | |
| 288 | #define FFA_MEMORY_TYPE_OFFSET (0x4U) |
| 289 | #define FFA_MEMORY_TYPE_MASK ((0x3U) << FFA_MEMORY_TYPE_OFFSET) |
| 290 | |
Olivier Deprez | 4342a3c | 2022-02-28 09:37:25 +0100 | [diff] [blame] | 291 | #define FFA_MEMORY_SECURITY_OFFSET (0x6U) |
| 292 | #define FFA_MEMORY_SECURITY_MASK ((0x1U) << FFA_MEMORY_SECURITY_OFFSET) |
| 293 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 294 | #define FFA_MEMORY_CACHEABILITY_OFFSET (0x2U) |
| 295 | #define FFA_MEMORY_CACHEABILITY_MASK ((0x3U) << FFA_MEMORY_CACHEABILITY_OFFSET) |
| 296 | |
| 297 | #define FFA_MEMORY_SHAREABILITY_OFFSET (0x0U) |
| 298 | #define FFA_MEMORY_SHAREABILITY_MASK ((0x3U) << FFA_MEMORY_SHAREABILITY_OFFSET) |
| 299 | |
| 300 | #define ATTR_FUNCTION_SET(name, container_type, offset, mask) \ |
| 301 | static inline void ffa_set_##name##_attr(container_type *attr, \ |
| 302 | const enum ffa_##name perm) \ |
| 303 | { \ |
| 304 | *attr = (*attr & ~(mask)) | ((perm << offset) & mask); \ |
| 305 | } |
| 306 | |
| 307 | #define ATTR_FUNCTION_GET(name, container_type, offset, mask) \ |
| 308 | static inline enum ffa_##name ffa_get_##name##_attr( \ |
| 309 | container_type attr) \ |
| 310 | { \ |
| 311 | return (enum ffa_##name)((attr & mask) >> offset); \ |
| 312 | } |
| 313 | |
| 314 | ATTR_FUNCTION_SET(data_access, ffa_memory_access_permissions_t, |
| 315 | FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK) |
| 316 | ATTR_FUNCTION_GET(data_access, ffa_memory_access_permissions_t, |
| 317 | FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK) |
| 318 | |
| 319 | ATTR_FUNCTION_SET(instruction_access, ffa_memory_access_permissions_t, |
| 320 | FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK) |
| 321 | ATTR_FUNCTION_GET(instruction_access, ffa_memory_access_permissions_t, |
| 322 | FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK) |
| 323 | |
| 324 | ATTR_FUNCTION_SET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET, |
| 325 | FFA_MEMORY_TYPE_MASK) |
| 326 | ATTR_FUNCTION_GET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET, |
| 327 | FFA_MEMORY_TYPE_MASK) |
| 328 | |
| 329 | ATTR_FUNCTION_SET(memory_cacheability, ffa_memory_attributes_t, |
| 330 | FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK) |
| 331 | ATTR_FUNCTION_GET(memory_cacheability, ffa_memory_attributes_t, |
| 332 | FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK) |
| 333 | |
| 334 | ATTR_FUNCTION_SET(memory_shareability, ffa_memory_attributes_t, |
| 335 | FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK) |
| 336 | ATTR_FUNCTION_GET(memory_shareability, ffa_memory_attributes_t, |
| 337 | FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK) |
| 338 | |
Olivier Deprez | 4342a3c | 2022-02-28 09:37:25 +0100 | [diff] [blame] | 339 | ATTR_FUNCTION_SET(memory_security, ffa_memory_attributes_t, |
| 340 | FFA_MEMORY_SECURITY_OFFSET, FFA_MEMORY_SECURITY_MASK) |
| 341 | ATTR_FUNCTION_GET(memory_security, ffa_memory_attributes_t, |
| 342 | FFA_MEMORY_SECURITY_OFFSET, FFA_MEMORY_SECURITY_MASK) |
| 343 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 344 | /** |
| 345 | * A globally-unique ID assigned by the hypervisor for a region of memory being |
| 346 | * sent between VMs. |
| 347 | */ |
| 348 | typedef uint64_t ffa_memory_handle_t; |
| 349 | |
J-Alves | 917d2f2 | 2020-10-30 18:39:30 +0000 | [diff] [blame] | 350 | #define FFA_MEMORY_HANDLE_ALLOCATOR_MASK \ |
| 351 | ((ffa_memory_handle_t)(UINT64_C(1) << 63)) |
| 352 | #define FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR \ |
| 353 | ((ffa_memory_handle_t)(UINT64_C(1) << 63)) |
| 354 | |
| 355 | #define FFA_MEMORY_HANDLE_ALLOCATOR_SPMC (UINT64_C(0) << 63) |
| 356 | #define FFA_MEMORY_HANDLE_INVALID (~UINT64_C(0)) |
| 357 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 358 | /** |
| 359 | * A count of VMs. This has the same range as the VM IDs but we give it a |
| 360 | * different name to make the different semantics clear. |
| 361 | */ |
| 362 | typedef ffa_vm_id_t ffa_vm_count_t; |
| 363 | |
| 364 | /** The index of a vCPU within a particular VM. */ |
| 365 | typedef uint16_t ffa_vcpu_index_t; |
| 366 | |
| 367 | /** |
| 368 | * A count of vCPUs. This has the same range as the vCPU indices but we give it |
| 369 | * a different name to make the different semantics clear. |
| 370 | */ |
| 371 | typedef ffa_vcpu_index_t ffa_vcpu_count_t; |
| 372 | |
| 373 | /** Parameter and return type of FF-A functions. */ |
| 374 | struct ffa_value { |
| 375 | uint64_t func; |
| 376 | uint64_t arg1; |
| 377 | uint64_t arg2; |
| 378 | uint64_t arg3; |
| 379 | uint64_t arg4; |
| 380 | uint64_t arg5; |
| 381 | uint64_t arg6; |
| 382 | uint64_t arg7; |
Raghu Krishnamurthy | 567068e | 2022-12-26 07:46:38 -0800 | [diff] [blame] | 383 | |
| 384 | struct { |
| 385 | uint64_t arg8; |
| 386 | uint64_t arg9; |
| 387 | uint64_t arg10; |
| 388 | uint64_t arg11; |
| 389 | uint64_t arg12; |
| 390 | uint64_t arg13; |
| 391 | uint64_t arg14; |
| 392 | uint64_t arg15; |
| 393 | uint64_t arg16; |
| 394 | uint64_t arg17; |
| 395 | bool valid; |
| 396 | } extended_val; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 397 | }; |
| 398 | |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 399 | static inline uint32_t ffa_func_id(struct ffa_value args) |
| 400 | { |
| 401 | return args.func; |
| 402 | } |
| 403 | |
J-Alves | 13318e3 | 2021-02-22 17:21:00 +0000 | [diff] [blame] | 404 | static inline int32_t ffa_error_code(struct ffa_value val) |
| 405 | { |
| 406 | return (int32_t)val.arg2; |
| 407 | } |
| 408 | |
J-Alves | d6f4e14 | 2021-03-05 13:33:59 +0000 | [diff] [blame] | 409 | static inline ffa_vm_id_t ffa_sender(struct ffa_value args) |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 410 | { |
| 411 | return (args.arg1 >> 16) & 0xffff; |
| 412 | } |
| 413 | |
J-Alves | d6f4e14 | 2021-03-05 13:33:59 +0000 | [diff] [blame] | 414 | static inline ffa_vm_id_t ffa_receiver(struct ffa_value args) |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 415 | { |
| 416 | return args.arg1 & 0xffff; |
| 417 | } |
| 418 | |
| 419 | static inline uint32_t ffa_msg_send_size(struct ffa_value args) |
| 420 | { |
| 421 | return args.arg3; |
| 422 | } |
| 423 | |
Federico Recanati | 25053ee | 2022-03-14 15:01:53 +0100 | [diff] [blame] | 424 | static inline uint32_t ffa_msg_send2_flags(struct ffa_value args) |
| 425 | { |
| 426 | return args.arg2; |
| 427 | } |
| 428 | |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 429 | static inline uint32_t ffa_partition_info_get_count(struct ffa_value args) |
| 430 | { |
| 431 | return args.arg2; |
| 432 | } |
| 433 | |
Raghu Krishnamurthy | 2957b92 | 2022-12-27 10:29:12 -0800 | [diff] [blame] | 434 | static inline uint16_t ffa_partition_info_regs_get_last_idx( |
| 435 | struct ffa_value args) |
| 436 | { |
| 437 | return args.arg2 & 0xFFFF; |
| 438 | } |
| 439 | |
| 440 | static inline uint16_t ffa_partition_info_regs_get_curr_idx( |
| 441 | struct ffa_value args) |
| 442 | { |
| 443 | return (args.arg2 >> 16) & 0xFFFF; |
| 444 | } |
| 445 | |
| 446 | static inline uint16_t ffa_partition_info_regs_get_tag(struct ffa_value args) |
| 447 | { |
| 448 | return (args.arg2 >> 32) & 0xFFFF; |
| 449 | } |
| 450 | |
| 451 | static inline uint16_t ffa_partition_info_regs_get_desc_size( |
| 452 | struct ffa_value args) |
| 453 | { |
| 454 | return (args.arg2 >> 48); |
| 455 | } |
| 456 | |
Andrew Walbran | 1bbe940 | 2020-04-30 16:47:13 +0100 | [diff] [blame] | 457 | static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t a1, uint32_t a2) |
| 458 | { |
| 459 | return (uint64_t)a1 | (uint64_t)a2 << 32; |
| 460 | } |
| 461 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 462 | static inline ffa_memory_handle_t ffa_mem_success_handle(struct ffa_value args) |
| 463 | { |
Andrew Walbran | 1bbe940 | 2020-04-30 16:47:13 +0100 | [diff] [blame] | 464 | return ffa_assemble_handle(args.arg2, args.arg3); |
| 465 | } |
| 466 | |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 467 | static inline ffa_memory_handle_t ffa_frag_handle(struct ffa_value args) |
| 468 | { |
| 469 | return ffa_assemble_handle(args.arg1, args.arg2); |
| 470 | } |
| 471 | |
Andrew Walbran | 1bbe940 | 2020-04-30 16:47:13 +0100 | [diff] [blame] | 472 | static inline struct ffa_value ffa_mem_success(ffa_memory_handle_t handle) |
| 473 | { |
| 474 | return (struct ffa_value){.func = FFA_SUCCESS_32, |
| 475 | .arg2 = (uint32_t)handle, |
| 476 | .arg3 = (uint32_t)(handle >> 32)}; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | static inline ffa_vm_id_t ffa_vm_id(struct ffa_value args) |
| 480 | { |
| 481 | return (args.arg1 >> 16) & 0xffff; |
| 482 | } |
| 483 | |
| 484 | static inline ffa_vcpu_index_t ffa_vcpu_index(struct ffa_value args) |
| 485 | { |
| 486 | return args.arg1 & 0xffff; |
| 487 | } |
| 488 | |
| 489 | static inline uint64_t ffa_vm_vcpu(ffa_vm_id_t vm_id, |
| 490 | ffa_vcpu_index_t vcpu_index) |
| 491 | { |
| 492 | return ((uint32_t)vm_id << 16) | vcpu_index; |
| 493 | } |
| 494 | |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 495 | static inline ffa_vm_id_t ffa_frag_sender(struct ffa_value args) |
| 496 | { |
| 497 | return (args.arg4 >> 16) & 0xffff; |
| 498 | } |
| 499 | |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 500 | static inline uint32_t ffa_feature_intid(struct ffa_value args) |
| 501 | { |
| 502 | return (uint32_t)args.arg2; |
| 503 | } |
| 504 | |
Daniel Boulby | efa381f | 2022-01-18 14:49:40 +0000 | [diff] [blame] | 505 | static inline uint32_t ffa_fwk_msg(struct ffa_value args) |
| 506 | { |
| 507 | return (uint32_t)args.arg2; |
| 508 | } |
| 509 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 510 | /** |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 511 | * Holds the UUID in a struct that is mappable directly to the SMCC calling |
| 512 | * convention, which is used for FF-A calls. |
| 513 | * |
| 514 | * Refer to table 84 of the FF-A 1.0 EAC specification as well as section 5.3 |
| 515 | * of the SMCC Spec 1.2. |
| 516 | */ |
| 517 | struct ffa_uuid { |
| 518 | uint32_t uuid[4]; |
| 519 | }; |
| 520 | |
| 521 | static inline void ffa_uuid_init(uint32_t w0, uint32_t w1, uint32_t w2, |
| 522 | uint32_t w3, struct ffa_uuid *uuid) |
| 523 | { |
| 524 | uuid->uuid[0] = w0; |
| 525 | uuid->uuid[1] = w1; |
| 526 | uuid->uuid[2] = w2; |
| 527 | uuid->uuid[3] = w3; |
| 528 | } |
| 529 | |
| 530 | static inline bool ffa_uuid_equal(const struct ffa_uuid *uuid1, |
| 531 | const struct ffa_uuid *uuid2) |
| 532 | { |
| 533 | return (uuid1->uuid[0] == uuid2->uuid[0]) && |
| 534 | (uuid1->uuid[1] == uuid2->uuid[1]) && |
| 535 | (uuid1->uuid[2] == uuid2->uuid[2]) && |
| 536 | (uuid1->uuid[3] == uuid2->uuid[3]); |
| 537 | } |
| 538 | |
| 539 | static inline bool ffa_uuid_is_null(const struct ffa_uuid *uuid) |
| 540 | { |
| 541 | return (uuid->uuid[0] == 0) && (uuid->uuid[1] == 0) && |
| 542 | (uuid->uuid[2] == 0) && (uuid->uuid[3] == 0); |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * Flags to determine the partition properties, as required by |
| 547 | * FFA_PARTITION_INFO_GET. |
| 548 | * |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 549 | * The values of the flags are specified in table 8.25 of DEN0077A FF-A 1.0 REL |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 550 | * specification, "Partition information descriptor, partition properties". |
| 551 | */ |
| 552 | typedef uint32_t ffa_partition_properties_t; |
| 553 | |
| 554 | /** Partition property: partition supports receipt of direct requests. */ |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 555 | #define FFA_PARTITION_DIRECT_REQ_RECV (UINT32_C(1) << 0) |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 556 | |
| 557 | /** Partition property: partition can send direct requests. */ |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 558 | #define FFA_PARTITION_DIRECT_REQ_SEND (UINT32_C(1) << 1) |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 559 | |
| 560 | /** Partition property: partition can send and receive indirect messages. */ |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 561 | #define FFA_PARTITION_INDIRECT_MSG (UINT32_C(1) << 2) |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 562 | |
J-Alves | 09ff9d8 | 2021-11-02 11:55:20 +0000 | [diff] [blame] | 563 | /** Partition property: partition can receive notifications. */ |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 564 | #define FFA_PARTITION_NOTIFICATION (UINT32_C(1) << 3) |
| 565 | |
| 566 | /** Partition property: partition runs in the AArch64 execution state. */ |
| 567 | #define FFA_PARTITION_AARCH64_EXEC (UINT32_C(1) << 8) |
J-Alves | 09ff9d8 | 2021-11-02 11:55:20 +0000 | [diff] [blame] | 568 | |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 569 | /** |
| 570 | * Holds information returned for each partition by the FFA_PARTITION_INFO_GET |
| 571 | * interface. |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 572 | * This corresponds to table 13.37 "Partition information descriptor" |
| 573 | * in FF-A 1.1 EAC0 specification. |
Daniel Boulby | 1ddb3d7 | 2021-12-16 18:16:50 +0000 | [diff] [blame] | 574 | */ |
| 575 | struct ffa_partition_info { |
| 576 | ffa_vm_id_t vm_id; |
| 577 | ffa_vcpu_count_t vcpu_count; |
| 578 | ffa_partition_properties_t properties; |
| 579 | struct ffa_uuid uuid; |
| 580 | }; |
| 581 | |
J-Alves | dd1ad57 | 2022-01-25 17:58:26 +0000 | [diff] [blame] | 582 | /** Length in bytes of the name in boot information descriptor. */ |
| 583 | #define FFA_BOOT_INFO_NAME_LEN 16 |
| 584 | |
J-Alves | 240d84c | 2022-04-22 12:19:34 +0100 | [diff] [blame] | 585 | /** |
| 586 | * The FF-A boot info descriptor, as defined in table 5.8 of section 5.4.1, of |
| 587 | * the FF-A v1.1 EAC0 specification. |
| 588 | */ |
J-Alves | dd1ad57 | 2022-01-25 17:58:26 +0000 | [diff] [blame] | 589 | struct ffa_boot_info_desc { |
| 590 | char name[FFA_BOOT_INFO_NAME_LEN]; |
| 591 | uint8_t type; |
| 592 | uint8_t reserved; |
| 593 | uint16_t flags; |
| 594 | uint32_t size; |
| 595 | uint64_t content; |
| 596 | }; |
| 597 | |
| 598 | /** FF-A boot information type mask. */ |
| 599 | #define FFA_BOOT_INFO_TYPE_SHIFT 7 |
| 600 | #define FFA_BOOT_INFO_TYPE_MASK (0x1U << FFA_BOOT_INFO_TYPE_SHIFT) |
| 601 | #define FFA_BOOT_INFO_TYPE_STD 0U |
| 602 | #define FFA_BOOT_INFO_TYPE_IMPDEF 1U |
| 603 | |
| 604 | /** Standard boot info type IDs. */ |
| 605 | #define FFA_BOOT_INFO_TYPE_ID_MASK 0x7FU |
| 606 | #define FFA_BOOT_INFO_TYPE_ID_FDT 0U |
| 607 | #define FFA_BOOT_INFO_TYPE_ID_HOB 1U |
| 608 | |
| 609 | /** FF-A Boot Info descriptors flags. */ |
| 610 | #define FFA_BOOT_INFO_FLAG_MBZ_MASK 0xFFF0U |
| 611 | |
| 612 | /** Bits [1:0] encode the format of the name field in ffa_boot_info_desc. */ |
| 613 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT 0U |
| 614 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK \ |
| 615 | (0x3U << FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT) |
| 616 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_STRING 0x0U |
| 617 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_UUID 0x1U |
| 618 | |
| 619 | /** Bits [3:2] encode the format of the content field in ffa_boot_info_desc. */ |
| 620 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT 2 |
| 621 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK \ |
| 622 | (0x3U << FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT) |
| 623 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_VALUE 0x1U |
| 624 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_ADDR 0x0U |
| 625 | |
| 626 | static inline uint16_t ffa_boot_info_content_format( |
| 627 | struct ffa_boot_info_desc *desc) |
| 628 | { |
| 629 | return (desc->flags & FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK) >> |
| 630 | FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT; |
| 631 | } |
| 632 | |
| 633 | static inline uint16_t ffa_boot_info_name_format( |
| 634 | struct ffa_boot_info_desc *desc) |
| 635 | { |
| 636 | return (desc->flags & FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK) >> |
| 637 | FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT; |
| 638 | } |
| 639 | |
| 640 | static inline uint8_t ffa_boot_info_type_id(struct ffa_boot_info_desc *desc) |
| 641 | { |
| 642 | return desc->type & FFA_BOOT_INFO_TYPE_ID_MASK; |
| 643 | } |
| 644 | |
| 645 | static inline uint8_t ffa_boot_info_type(struct ffa_boot_info_desc *desc) |
| 646 | { |
| 647 | return (desc->type & FFA_BOOT_INFO_TYPE_MASK) >> |
| 648 | FFA_BOOT_INFO_TYPE_SHIFT; |
| 649 | } |
| 650 | |
| 651 | /** Length in bytes of the signature in the boot descriptor. */ |
| 652 | #define FFA_BOOT_INFO_HEADER_SIGNATURE_LEN 4 |
| 653 | |
J-Alves | 240d84c | 2022-04-22 12:19:34 +0100 | [diff] [blame] | 654 | /** |
| 655 | * The FF-A boot information header, as defined in table 5.9 of section 5.4.2, |
| 656 | * of the FF-A v1.1 EAC0 specification. |
| 657 | */ |
J-Alves | dd1ad57 | 2022-01-25 17:58:26 +0000 | [diff] [blame] | 658 | struct ffa_boot_info_header { |
| 659 | uint32_t signature; |
| 660 | uint32_t version; |
| 661 | uint32_t info_blob_size; |
| 662 | uint32_t desc_size; |
| 663 | uint32_t desc_count; |
| 664 | uint32_t desc_offset; |
| 665 | uint64_t reserved; |
| 666 | struct ffa_boot_info_desc boot_info[]; |
| 667 | }; |
| 668 | |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 669 | /** |
J-Alves | 980d199 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 670 | * FF-A v1.1 specification restricts the number of notifications to a maximum |
| 671 | * of 64. Following all possible bitmaps. |
| 672 | */ |
| 673 | #define FFA_NOTIFICATION_MASK(ID) (UINT64_C(1) << ID) |
| 674 | |
| 675 | typedef uint64_t ffa_notifications_bitmap_t; |
| 676 | |
| 677 | #define MAX_FFA_NOTIFICATIONS 64U |
| 678 | |
| 679 | /** |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 680 | * Flag for notification bind and set, to specify call is about per-vCPU |
| 681 | * notifications. |
| 682 | */ |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 683 | #define FFA_NOTIFICATION_FLAG_PER_VCPU (UINT32_C(1) << 0) |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 684 | |
Federico Recanati | e73d283 | 2022-04-20 11:10:52 +0200 | [diff] [blame] | 685 | #define FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK FFA_NOTIFICATION_MASK(0) |
| 686 | #define FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK FFA_NOTIFICATION_MASK(32) |
| 687 | |
| 688 | /** |
| 689 | * Helper functions to check for buffer full notification. |
| 690 | */ |
| 691 | static inline bool is_ffa_hyp_buffer_full_notification( |
| 692 | ffa_notifications_bitmap_t framework) |
| 693 | { |
| 694 | return (framework & FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK) != 0; |
| 695 | } |
| 696 | |
| 697 | static inline bool is_ffa_spm_buffer_full_notification( |
| 698 | ffa_notifications_bitmap_t framework) |
| 699 | { |
| 700 | return (framework & FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK) != 0; |
| 701 | } |
| 702 | |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 703 | /** |
J-Alves | 980d199 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 704 | * Helper function to assemble a 64-bit sized bitmap, from the 32-bit sized lo |
| 705 | * and hi. |
| 706 | * Helpful as FF-A specification defines that the notifications interfaces |
| 707 | * arguments are 32-bit registers. |
| 708 | */ |
| 709 | static inline ffa_notifications_bitmap_t ffa_notifications_bitmap(uint32_t lo, |
| 710 | uint32_t hi) |
| 711 | { |
| 712 | return (ffa_notifications_bitmap_t)hi << 32U | lo; |
| 713 | } |
| 714 | |
J-Alves | 98ff956 | 2021-09-09 14:39:41 +0100 | [diff] [blame] | 715 | static inline ffa_notifications_bitmap_t ffa_notification_get_from_sp( |
| 716 | struct ffa_value val) |
| 717 | { |
| 718 | return ffa_notifications_bitmap((uint32_t)val.arg2, (uint32_t)val.arg3); |
| 719 | } |
| 720 | |
| 721 | static inline ffa_notifications_bitmap_t ffa_notification_get_from_vm( |
| 722 | struct ffa_value val) |
| 723 | { |
| 724 | return ffa_notifications_bitmap((uint32_t)val.arg4, (uint32_t)val.arg5); |
| 725 | } |
| 726 | |
Federico Recanati | e73d283 | 2022-04-20 11:10:52 +0200 | [diff] [blame] | 727 | static inline ffa_notifications_bitmap_t ffa_notification_get_from_framework( |
| 728 | struct ffa_value val) |
| 729 | { |
| 730 | return ffa_notifications_bitmap((uint32_t)val.arg6, (uint32_t)val.arg7); |
| 731 | } |
| 732 | |
J-Alves | 980d199 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 733 | /** |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 734 | * Flags used in calls to FFA_NOTIFICATION_GET interface. |
| 735 | */ |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 736 | #define FFA_NOTIFICATION_FLAG_BITMAP_SP (UINT32_C(1) << 0) |
| 737 | #define FFA_NOTIFICATION_FLAG_BITMAP_VM (UINT32_C(1) << 1) |
| 738 | #define FFA_NOTIFICATION_FLAG_BITMAP_SPM (UINT32_C(1) << 2) |
| 739 | #define FFA_NOTIFICATION_FLAG_BITMAP_HYP (UINT32_C(1) << 3) |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 740 | |
J-Alves | a375507 | 2021-11-26 16:01:08 +0000 | [diff] [blame] | 741 | /* Flag to configure notification as being per vCPU. */ |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 742 | #define FFA_NOTIFICATIONS_FLAG_PER_VCPU (UINT32_C(1) << 0) |
J-Alves | a375507 | 2021-11-26 16:01:08 +0000 | [diff] [blame] | 743 | |
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 744 | /** Flag for FFA_NOTIFICATION_SET to delay Schedule Receiver Interrupt */ |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 745 | #define FFA_NOTIFICATIONS_FLAG_DELAY_SRI (UINT32_C(1) << 1) |
| 746 | |
| 747 | #define FFA_NOTIFICATIONS_FLAGS_VCPU_ID(id) \ |
| 748 | ((((uint32_t)(id)) & UINT32_C(0xffff)) << 16) |
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 749 | |
J-Alves | be6e303 | 2021-11-30 14:54:12 +0000 | [diff] [blame] | 750 | static inline ffa_vcpu_index_t ffa_notifications_get_vcpu(struct ffa_value args) |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 751 | { |
J-Alves | be6e303 | 2021-11-30 14:54:12 +0000 | [diff] [blame] | 752 | return (ffa_vcpu_index_t)(args.arg1 >> 16 & 0xffffU); |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | /** |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 756 | * The max number of IDs for return of FFA_NOTIFICATION_INFO_GET. |
| 757 | */ |
| 758 | #define FFA_NOTIFICATIONS_INFO_GET_MAX_IDS 20U |
| 759 | |
| 760 | /** |
| 761 | * Number of registers to use in successfull return of interface |
| 762 | * FFA_NOTIFICATION_INFO_GET. |
| 763 | */ |
| 764 | #define FFA_NOTIFICATIONS_INFO_GET_REGS_RET 5U |
| 765 | |
| 766 | #define FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING 0x1U |
| 767 | |
| 768 | /** |
| 769 | * Helper macros for return parameter encoding as described in section 17.7.1 |
| 770 | * of the FF-A v1.1 Beta0 specification. |
| 771 | */ |
| 772 | #define FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT 0x7U |
| 773 | #define FFA_NOTIFICATIONS_LISTS_COUNT_MASK 0x1fU |
| 774 | #define FFA_NOTIFICATIONS_LIST_SHIFT(l) (2 * (l - 1) + 12) |
| 775 | #define FFA_NOTIFICATIONS_LIST_SIZE_MASK 0x3U |
| 776 | |
| 777 | static inline uint32_t ffa_notification_info_get_lists_count( |
| 778 | struct ffa_value args) |
| 779 | { |
| 780 | return (uint32_t)(args.arg2 >> FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT) & |
| 781 | FFA_NOTIFICATIONS_LISTS_COUNT_MASK; |
| 782 | } |
| 783 | |
| 784 | static inline uint32_t ffa_notification_info_get_list_size( |
| 785 | struct ffa_value args, unsigned int list_idx) |
| 786 | { |
| 787 | return ((uint32_t)args.arg2 >> FFA_NOTIFICATIONS_LIST_SHIFT(list_idx)) & |
| 788 | FFA_NOTIFICATIONS_LIST_SIZE_MASK; |
| 789 | } |
| 790 | |
| 791 | static inline bool ffa_notification_info_get_more_pending(struct ffa_value args) |
| 792 | { |
| 793 | return (args.arg2 & FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING) != 0U; |
| 794 | } |
| 795 | |
| 796 | /** |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 797 | * A set of contiguous pages which is part of a memory region. This corresponds |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 798 | * to table 10.14 of the FF-A v1.1 EAC0 specification, "Constituent memory |
| 799 | * region descriptor". |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 800 | */ |
| 801 | struct ffa_memory_region_constituent { |
| 802 | /** |
| 803 | * The base IPA of the constituent memory region, aligned to 4 kiB page |
| 804 | * size granularity. |
| 805 | */ |
| 806 | uint64_t address; |
| 807 | /** The number of 4 kiB pages in the constituent memory region. */ |
| 808 | uint32_t page_count; |
| 809 | /** Reserved field, must be 0. */ |
| 810 | uint32_t reserved; |
| 811 | }; |
| 812 | |
| 813 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 814 | * A set of pages comprising a memory region. This corresponds to table 10.13 of |
| 815 | * the FF-A v1.1 EAC0 specification, "Composite memory region descriptor". |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 816 | */ |
| 817 | struct ffa_composite_memory_region { |
| 818 | /** |
| 819 | * The total number of 4 kiB pages included in this memory region. This |
| 820 | * must be equal to the sum of page counts specified in each |
| 821 | * `ffa_memory_region_constituent`. |
| 822 | */ |
| 823 | uint32_t page_count; |
| 824 | /** |
| 825 | * The number of constituents (`ffa_memory_region_constituent`) |
| 826 | * included in this memory region range. |
| 827 | */ |
| 828 | uint32_t constituent_count; |
| 829 | /** Reserved field, must be 0. */ |
| 830 | uint64_t reserved_0; |
| 831 | /** An array of `constituent_count` memory region constituents. */ |
| 832 | struct ffa_memory_region_constituent constituents[]; |
| 833 | }; |
| 834 | |
| 835 | /** Flags to indicate properties of receivers during memory region retrieval. */ |
| 836 | typedef uint8_t ffa_memory_receiver_flags_t; |
| 837 | |
| 838 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 839 | * This corresponds to table 10.15 of the FF-A v1.1 EAC0 specification, "Memory |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 840 | * access permissions descriptor". |
| 841 | */ |
| 842 | struct ffa_memory_region_attributes { |
| 843 | /** The ID of the VM to which the memory is being given or shared. */ |
| 844 | ffa_vm_id_t receiver; |
| 845 | /** |
| 846 | * The permissions with which the memory region should be mapped in the |
| 847 | * receiver's page table. |
| 848 | */ |
| 849 | ffa_memory_access_permissions_t permissions; |
| 850 | /** |
| 851 | * Flags used during FFA_MEM_RETRIEVE_REQ and FFA_MEM_RETRIEVE_RESP |
| 852 | * for memory regions with multiple borrowers. |
| 853 | */ |
| 854 | ffa_memory_receiver_flags_t flags; |
| 855 | }; |
| 856 | |
| 857 | /** Flags to control the behaviour of a memory sharing transaction. */ |
| 858 | typedef uint32_t ffa_memory_region_flags_t; |
| 859 | |
| 860 | /** |
| 861 | * Clear memory region contents after unmapping it from the sender and before |
| 862 | * mapping it for any receiver. |
| 863 | */ |
| 864 | #define FFA_MEMORY_REGION_FLAG_CLEAR 0x1 |
| 865 | |
| 866 | /** |
| 867 | * Whether the hypervisor may time slice the memory sharing or retrieval |
| 868 | * operation. |
| 869 | */ |
| 870 | #define FFA_MEMORY_REGION_FLAG_TIME_SLICE 0x2 |
| 871 | |
| 872 | /** |
| 873 | * Whether the hypervisor should clear the memory region after the receiver |
| 874 | * relinquishes it or is aborted. |
| 875 | */ |
| 876 | #define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH 0x4 |
| 877 | |
| 878 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_MASK ((0x3U) << 3) |
| 879 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_UNSPECIFIED ((0x0U) << 3) |
| 880 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE ((0x1U) << 3) |
| 881 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_LEND ((0x2U) << 3) |
| 882 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_DONATE ((0x3U) << 3) |
| 883 | |
Federico Recanati | 85090c4 | 2021-12-15 13:17:54 +0100 | [diff] [blame] | 884 | #define FFA_MEMORY_REGION_ADDRESS_RANGE_HINT_VALID ((0x1U) << 9) |
| 885 | #define FFA_MEMORY_REGION_ADDRESS_RANGE_HINT_MASK ((0xFU) << 5) |
| 886 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 887 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 888 | * This corresponds to table 10.16 of the FF-A v1.1 EAC0 specification, |
| 889 | * "Endpoint memory access descriptor". |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 890 | */ |
| 891 | struct ffa_memory_access { |
| 892 | struct ffa_memory_region_attributes receiver_permissions; |
| 893 | /** |
| 894 | * Offset in bytes from the start of the outer `ffa_memory_region` to |
| 895 | * an `ffa_composite_memory_region` struct. |
| 896 | */ |
| 897 | uint32_t composite_memory_region_offset; |
| 898 | uint64_t reserved_0; |
| 899 | }; |
| 900 | |
J-Alves | 363f572 | 2022-04-25 17:37:37 +0100 | [diff] [blame] | 901 | /** The maximum number of recipients a memory region may be sent to. */ |
J-Alves | ba0e617 | 2022-04-25 17:41:40 +0100 | [diff] [blame] | 902 | #define MAX_MEM_SHARE_RECIPIENTS UINT32_C(2) |
J-Alves | 363f572 | 2022-04-25 17:37:37 +0100 | [diff] [blame] | 903 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 904 | /** |
| 905 | * Information about a set of pages which are being shared. This corresponds to |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 906 | * table 10.20 of the FF-A v1.1 EAC0 specification, "Lend, donate or share |
| 907 | * memory transaction descriptor". Note that it is also used for retrieve |
| 908 | * requests and responses. |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 909 | */ |
| 910 | struct ffa_memory_region { |
| 911 | /** |
| 912 | * The ID of the VM which originally sent the memory region, i.e. the |
| 913 | * owner. |
| 914 | */ |
| 915 | ffa_vm_id_t sender; |
| 916 | ffa_memory_attributes_t attributes; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 917 | /** Flags to control behaviour of the transaction. */ |
| 918 | ffa_memory_region_flags_t flags; |
| 919 | ffa_memory_handle_t handle; |
| 920 | /** |
| 921 | * An implementation defined value associated with the receiver and the |
| 922 | * memory region. |
| 923 | */ |
| 924 | uint64_t tag; |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 925 | /* Size of the memory access descriptor. */ |
| 926 | uint32_t memory_access_desc_size; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 927 | /** |
| 928 | * The number of `ffa_memory_access` entries included in this |
| 929 | * transaction. |
| 930 | */ |
| 931 | uint32_t receiver_count; |
| 932 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 933 | * Offset of the 'receivers' field, which relates to the memory access |
| 934 | * descriptors. |
| 935 | */ |
| 936 | uint32_t receivers_offset; |
| 937 | /** Reserved field (12 bytes) must be 0. */ |
| 938 | uint32_t reserved[3]; |
| 939 | /** |
Federico Recanati | 3ddf28e | 2021-12-20 09:40:26 +0100 | [diff] [blame] | 940 | * An array of `receiver_count` endpoint memory access descriptors. |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 941 | * Each one specifies a memory region offset, an endpoint and the |
| 942 | * attributes with which this memory region should be mapped in that |
| 943 | * endpoint's page table. |
| 944 | */ |
| 945 | struct ffa_memory_access receivers[]; |
| 946 | }; |
| 947 | |
| 948 | /** |
| 949 | * Descriptor used for FFA_MEM_RELINQUISH requests. This corresponds to table |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 950 | * 16.25 of the FF-A v1.1 EAC0 specification, "Descriptor to relinquish a memory |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 951 | * region". |
| 952 | */ |
| 953 | struct ffa_mem_relinquish { |
| 954 | ffa_memory_handle_t handle; |
| 955 | ffa_memory_region_flags_t flags; |
| 956 | uint32_t endpoint_count; |
| 957 | ffa_vm_id_t endpoints[]; |
| 958 | }; |
| 959 | |
| 960 | /** |
| 961 | * Gets the `ffa_composite_memory_region` for the given receiver from an |
| 962 | * `ffa_memory_region`, or NULL if it is not valid. |
| 963 | */ |
| 964 | static inline struct ffa_composite_memory_region * |
| 965 | ffa_memory_region_get_composite(struct ffa_memory_region *memory_region, |
| 966 | uint32_t receiver_index) |
| 967 | { |
| 968 | uint32_t offset = memory_region->receivers[receiver_index] |
| 969 | .composite_memory_region_offset; |
| 970 | |
| 971 | if (offset == 0) { |
| 972 | return NULL; |
| 973 | } |
| 974 | |
| 975 | return (struct ffa_composite_memory_region *)((uint8_t *)memory_region + |
| 976 | offset); |
| 977 | } |
| 978 | |
| 979 | static inline uint32_t ffa_mem_relinquish_init( |
| 980 | struct ffa_mem_relinquish *relinquish_request, |
| 981 | ffa_memory_handle_t handle, ffa_memory_region_flags_t flags, |
| 982 | ffa_vm_id_t sender) |
| 983 | { |
| 984 | relinquish_request->handle = handle; |
| 985 | relinquish_request->flags = flags; |
| 986 | relinquish_request->endpoint_count = 1; |
| 987 | relinquish_request->endpoints[0] = sender; |
| 988 | return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_vm_id_t); |
| 989 | } |
| 990 | |
J-Alves | 126ab50 | 2022-09-29 11:37:33 +0100 | [diff] [blame] | 991 | void ffa_copy_memory_region_constituents( |
| 992 | struct ffa_memory_region_constituent *dest, |
| 993 | const struct ffa_memory_region_constituent *src); |
| 994 | |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 995 | /** |
| 996 | * Endpoint RX/TX descriptor, as defined by Table 13.27 in FF-A v1.1 EAC0. |
| 997 | * It's used by the Hypervisor to describe the RX/TX buffers mapped by a VM |
| 998 | * to the SPMC, in order to allow indirect messaging. |
| 999 | */ |
| 1000 | struct ffa_endpoint_rx_tx_descriptor { |
| 1001 | ffa_vm_id_t endpoint_id; |
| 1002 | uint16_t reserved; |
| 1003 | |
| 1004 | /* |
| 1005 | * 8-byte aligned offset from the base address of this descriptor to the |
| 1006 | * `ffa_composite_memory_region` describing the RX buffer. |
| 1007 | */ |
| 1008 | uint32_t rx_offset; |
| 1009 | |
| 1010 | /* |
| 1011 | * 8-byte aligned offset from the base address of this descriptor to the |
| 1012 | * `ffa_composite_memory_region` describing the TX buffer. |
| 1013 | */ |
| 1014 | uint32_t tx_offset; |
| 1015 | |
| 1016 | /* Pad to align on 16-byte boundary. */ |
| 1017 | uint32_t pad; |
| 1018 | }; |
| 1019 | |
| 1020 | static inline struct ffa_composite_memory_region * |
| 1021 | ffa_enpoint_get_rx_memory_region(struct ffa_endpoint_rx_tx_descriptor *desc) |
| 1022 | { |
| 1023 | return (struct ffa_composite_memory_region *)((uintptr_t)desc + |
| 1024 | desc->rx_offset); |
| 1025 | } |
| 1026 | |
| 1027 | static inline struct ffa_composite_memory_region * |
| 1028 | ffa_enpoint_get_tx_memory_region(struct ffa_endpoint_rx_tx_descriptor *desc) |
| 1029 | { |
| 1030 | return (struct ffa_composite_memory_region *)((uintptr_t)desc + |
| 1031 | desc->tx_offset); |
| 1032 | } |
| 1033 | |
J-Alves | 2d8457f | 2022-10-05 11:06:41 +0100 | [diff] [blame^] | 1034 | void ffa_memory_region_init_header(struct ffa_memory_region *memory_region, |
| 1035 | ffa_vm_id_t sender, |
| 1036 | ffa_memory_attributes_t attributes, |
| 1037 | ffa_memory_region_flags_t flags, |
| 1038 | ffa_memory_handle_t handle, uint32_t tag, |
| 1039 | uint32_t receiver_count); |
J-Alves | b44bb7d | 2022-04-25 15:43:46 +0100 | [diff] [blame] | 1040 | void ffa_memory_access_init_permissions( |
| 1041 | struct ffa_memory_access *receiver, ffa_vm_id_t receiver_id, |
| 1042 | enum ffa_data_access data_access, |
| 1043 | enum ffa_instruction_access instruction_access, |
| 1044 | ffa_memory_receiver_flags_t flags); |
J-Alves | 4508543 | 2022-04-22 16:19:20 +0100 | [diff] [blame] | 1045 | uint32_t ffa_memory_region_init_single_receiver( |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 1046 | struct ffa_memory_region *memory_region, size_t memory_region_max_size, |
| 1047 | ffa_vm_id_t sender, ffa_vm_id_t receiver, |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1048 | const struct ffa_memory_region_constituent constituents[], |
| 1049 | uint32_t constituent_count, uint32_t tag, |
| 1050 | ffa_memory_region_flags_t flags, enum ffa_data_access data_access, |
| 1051 | enum ffa_instruction_access instruction_access, |
| 1052 | enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 1053 | enum ffa_memory_shareability shareability, uint32_t *fragment_length, |
| 1054 | uint32_t *total_length); |
J-Alves | f4eecf7 | 2022-07-20 16:05:34 +0100 | [diff] [blame] | 1055 | uint32_t ffa_memory_region_init( |
| 1056 | struct ffa_memory_region *memory_region, size_t memory_region_max_size, |
| 1057 | ffa_vm_id_t sender, struct ffa_memory_access receivers[], |
| 1058 | uint32_t receiver_count, |
| 1059 | const struct ffa_memory_region_constituent constituents[], |
| 1060 | uint32_t constituent_count, uint32_t tag, |
| 1061 | ffa_memory_region_flags_t flags, enum ffa_memory_type type, |
| 1062 | enum ffa_memory_cacheability cacheability, |
| 1063 | enum ffa_memory_shareability shareability, uint32_t *fragment_length, |
| 1064 | uint32_t *total_length); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1065 | uint32_t ffa_memory_retrieve_request_init( |
| 1066 | struct ffa_memory_region *memory_region, ffa_memory_handle_t handle, |
J-Alves | 9b24ed8 | 2022-08-04 13:12:45 +0100 | [diff] [blame] | 1067 | ffa_vm_id_t sender, struct ffa_memory_access receivers[], |
| 1068 | uint32_t receiver_count, uint32_t tag, ffa_memory_region_flags_t flags, |
| 1069 | enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, |
| 1070 | enum ffa_memory_shareability shareability); |
| 1071 | uint32_t ffa_memory_retrieve_request_init_single_receiver( |
| 1072 | struct ffa_memory_region *memory_region, ffa_memory_handle_t handle, |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1073 | ffa_vm_id_t sender, ffa_vm_id_t receiver, uint32_t tag, |
| 1074 | ffa_memory_region_flags_t flags, enum ffa_data_access data_access, |
| 1075 | enum ffa_instruction_access instruction_access, |
| 1076 | enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, |
| 1077 | enum ffa_memory_shareability shareability); |
| 1078 | uint32_t ffa_memory_lender_retrieve_request_init( |
| 1079 | struct ffa_memory_region *memory_region, ffa_memory_handle_t handle, |
| 1080 | ffa_vm_id_t sender); |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 1081 | uint32_t ffa_memory_fragment_init( |
| 1082 | struct ffa_memory_region_constituent *fragment, |
| 1083 | size_t fragment_max_size, |
| 1084 | const struct ffa_memory_region_constituent constituents[], |
| 1085 | uint32_t constituent_count, uint32_t *fragment_length); |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 1086 | void ffa_endpoint_rx_tx_descriptor_init( |
| 1087 | struct ffa_endpoint_rx_tx_descriptor *desc, ffa_vm_id_t endpoint_id, |
| 1088 | uint64_t rx_address, uint64_t tx_address); |