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