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 | |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 11 | #include "hf/static_assert.h" |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 12 | #include "hf/types.h" |
| 13 | |
Karl Meakin | 0e617d9 | 2024-04-05 12:55:22 +0100 | [diff] [blame] | 14 | /** |
| 15 | * The version number of a Firmware Framework implementation is a 31-bit |
| 16 | * unsigned integer, with the upper 15 bits denoting the major revision, |
| 17 | * and the lower 16 bits denoting the minor revision. |
| 18 | * |
| 19 | * See FF-A specification v1.2 ALP1, section 13.2.1. |
| 20 | */ |
| 21 | enum ffa_version { |
| 22 | FFA_VERSION_1_0 = 0x10000, |
| 23 | FFA_VERSION_1_1 = 0x10001, |
| 24 | FFA_VERSION_1_2 = 0x10002, |
Karl Meakin | 59352b3 | 2025-02-25 12:19:45 +0000 | [diff] [blame] | 25 | /* |
| 26 | * Use the value of `FFA_VERSION` passed by the build system, otherwise default |
| 27 | * to latest FF-A version. |
| 28 | */ |
| 29 | #ifdef FFA_VERSION |
| 30 | FFA_VERSION_COMPILED = FFA_VERSION, |
| 31 | #else |
Karl Meakin | 0e617d9 | 2024-04-05 12:55:22 +0100 | [diff] [blame] | 32 | FFA_VERSION_COMPILED = FFA_VERSION_1_2, |
Karl Meakin | 59352b3 | 2025-02-25 12:19:45 +0000 | [diff] [blame] | 33 | #endif |
Karl Meakin | 0e617d9 | 2024-04-05 12:55:22 +0100 | [diff] [blame] | 34 | }; |
Daniel Boulby | 6e32c61 | 2021-02-17 15:09:41 +0000 | [diff] [blame] | 35 | |
Karl Meakin | 59352b3 | 2025-02-25 12:19:45 +0000 | [diff] [blame] | 36 | static_assert((FFA_VERSION_1_0 <= FFA_VERSION_COMPILED) && |
| 37 | (FFA_VERSION_1_2 >= FFA_VERSION_COMPILED), |
| 38 | "FFA_VERSION_COMPILED must be between v1.0 and v1.2"); |
| 39 | |
Karl Meakin | 0e617d9 | 2024-04-05 12:55:22 +0100 | [diff] [blame] | 40 | #define FFA_VERSION_MBZ_BIT (1U << 31U) |
| 41 | #define FFA_VERSION_MAJOR_SHIFT (16U) |
| 42 | #define FFA_VERSION_MAJOR_MASK (0x7FFFU) |
| 43 | #define FFA_VERSION_MINOR_SHIFT (0U) |
| 44 | #define FFA_VERSION_MINOR_MASK (0xFFFFU) |
| 45 | |
| 46 | /** Return true if the version is valid (i.e. bit 31 is 0). */ |
| 47 | static inline bool ffa_version_is_valid(uint32_t version) |
| 48 | { |
| 49 | return (version & FFA_VERSION_MBZ_BIT) == 0; |
| 50 | } |
| 51 | |
| 52 | /** Construct a version from a pair of major and minor components. */ |
| 53 | static inline enum ffa_version make_ffa_version(uint16_t major, uint16_t minor) |
| 54 | { |
| 55 | return (enum ffa_version)((major << FFA_VERSION_MAJOR_SHIFT) | |
| 56 | (minor << FFA_VERSION_MINOR_SHIFT)); |
| 57 | } |
| 58 | |
| 59 | /** Get the major component of the version. */ |
| 60 | static inline uint16_t ffa_version_get_major(enum ffa_version version) |
| 61 | { |
| 62 | return (version >> FFA_VERSION_MAJOR_SHIFT) & FFA_VERSION_MAJOR_MASK; |
| 63 | } |
| 64 | |
| 65 | /** Get the minor component of the version. */ |
| 66 | static inline uint16_t ffa_version_get_minor(enum ffa_version version) |
| 67 | { |
| 68 | return (version >> FFA_VERSION_MINOR_SHIFT) & FFA_VERSION_MINOR_MASK; |
| 69 | } |
Olivier Deprez | 62d99e3 | 2020-01-09 15:58:07 +0100 | [diff] [blame] | 70 | |
Daniel Boulby | c7dc932 | 2023-10-27 15:12:07 +0100 | [diff] [blame] | 71 | /** |
| 72 | * Check major versions are equal and the minor version of the caller is |
| 73 | * less than or equal to the minor version of the callee. |
| 74 | */ |
Karl Meakin | 0e617d9 | 2024-04-05 12:55:22 +0100 | [diff] [blame] | 75 | static inline bool ffa_versions_are_compatible(enum ffa_version caller, |
| 76 | enum ffa_version callee) |
| 77 | { |
| 78 | return ffa_version_get_major(caller) == ffa_version_get_major(callee) && |
| 79 | ffa_version_get_minor(caller) <= ffa_version_get_minor(callee); |
| 80 | } |
Daniel Boulby | c7dc932 | 2023-10-27 15:12:07 +0100 | [diff] [blame] | 81 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 82 | /* clang-format off */ |
| 83 | |
| 84 | #define FFA_LOW_32_ID 0x84000060 |
| 85 | #define FFA_HIGH_32_ID 0x8400007F |
| 86 | #define FFA_LOW_64_ID 0xC4000060 |
Fuad Tabba | da72d14 | 2020-07-30 09:17:05 +0100 | [diff] [blame] | 87 | #define FFA_HIGH_64_ID 0xC400007F |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 88 | |
Karl Meakin | f51a35f | 2023-08-07 17:53:52 +0100 | [diff] [blame] | 89 | /** |
| 90 | * FF-A function identifiers. |
| 91 | * Don't forget to update `ffa_func_name` if you add a new one. |
| 92 | */ |
J-Alves | 3829fc0 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 93 | #define FFA_ERROR_32 0x84000060 |
| 94 | #define FFA_SUCCESS_32 0x84000061 |
| 95 | #define FFA_SUCCESS_64 0xC4000061 |
| 96 | #define FFA_INTERRUPT_32 0x84000062 |
| 97 | #define FFA_VERSION_32 0x84000063 |
| 98 | #define FFA_FEATURES_32 0x84000064 |
| 99 | #define FFA_RX_RELEASE_32 0x84000065 |
| 100 | #define FFA_RXTX_MAP_32 0x84000066 |
| 101 | #define FFA_RXTX_MAP_64 0xC4000066 |
| 102 | #define FFA_RXTX_UNMAP_32 0x84000067 |
| 103 | #define FFA_PARTITION_INFO_GET_32 0x84000068 |
| 104 | #define FFA_ID_GET_32 0x84000069 |
| 105 | #define FFA_MSG_POLL_32 0x8400006A /* Legacy FF-A v1.0 */ |
| 106 | #define FFA_MSG_WAIT_32 0x8400006B |
| 107 | #define FFA_YIELD_32 0x8400006C |
| 108 | #define FFA_RUN_32 0x8400006D |
| 109 | #define FFA_MSG_SEND_32 0x8400006E /* Legacy FF-A v1.0 */ |
| 110 | #define FFA_MSG_SEND_DIRECT_REQ_32 0x8400006F |
| 111 | #define FFA_MSG_SEND_DIRECT_REQ_64 0xC400006F |
| 112 | #define FFA_MSG_SEND_DIRECT_RESP_32 0x84000070 |
| 113 | #define FFA_MSG_SEND_DIRECT_RESP_64 0xC4000070 |
| 114 | #define FFA_MEM_DONATE_32 0x84000071 |
J-Alves | 95fbb31 | 2024-03-20 15:19:16 +0000 | [diff] [blame] | 115 | #define FFA_MEM_DONATE_64 0xC4000071 |
J-Alves | 3829fc0 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 116 | #define FFA_MEM_LEND_32 0x84000072 |
J-Alves | 95fbb31 | 2024-03-20 15:19:16 +0000 | [diff] [blame] | 117 | #define FFA_MEM_LEND_64 0xC4000072 |
J-Alves | 3829fc0 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 118 | #define FFA_MEM_SHARE_32 0x84000073 |
J-Alves | 95fbb31 | 2024-03-20 15:19:16 +0000 | [diff] [blame] | 119 | #define FFA_MEM_SHARE_64 0xC4000073 |
J-Alves | 3829fc0 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 120 | #define FFA_MEM_RETRIEVE_REQ_32 0x84000074 |
J-Alves | 95fbb31 | 2024-03-20 15:19:16 +0000 | [diff] [blame] | 121 | #define FFA_MEM_RETRIEVE_REQ_64 0xC4000074 |
J-Alves | 3829fc0 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 122 | #define FFA_MEM_RETRIEVE_RESP_32 0x84000075 |
| 123 | #define FFA_MEM_RELINQUISH_32 0x84000076 |
| 124 | #define FFA_MEM_RECLAIM_32 0x84000077 |
| 125 | #define FFA_MEM_FRAG_RX_32 0x8400007A |
| 126 | #define FFA_MEM_FRAG_TX_32 0x8400007B |
| 127 | #define FFA_NORMAL_WORLD_RESUME 0x8400007C |
| 128 | |
| 129 | /* FF-A v1.1 */ |
| 130 | #define FFA_NOTIFICATION_BITMAP_CREATE_32 0x8400007D |
| 131 | #define FFA_NOTIFICATION_BITMAP_DESTROY_32 0x8400007E |
| 132 | #define FFA_NOTIFICATION_BIND_32 0x8400007F |
| 133 | #define FFA_NOTIFICATION_UNBIND_32 0x84000080 |
| 134 | #define FFA_NOTIFICATION_SET_32 0x84000081 |
| 135 | #define FFA_NOTIFICATION_GET_32 0x84000082 |
| 136 | #define FFA_NOTIFICATION_INFO_GET_64 0xC4000083 |
| 137 | #define FFA_RX_ACQUIRE_32 0x84000084 |
| 138 | #define FFA_SPM_ID_GET_32 0x84000085 |
| 139 | #define FFA_MSG_SEND2_32 0x84000086 |
| 140 | #define FFA_SECONDARY_EP_REGISTER_64 0xC4000087 |
| 141 | #define FFA_MEM_PERM_GET_32 0x84000088 |
| 142 | #define FFA_MEM_PERM_SET_32 0x84000089 |
Raghu Krishnamurthy | ea6d25f | 2021-09-14 15:27:06 -0700 | [diff] [blame] | 143 | #define FFA_MEM_PERM_GET_64 0xC4000088 |
| 144 | #define FFA_MEM_PERM_SET_64 0xC4000089 |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 145 | |
Kathleen Capella | e4fe296 | 2023-09-01 17:08:47 -0400 | [diff] [blame] | 146 | /* FF-A v1.2 */ |
Maksims Svecovs | 71b7670 | 2022-05-20 15:32:58 +0100 | [diff] [blame] | 147 | #define FFA_CONSOLE_LOG_32 0x8400008A |
| 148 | #define FFA_CONSOLE_LOG_64 0xC400008A |
Raghu Krishnamurthy | 7592bcb | 2022-12-25 13:09:00 -0800 | [diff] [blame] | 149 | #define FFA_PARTITION_INFO_GET_REGS_64 0xC400008B |
Madhukar Pappireddy | 77d3bcd | 2023-03-01 17:26:22 -0600 | [diff] [blame] | 150 | #define FFA_EL3_INTR_HANDLE_32 0x8400008C |
Kathleen Capella | 41fea93 | 2023-06-23 17:39:28 -0400 | [diff] [blame] | 151 | #define FFA_MSG_SEND_DIRECT_REQ2_64 0xC400008D |
Kathleen Capella | 087e502 | 2023-09-07 18:04:15 -0400 | [diff] [blame] | 152 | #define FFA_MSG_SEND_DIRECT_RESP2_64 0xC400008E |
Maksims Svecovs | 71b7670 | 2022-05-20 15:32:58 +0100 | [diff] [blame] | 153 | |
Karl Meakin | f51a35f | 2023-08-07 17:53:52 +0100 | [diff] [blame] | 154 | /** |
| 155 | * FF-A error codes. |
| 156 | * Don't forget to update `ffa_error_name` if you add a new one. |
| 157 | */ |
Karl Meakin | dc759f5 | 2024-05-07 16:08:02 +0100 | [diff] [blame] | 158 | enum ffa_error { |
| 159 | FFA_NOT_SUPPORTED = -1, |
| 160 | FFA_INVALID_PARAMETERS = -2, |
| 161 | FFA_NO_MEMORY = -3, |
| 162 | FFA_BUSY = -4, |
| 163 | FFA_INTERRUPTED = -5, |
| 164 | FFA_DENIED = -6, |
| 165 | FFA_RETRY = -7, |
| 166 | FFA_ABORTED = -8, |
| 167 | FFA_NO_DATA = -9, |
| 168 | FFA_NOT_READY = -10, |
| 169 | }; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 170 | |
| 171 | /* clang-format on */ |
| 172 | |
Karl Meakin | f51a35f | 2023-08-07 17:53:52 +0100 | [diff] [blame] | 173 | /* Return the name of the function identifier. */ |
| 174 | static inline const char *ffa_func_name(uint32_t func) |
| 175 | { |
| 176 | switch (func) { |
| 177 | case FFA_ERROR_32: |
| 178 | return "FFA_ERROR_32"; |
| 179 | case FFA_SUCCESS_32: |
| 180 | return "FFA_SUCCESS_32"; |
| 181 | case FFA_SUCCESS_64: |
| 182 | return "FFA_SUCCESS_64"; |
| 183 | case FFA_INTERRUPT_32: |
| 184 | return "FFA_INTERRUPT_32"; |
| 185 | case FFA_VERSION_32: |
| 186 | return "FFA_VERSION_32"; |
| 187 | case FFA_FEATURES_32: |
| 188 | return "FFA_FEATURES_32"; |
| 189 | case FFA_RX_RELEASE_32: |
| 190 | return "FFA_RX_RELEASE_32"; |
| 191 | case FFA_RXTX_MAP_32: |
| 192 | return "FFA_RXTX_MAP_32"; |
| 193 | case FFA_RXTX_MAP_64: |
| 194 | return "FFA_RXTX_MAP_64"; |
| 195 | case FFA_RXTX_UNMAP_32: |
| 196 | return "FFA_RXTX_UNMAP_32"; |
| 197 | case FFA_PARTITION_INFO_GET_32: |
| 198 | return "FFA_PARTITION_INFO_GET_32"; |
| 199 | case FFA_ID_GET_32: |
| 200 | return "FFA_ID_GET_32"; |
| 201 | case FFA_MSG_POLL_32: |
| 202 | return "FFA_MSG_POLL_32"; |
| 203 | case FFA_MSG_WAIT_32: |
| 204 | return "FFA_MSG_WAIT_32"; |
| 205 | case FFA_YIELD_32: |
| 206 | return "FFA_YIELD_32"; |
| 207 | case FFA_RUN_32: |
| 208 | return "FFA_RUN_32"; |
| 209 | case FFA_MSG_SEND_32: |
| 210 | return "FFA_MSG_SEND_32"; |
| 211 | case FFA_MSG_SEND_DIRECT_REQ_32: |
| 212 | return "FFA_MSG_SEND_DIRECT_REQ_32"; |
| 213 | case FFA_MSG_SEND_DIRECT_REQ_64: |
| 214 | return "FFA_MSG_SEND_DIRECT_REQ_64"; |
| 215 | case FFA_MSG_SEND_DIRECT_RESP_32: |
| 216 | return "FFA_MSG_SEND_DIRECT_RESP_32"; |
| 217 | case FFA_MSG_SEND_DIRECT_RESP_64: |
| 218 | return "FFA_MSG_SEND_DIRECT_RESP_64"; |
| 219 | case FFA_MEM_DONATE_32: |
| 220 | return "FFA_MEM_DONATE_32"; |
| 221 | case FFA_MEM_LEND_32: |
| 222 | return "FFA_MEM_LEND_32"; |
| 223 | case FFA_MEM_SHARE_32: |
| 224 | return "FFA_MEM_SHARE_32"; |
| 225 | case FFA_MEM_RETRIEVE_REQ_32: |
| 226 | return "FFA_MEM_RETRIEVE_REQ_32"; |
J-Alves | 95fbb31 | 2024-03-20 15:19:16 +0000 | [diff] [blame] | 227 | case FFA_MEM_DONATE_64: |
| 228 | return "FFA_MEM_DONATE_64"; |
| 229 | case FFA_MEM_LEND_64: |
| 230 | return "FFA_MEM_LEND_64"; |
| 231 | case FFA_MEM_SHARE_64: |
| 232 | return "FFA_MEM_SHARE_64"; |
| 233 | case FFA_MEM_RETRIEVE_REQ_64: |
| 234 | return "FFA_MEM_RETRIEVE_REQ_64"; |
Karl Meakin | f51a35f | 2023-08-07 17:53:52 +0100 | [diff] [blame] | 235 | case FFA_MEM_RETRIEVE_RESP_32: |
| 236 | return "FFA_MEM_RETRIEVE_RESP_32"; |
| 237 | case FFA_MEM_RELINQUISH_32: |
| 238 | return "FFA_MEM_RELINQUISH_32"; |
| 239 | case FFA_MEM_RECLAIM_32: |
| 240 | return "FFA_MEM_RECLAIM_32"; |
| 241 | case FFA_MEM_FRAG_RX_32: |
| 242 | return "FFA_MEM_FRAG_RX_32"; |
| 243 | case FFA_MEM_FRAG_TX_32: |
| 244 | return "FFA_MEM_FRAG_TX_32"; |
| 245 | case FFA_NORMAL_WORLD_RESUME: |
| 246 | return "FFA_NORMAL_WORLD_RESUME"; |
| 247 | |
| 248 | /* FF-A v1.1 */ |
| 249 | case FFA_NOTIFICATION_BITMAP_CREATE_32: |
| 250 | return "FFA_NOTIFICATION_BITMAP_CREATE_32"; |
| 251 | case FFA_NOTIFICATION_BITMAP_DESTROY_32: |
| 252 | return "FFA_NOTIFICATION_BITMAP_DESTROY_32"; |
| 253 | case FFA_NOTIFICATION_BIND_32: |
| 254 | return "FFA_NOTIFICATION_BIND_32"; |
| 255 | case FFA_NOTIFICATION_UNBIND_32: |
| 256 | return "FFA_NOTIFICATION_UNBIND_32"; |
| 257 | case FFA_NOTIFICATION_SET_32: |
| 258 | return "FFA_NOTIFICATION_SET_32"; |
| 259 | case FFA_NOTIFICATION_GET_32: |
| 260 | return "FFA_NOTIFICATION_GET_32"; |
| 261 | case FFA_NOTIFICATION_INFO_GET_64: |
| 262 | return "FFA_NOTIFICATION_INFO_GET_64"; |
| 263 | case FFA_RX_ACQUIRE_32: |
| 264 | return "FFA_RX_ACQUIRE_32"; |
| 265 | case FFA_SPM_ID_GET_32: |
| 266 | return "FFA_SPM_ID_GET_32"; |
| 267 | case FFA_MSG_SEND2_32: |
| 268 | return "FFA_MSG_SEND2_32"; |
| 269 | case FFA_SECONDARY_EP_REGISTER_64: |
| 270 | return "FFA_SECONDARY_EP_REGISTER_64"; |
| 271 | case FFA_MEM_PERM_GET_32: |
| 272 | return "FFA_MEM_PERM_GET_32"; |
| 273 | case FFA_MEM_PERM_SET_32: |
| 274 | return "FFA_MEM_PERM_SET_32"; |
| 275 | case FFA_MEM_PERM_GET_64: |
| 276 | return "FFA_MEM_PERM_GET_64"; |
| 277 | case FFA_MEM_PERM_SET_64: |
| 278 | return "FFA_MEM_PERM_SET_64"; |
| 279 | |
| 280 | /* Implementation-defined ABIs. */ |
| 281 | case FFA_CONSOLE_LOG_32: |
| 282 | return "FFA_CONSOLE_LOG_32"; |
| 283 | case FFA_CONSOLE_LOG_64: |
| 284 | return "FFA_CONSOLE_LOG_64"; |
| 285 | case FFA_PARTITION_INFO_GET_REGS_64: |
| 286 | return "FFA_PARTITION_INFO_GET_REGS_64"; |
| 287 | case FFA_EL3_INTR_HANDLE_32: |
| 288 | return "FFA_EL3_INTR_HANDLE_32"; |
| 289 | |
| 290 | default: |
| 291 | return "UNKNOWN"; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | /* Return the name of the error code. */ |
Karl Meakin | dc759f5 | 2024-05-07 16:08:02 +0100 | [diff] [blame] | 296 | static inline const char *ffa_error_name(enum ffa_error error) |
Karl Meakin | f51a35f | 2023-08-07 17:53:52 +0100 | [diff] [blame] | 297 | { |
| 298 | switch (error) { |
| 299 | case FFA_NOT_SUPPORTED: |
| 300 | return "FFA_NOT_SUPPORTED"; |
| 301 | case FFA_INVALID_PARAMETERS: |
| 302 | return "FFA_INVALID_PARAMETERS"; |
| 303 | case FFA_NO_MEMORY: |
| 304 | return "FFA_NO_MEMORY"; |
| 305 | case FFA_BUSY: |
| 306 | return "FFA_BUSY"; |
| 307 | case FFA_INTERRUPTED: |
| 308 | return "FFA_INTERRUPTED"; |
| 309 | case FFA_DENIED: |
| 310 | return "FFA_DENIED"; |
| 311 | case FFA_RETRY: |
| 312 | return "FFA_RETRY"; |
| 313 | case FFA_ABORTED: |
| 314 | return "FFA_ABORTED"; |
| 315 | case FFA_NO_DATA: |
| 316 | return "FFA_NO_DATA"; |
Karl Meakin | dc759f5 | 2024-05-07 16:08:02 +0100 | [diff] [blame] | 317 | case FFA_NOT_READY: |
| 318 | return "FFA_NOT_READY"; |
Karl Meakin | f51a35f | 2023-08-07 17:53:52 +0100 | [diff] [blame] | 319 | } |
Karl Meakin | dc759f5 | 2024-05-07 16:08:02 +0100 | [diff] [blame] | 320 | return "UNKNOWN"; |
Karl Meakin | f51a35f | 2023-08-07 17:53:52 +0100 | [diff] [blame] | 321 | } |
| 322 | |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 323 | /** |
Karl Meakin | 49ec1e4 | 2024-05-10 13:08:24 +0100 | [diff] [blame] | 324 | * Defined in Table 3.1 in the FF-A v.1.2 memory management supplement. |
| 325 | * Input properties: |
| 326 | * - Bits[31:2] and Bit[0] are reserved (SBZ). |
| 327 | * Output properties: |
| 328 | * - Bit[0]: dynamically allocated buffer support. |
| 329 | * - Bit[1]: NS bit handling. |
| 330 | * - Bit[2]: support for retrieval by hypervisor. |
| 331 | * - Bits[31:3] are reserved (MBZ). |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 332 | */ |
Karl Meakin | 49ec1e4 | 2024-05-10 13:08:24 +0100 | [diff] [blame] | 333 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_BUFFER_SUPPORT (0U << 0U) |
| 334 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT (1U << 1U) |
| 335 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_HYPERVISOR_SUPPORT (1U << 2U) |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 336 | |
Karl Meakin | 49ec1e4 | 2024-05-10 13:08:24 +0100 | [diff] [blame] | 337 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_MBZ_HI_BIT (31U) |
| 338 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_MBZ_LO_BIT (2U) |
| 339 | #define FFA_FEATURES_MEM_RETRIEVE_REQ_MBZ_BIT (0U) |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 340 | |
Karl Meakin | 49ec1e4 | 2024-05-10 13:08:24 +0100 | [diff] [blame] | 341 | enum ffa_feature_id { |
| 342 | /* Query interrupt ID of Notification Pending Interrupt. */ |
| 343 | FFA_FEATURE_NPI = 1, |
Karl Meakin | 34b8ae9 | 2023-01-13 13:33:07 +0000 | [diff] [blame] | 344 | |
Karl Meakin | 49ec1e4 | 2024-05-10 13:08:24 +0100 | [diff] [blame] | 345 | /* Query interrupt ID of Schedule Receiver Interrupt. */ |
| 346 | FFA_FEATURE_SRI = 2, |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 347 | |
Karl Meakin | 49ec1e4 | 2024-05-10 13:08:24 +0100 | [diff] [blame] | 348 | /* Query interrupt ID of the Managed Exit Interrupt. */ |
| 349 | FFA_FEATURE_MEI = 3, |
| 350 | }; |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 351 | |
Karl Meakin | 49ec1e4 | 2024-05-10 13:08:24 +0100 | [diff] [blame] | 352 | /** Constants for bitmasks used in FFA_FEATURES. */ |
| 353 | #define FFA_FEATURES_FEATURE_BIT (31U) |
| 354 | #define FFA_FEATURES_FEATURE_MBZ_HI_BIT (30U) |
| 355 | #define FFA_FEATURES_FEATURE_MBZ_LO_BIT (8U) |
| 356 | |
| 357 | #define FFA_FEATURES_NS_SUPPORT_BIT (1U) |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 358 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 359 | /* FF-A function specific constants. */ |
| 360 | #define FFA_MSG_RECV_BLOCK 0x1 |
| 361 | #define FFA_MSG_RECV_BLOCK_MASK 0x1 |
| 362 | |
| 363 | #define FFA_MSG_SEND_NOTIFY 0x1 |
| 364 | #define FFA_MSG_SEND_NOTIFY_MASK 0x1 |
| 365 | |
| 366 | #define FFA_MEM_RECLAIM_CLEAR 0x1 |
| 367 | |
| 368 | #define FFA_SLEEP_INDEFINITE 0 |
| 369 | |
Karl Meakin | 8022005 | 2025-02-20 14:43:34 +0000 | [diff] [blame] | 370 | /* |
| 371 | * The type of memory permissions used by `FFA_MEM_PERM_GET` and |
| 372 | * `FFA_MEM_PERM_SET`. |
| 373 | */ |
| 374 | enum ffa_mem_perm { |
| 375 | FFA_MEM_PERM_RO = 0x7, |
| 376 | FFA_MEM_PERM_RW = 0x5, |
| 377 | FFA_MEM_PERM_RX = 0x3, |
| 378 | }; |
Raghu Krishnamurthy | ea6d25f | 2021-09-14 15:27:06 -0700 | [diff] [blame] | 379 | |
Kathleen Capella | 7253bd5 | 2024-08-14 17:36:09 -0400 | [diff] [blame] | 380 | #define FFA_MSG_WAIT_FLAG_RETAIN_RX UINT32_C(0x1) |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 381 | /* |
Olivier Deprez | 013f4d6 | 2022-11-21 15:46:20 +0100 | [diff] [blame] | 382 | * 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] | 383 | * The Partition count flag is used by FFA_PARTITION_INFO_GET to specify |
| 384 | * if partition info descriptors should be returned or just the count. |
| 385 | */ |
Olivier Deprez | 013f4d6 | 2022-11-21 15:46:20 +0100 | [diff] [blame] | 386 | #define FFA_PARTITION_COUNT_FLAG UINT32_C(0x1) |
| 387 | #define FFA_PARTITION_COUNT_FLAG_MASK (UINT32_C(0x1) << 0) |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 388 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 389 | /** |
| 390 | * For use where the FF-A specification refers explicitly to '4K pages'. Not to |
| 391 | * be confused with PAGE_SIZE, which is the translation granule Hafnium is |
| 392 | * configured to use. |
| 393 | */ |
J-Alves | 715d623 | 2023-02-16 16:33:28 +0000 | [diff] [blame] | 394 | #define FFA_PAGE_SIZE ((size_t)4096) |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 395 | |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 396 | /** 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] | 397 | typedef uint16_t ffa_id_t; |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 398 | |
| 399 | /** |
J-Alves | 661e1b7 | 2023-08-02 13:39:40 +0100 | [diff] [blame] | 400 | * The FF-A v1.2 ALP0, section 6.1 defines that partition IDs are split into two |
| 401 | * parts: |
| 402 | * - Bit15 -> partition type identifier. |
| 403 | * - b'0 -> ID relates to a VM ID. |
| 404 | * - b'1 -> ID relates to an SP ID. |
| 405 | */ |
| 406 | #define FFA_ID_MASK ((ffa_id_t)0x8000) |
| 407 | #define FFA_VM_ID_MASK ((ffa_id_t)0x0000) |
| 408 | |
| 409 | /** |
| 410 | * Helper to check if FF-A ID is a VM ID, managed by the hypervisor. |
| 411 | */ |
| 412 | static inline bool ffa_is_vm_id(ffa_id_t id) |
| 413 | { |
| 414 | return (FFA_ID_MASK & id) == FFA_VM_ID_MASK; |
| 415 | } |
| 416 | |
| 417 | /** |
Karl Meakin | c88c8e9 | 2024-11-29 16:13:55 +0000 | [diff] [blame] | 418 | * Holds the UUID in a struct that is mappable directly to the SMCC calling |
| 419 | * convention, which is used for FF-A calls. |
| 420 | * |
| 421 | * Refer to table 84 of the FF-A 1.0 EAC specification as well as section 5.3 |
| 422 | * of the SMCC Spec 1.2. |
| 423 | */ |
| 424 | struct ffa_uuid { |
| 425 | uint32_t uuid[4]; |
| 426 | }; |
| 427 | |
| 428 | static inline void ffa_uuid_init(uint32_t w0, uint32_t w1, uint32_t w2, |
| 429 | uint32_t w3, struct ffa_uuid *uuid) |
| 430 | { |
| 431 | uuid->uuid[0] = w0; |
| 432 | uuid->uuid[1] = w1; |
| 433 | uuid->uuid[2] = w2; |
| 434 | uuid->uuid[3] = w3; |
| 435 | } |
| 436 | |
| 437 | static inline bool ffa_uuid_equal(const struct ffa_uuid *uuid1, |
| 438 | const struct ffa_uuid *uuid2) |
| 439 | { |
| 440 | return (uuid1->uuid[0] == uuid2->uuid[0]) && |
| 441 | (uuid1->uuid[1] == uuid2->uuid[1]) && |
| 442 | (uuid1->uuid[2] == uuid2->uuid[2]) && |
| 443 | (uuid1->uuid[3] == uuid2->uuid[3]); |
| 444 | } |
| 445 | |
| 446 | static inline bool ffa_uuid_is_null(const struct ffa_uuid *uuid) |
| 447 | { |
| 448 | struct ffa_uuid null = {0}; |
| 449 | |
| 450 | return ffa_uuid_equal(uuid, &null); |
| 451 | } |
| 452 | |
| 453 | static inline void ffa_uuid_from_u64x2(uint64_t uuid_lo, uint64_t uuid_hi, |
| 454 | struct ffa_uuid *uuid) |
| 455 | { |
| 456 | ffa_uuid_init((uint32_t)(uuid_lo & 0xFFFFFFFFU), |
| 457 | (uint32_t)(uuid_lo >> 32), |
| 458 | (uint32_t)(uuid_hi & 0xFFFFFFFFU), |
| 459 | (uint32_t)(uuid_hi >> 32), uuid); |
| 460 | } |
| 461 | |
| 462 | /** |
| 463 | * Split `uuid` into two u64s. |
| 464 | * This function writes to pointer parameters because C does not allow returning |
| 465 | * arrays from functions. |
| 466 | */ |
| 467 | static inline void ffa_uuid_to_u64x2(uint64_t *lo, uint64_t *hi, |
| 468 | const struct ffa_uuid *uuid) |
| 469 | { |
| 470 | *lo = (uint64_t)uuid->uuid[1] << 32 | uuid->uuid[0]; |
| 471 | *hi = (uint64_t)uuid->uuid[3] << 32 | uuid->uuid[2]; |
| 472 | } |
| 473 | |
| 474 | /** |
| 475 | * Partition message header as specified by table 7.1 from FF-A v1.3 ALP0 |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 476 | * specification. |
| 477 | */ |
| 478 | struct ffa_partition_rxtx_header { |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 479 | /* Reserved (SBZ). */ |
| 480 | uint32_t flags; |
| 481 | /* Reserved (SBZ). */ |
| 482 | uint32_t reserved_1; |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 483 | /* Offset from the beginning of the buffer to the message payload. */ |
| 484 | uint32_t offset; |
Karl Meakin | 9ca0551 | 2024-11-29 17:02:32 +0000 | [diff] [blame] | 485 | /* Receiver endpoint ID. */ |
| 486 | ffa_id_t receiver; |
| 487 | /* Sender endpoint ID. */ |
| 488 | ffa_id_t sender; |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 489 | /* Size of message in buffer. */ |
| 490 | uint32_t size; |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 491 | /* Reserved (SBZ). Added in v1.2. */ |
| 492 | uint32_t reserved_2; |
| 493 | /* UUID identifying the communication protocol. Added in v1.2. */ |
| 494 | struct ffa_uuid uuid; |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 495 | }; |
| 496 | |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 497 | #define FFA_RXTX_HEADER_SIZE_V1_1 \ |
| 498 | offsetof(struct ffa_partition_rxtx_header, reserved_2) |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 499 | #define FFA_RXTX_HEADER_SIZE sizeof(struct ffa_partition_rxtx_header) |
J-Alves | 7007993 | 2022-12-07 17:32:20 +0000 | [diff] [blame] | 500 | #define FFA_RXTX_ALLOCATOR_SHIFT 16 |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 501 | |
Karl Meakin | 895007c | 2025-01-13 15:48:07 +0000 | [diff] [blame] | 502 | /** |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 503 | * Initialize a partition message header, with the default values for `flags`, |
| 504 | * `offset` and `uuid` and the v1.1 payload offset. |
| 505 | */ |
| 506 | static inline void ffa_rxtx_header_init_v1_1( |
| 507 | struct ffa_partition_rxtx_header *header, ffa_id_t sender, |
| 508 | ffa_id_t receiver, uint32_t payload_size) |
| 509 | { |
| 510 | header->flags = 0; |
| 511 | header->reserved_1 = 0; |
| 512 | header->offset = FFA_RXTX_HEADER_SIZE_V1_1; |
| 513 | header->sender = sender; |
| 514 | header->receiver = receiver; |
| 515 | header->size = payload_size; |
| 516 | header->reserved_2 = 0; |
| 517 | header->uuid = (struct ffa_uuid){0}; |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Initialize a partition message header, with the default values for `flags`, |
| 522 | * `offset` and `uuid`. |
Karl Meakin | 895007c | 2025-01-13 15:48:07 +0000 | [diff] [blame] | 523 | */ |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 524 | static inline void ffa_rxtx_header_init( |
Karl Meakin | 895007c | 2025-01-13 15:48:07 +0000 | [diff] [blame] | 525 | struct ffa_partition_rxtx_header *header, ffa_id_t sender, |
| 526 | ffa_id_t receiver, uint32_t payload_size) |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 527 | { |
| 528 | header->flags = 0; |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 529 | header->reserved_1 = 0; |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 530 | header->offset = FFA_RXTX_HEADER_SIZE; |
Karl Meakin | 9ca0551 | 2024-11-29 17:02:32 +0000 | [diff] [blame] | 531 | header->sender = sender; |
| 532 | header->receiver = receiver; |
Karl Meakin | 895007c | 2025-01-13 15:48:07 +0000 | [diff] [blame] | 533 | header->size = payload_size; |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 534 | header->reserved_2 = 0; |
| 535 | header->uuid = (struct ffa_uuid){0}; |
| 536 | } |
| 537 | |
| 538 | /** |
| 539 | * Initialize a partition message header, with the default values for `flags` |
| 540 | * and `offset`. |
| 541 | */ |
| 542 | static inline void ffa_rxtx_header_init_with_uuid( |
| 543 | struct ffa_partition_rxtx_header *header, ffa_id_t sender, |
| 544 | ffa_id_t receiver, uint32_t size, struct ffa_uuid uuid) |
| 545 | { |
| 546 | header->flags = 0; |
| 547 | header->reserved_1 = 0; |
| 548 | header->offset = FFA_RXTX_HEADER_SIZE; |
| 549 | header->sender = sender; |
| 550 | header->receiver = receiver; |
| 551 | header->size = size; |
| 552 | header->reserved_2 = 0; |
| 553 | header->uuid = uuid; |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 554 | } |
| 555 | |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 556 | /* The maximum length possible for a single message. */ |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 557 | #define FFA_PARTITION_MSG_PAYLOAD_MAX_V1_1 \ |
| 558 | (HF_MAILBOX_SIZE - FFA_RXTX_HEADER_SIZE_V1_1) |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 559 | #define FFA_PARTITION_MSG_PAYLOAD_MAX (HF_MAILBOX_SIZE - FFA_RXTX_HEADER_SIZE) |
| 560 | |
| 561 | struct ffa_partition_msg { |
| 562 | struct ffa_partition_rxtx_header header; |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 563 | /** |
| 564 | * Prefer using `ffa_partition_msg_payload` to accessing this field |
| 565 | * directly, because the offset does not necessarily correspond to the |
| 566 | * offset of this field. |
| 567 | */ |
Federico Recanati | fc0295e | 2022-02-08 19:37:39 +0100 | [diff] [blame] | 568 | char payload[FFA_PARTITION_MSG_PAYLOAD_MAX]; |
| 569 | }; |
| 570 | |
Karl Meakin | bf580c2 | 2024-12-12 14:31:06 +0000 | [diff] [blame] | 571 | static_assert(sizeof(struct ffa_partition_msg) == HF_MAILBOX_SIZE, |
| 572 | "FF-A message size must match mailbox size"); |
| 573 | |
Karl Meakin | 891eb88 | 2025-01-17 19:11:20 +0000 | [diff] [blame] | 574 | /** |
| 575 | * Get the partition message's payload, according to the header's `offset` |
| 576 | * field. |
| 577 | */ |
| 578 | static inline void *ffa_partition_msg_payload(struct ffa_partition_msg *msg) |
| 579 | { |
| 580 | return (char *)msg + msg->header.offset; |
| 581 | } |
| 582 | |
| 583 | static inline const void *ffa_partition_msg_payload_const( |
| 584 | const struct ffa_partition_msg *msg) |
| 585 | { |
| 586 | return (const char *)msg + msg->header.offset; |
| 587 | } |
| 588 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 589 | /* The maximum length possible for a single message. */ |
| 590 | #define FFA_MSG_PAYLOAD_MAX HF_MAILBOX_SIZE |
| 591 | |
| 592 | enum ffa_data_access { |
| 593 | FFA_DATA_ACCESS_NOT_SPECIFIED, |
| 594 | FFA_DATA_ACCESS_RO, |
| 595 | FFA_DATA_ACCESS_RW, |
| 596 | FFA_DATA_ACCESS_RESERVED, |
| 597 | }; |
| 598 | |
Karl Meakin | f98b2aa | 2023-10-12 16:09:59 +0100 | [diff] [blame] | 599 | static inline const char *ffa_data_access_name(enum ffa_data_access data_access) |
| 600 | { |
| 601 | switch (data_access) { |
| 602 | case FFA_DATA_ACCESS_NOT_SPECIFIED: |
| 603 | return "FFA_DATA_ACCESS_NOT_SPECIFIED"; |
| 604 | case FFA_DATA_ACCESS_RO: |
| 605 | return "FFA_DATA_ACCESS_RO"; |
| 606 | case FFA_DATA_ACCESS_RW: |
| 607 | return "FFA_DATA_ACCESS_RW"; |
| 608 | case FFA_DATA_ACCESS_RESERVED: |
| 609 | return "FFA_DATA_ACCESS_RESERVED"; |
| 610 | } |
| 611 | } |
| 612 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 613 | enum ffa_instruction_access { |
| 614 | FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, |
| 615 | FFA_INSTRUCTION_ACCESS_NX, |
| 616 | FFA_INSTRUCTION_ACCESS_X, |
| 617 | FFA_INSTRUCTION_ACCESS_RESERVED, |
| 618 | }; |
| 619 | |
Karl Meakin | f98b2aa | 2023-10-12 16:09:59 +0100 | [diff] [blame] | 620 | static inline const char *ffa_instruction_access_name( |
| 621 | enum ffa_instruction_access instruction_access) |
| 622 | { |
| 623 | switch (instruction_access) { |
| 624 | case FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED: |
| 625 | return "FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED"; |
| 626 | case FFA_INSTRUCTION_ACCESS_NX: |
| 627 | return "FFA_INSTRUCTION_ACCESS_NX"; |
| 628 | case FFA_INSTRUCTION_ACCESS_X: |
| 629 | return "FFA_INSTRUCTION_ACCESS_X"; |
| 630 | case FFA_INSTRUCTION_ACCESS_RESERVED: |
| 631 | return "FFA_INSTRUCTION_ACCESS_RESERVED"; |
| 632 | } |
| 633 | } |
| 634 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 635 | enum ffa_memory_type { |
| 636 | FFA_MEMORY_NOT_SPECIFIED_MEM, |
| 637 | FFA_MEMORY_DEVICE_MEM, |
| 638 | FFA_MEMORY_NORMAL_MEM, |
| 639 | }; |
| 640 | |
Karl Meakin | f98b2aa | 2023-10-12 16:09:59 +0100 | [diff] [blame] | 641 | static inline const char *ffa_memory_type_name(enum ffa_memory_type type) |
| 642 | { |
| 643 | switch (type) { |
| 644 | case FFA_MEMORY_NOT_SPECIFIED_MEM: |
| 645 | return "FFA_MEMORY_NOT_SPECIFIED_MEM"; |
| 646 | case FFA_MEMORY_DEVICE_MEM: |
| 647 | return "FFA_MEMORY_DEVICE_MEM"; |
| 648 | case FFA_MEMORY_NORMAL_MEM: |
| 649 | return "FFA_MEMORY_NORMAL_MEM"; |
| 650 | } |
| 651 | } |
| 652 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 653 | enum ffa_memory_cacheability { |
| 654 | FFA_MEMORY_CACHE_RESERVED = 0x0, |
| 655 | FFA_MEMORY_CACHE_NON_CACHEABLE = 0x1, |
| 656 | FFA_MEMORY_CACHE_RESERVED_1 = 0x2, |
| 657 | FFA_MEMORY_CACHE_WRITE_BACK = 0x3, |
| 658 | FFA_MEMORY_DEV_NGNRNE = 0x0, |
| 659 | FFA_MEMORY_DEV_NGNRE = 0x1, |
| 660 | FFA_MEMORY_DEV_NGRE = 0x2, |
| 661 | FFA_MEMORY_DEV_GRE = 0x3, |
| 662 | }; |
| 663 | |
Karl Meakin | f98b2aa | 2023-10-12 16:09:59 +0100 | [diff] [blame] | 664 | static inline const char *ffa_memory_cacheability_name( |
| 665 | enum ffa_memory_cacheability cacheability) |
| 666 | { |
| 667 | switch (cacheability) { |
| 668 | case FFA_MEMORY_CACHE_RESERVED: |
| 669 | return "FFA_MEMORY_CACHE_RESERVED"; |
| 670 | case FFA_MEMORY_CACHE_NON_CACHEABLE: |
| 671 | return "FFA_MEMORY_CACHE_NON_CACHEABLE"; |
| 672 | case FFA_MEMORY_CACHE_RESERVED_1: |
| 673 | return "FFA_MEMORY_CACHE_RESERVED_1"; |
| 674 | case FFA_MEMORY_CACHE_WRITE_BACK: |
| 675 | return "FFA_MEMORY_CACHE_WRITE_BACK"; |
| 676 | } |
| 677 | } |
| 678 | |
Daniel Boulby | 9764ff6 | 2024-01-30 17:47:39 +0000 | [diff] [blame] | 679 | static inline const char *ffa_device_memory_cacheability_name( |
| 680 | enum ffa_memory_cacheability cacheability) |
| 681 | { |
| 682 | switch (cacheability) { |
| 683 | case FFA_MEMORY_DEV_NGNRNE: |
| 684 | return "FFA_MEMORY_DEV_NGNRNE"; |
| 685 | case FFA_MEMORY_DEV_NGNRE: |
| 686 | return "FFA_MEMORY_DEV_NGNRE"; |
| 687 | case FFA_MEMORY_DEV_NGRE: |
| 688 | return "FFA_MEMORY_DEV_NGRE"; |
| 689 | case FFA_MEMORY_DEV_GRE: |
| 690 | return "FFA_MEMORY_DEV_GRE"; |
| 691 | } |
| 692 | } |
| 693 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 694 | enum ffa_memory_shareability { |
| 695 | FFA_MEMORY_SHARE_NON_SHAREABLE, |
| 696 | FFA_MEMORY_SHARE_RESERVED, |
| 697 | FFA_MEMORY_OUTER_SHAREABLE, |
| 698 | FFA_MEMORY_INNER_SHAREABLE, |
| 699 | }; |
| 700 | |
Karl Meakin | f98b2aa | 2023-10-12 16:09:59 +0100 | [diff] [blame] | 701 | static inline const char *ffa_memory_shareability_name( |
| 702 | enum ffa_memory_shareability shareability) |
| 703 | { |
| 704 | switch (shareability) { |
| 705 | case FFA_MEMORY_SHARE_NON_SHAREABLE: |
| 706 | return "FFA_MEMORY_SHARE_NON_SHAREABLE"; |
| 707 | case FFA_MEMORY_SHARE_RESERVED: |
| 708 | return "FFA_MEMORY_SHARE_RESERVED"; |
| 709 | case FFA_MEMORY_OUTER_SHAREABLE: |
| 710 | return "FFA_MEMORY_OUTER_SHAREABLE"; |
| 711 | case FFA_MEMORY_INNER_SHAREABLE: |
| 712 | return "FFA_MEMORY_INNER_SHAREABLE"; |
| 713 | } |
| 714 | } |
| 715 | |
Olivier Deprez | 4342a3c | 2022-02-28 09:37:25 +0100 | [diff] [blame] | 716 | /** |
| 717 | * FF-A v1.1 REL0 Table 10.18 memory region attributes descriptor NS Bit 6. |
| 718 | * Per section 10.10.4.1, NS bit is reserved for FFA_MEM_DONATE/LEND/SHARE |
| 719 | * and FFA_MEM_RETRIEVE_REQUEST. |
| 720 | */ |
| 721 | enum ffa_memory_security { |
| 722 | FFA_MEMORY_SECURITY_UNSPECIFIED = 0, |
| 723 | FFA_MEMORY_SECURITY_SECURE = 0, |
| 724 | FFA_MEMORY_SECURITY_NON_SECURE, |
| 725 | }; |
| 726 | |
Karl Meakin | f98b2aa | 2023-10-12 16:09:59 +0100 | [diff] [blame] | 727 | static inline const char *ffa_memory_security_name( |
| 728 | enum ffa_memory_security security) |
| 729 | { |
| 730 | switch (security) { |
| 731 | case FFA_MEMORY_SECURITY_UNSPECIFIED: |
| 732 | return "FFA_MEMORY_SECURITY_UNSPECIFIED"; |
| 733 | case FFA_MEMORY_SECURITY_NON_SECURE: |
| 734 | return "FFA_MEMORY_SECURITY_NON_SECURE"; |
| 735 | } |
| 736 | } |
| 737 | |
Karl Meakin | 84710f3 | 2023-10-12 15:14:49 +0100 | [diff] [blame] | 738 | typedef struct { |
| 739 | uint8_t data_access : 2; |
| 740 | uint8_t instruction_access : 2; |
| 741 | } ffa_memory_access_permissions_t; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 742 | |
| 743 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 744 | * 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] | 745 | * region attributes descriptor". |
| 746 | */ |
Karl Meakin | 84710f3 | 2023-10-12 15:14:49 +0100 | [diff] [blame] | 747 | typedef struct { |
| 748 | uint8_t shareability : 2; |
| 749 | uint8_t cacheability : 2; |
| 750 | uint8_t type : 2; |
| 751 | uint8_t security : 2; |
| 752 | uint8_t : 8; |
| 753 | } ffa_memory_attributes_t; |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 754 | |
| 755 | /* FF-A v1.1 EAC0 states bit [15:7] Must Be Zero. */ |
| 756 | #define FFA_MEMORY_ATTRIBUTES_MBZ_MASK 0xFF80U |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 757 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 758 | /** |
| 759 | * A globally-unique ID assigned by the hypervisor for a region of memory being |
| 760 | * sent between VMs. |
| 761 | */ |
| 762 | typedef uint64_t ffa_memory_handle_t; |
| 763 | |
Karl Meakin | 1a760e7 | 2024-07-25 18:58:37 +0100 | [diff] [blame] | 764 | enum ffa_memory_handle_allocator { |
| 765 | FFA_MEMORY_HANDLE_ALLOCATOR_SPMC = 0, |
| 766 | FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR = 1, |
| 767 | }; |
J-Alves | 917d2f2 | 2020-10-30 18:39:30 +0000 | [diff] [blame] | 768 | |
Karl Meakin | 1a760e7 | 2024-07-25 18:58:37 +0100 | [diff] [blame] | 769 | #define FFA_MEMORY_HANDLE_ALLOCATOR_BIT UINT64_C(63) |
| 770 | #define FFA_MEMORY_HANDLE_ALLOCATOR_MASK \ |
| 771 | (UINT64_C(1) << FFA_MEMORY_HANDLE_ALLOCATOR_BIT) |
J-Alves | 917d2f2 | 2020-10-30 18:39:30 +0000 | [diff] [blame] | 772 | #define FFA_MEMORY_HANDLE_INVALID (~UINT64_C(0)) |
| 773 | |
Karl Meakin | 1a760e7 | 2024-07-25 18:58:37 +0100 | [diff] [blame] | 774 | static inline ffa_memory_handle_t ffa_memory_handle_make( |
| 775 | uint64_t index, enum ffa_memory_handle_allocator allocator) |
| 776 | { |
| 777 | return index | ((uint64_t)allocator << FFA_MEMORY_HANDLE_ALLOCATOR_BIT); |
| 778 | } |
| 779 | |
| 780 | static inline uint64_t ffa_memory_handle_index(ffa_memory_handle_t handle) |
| 781 | { |
| 782 | return handle & ~FFA_MEMORY_HANDLE_ALLOCATOR_MASK; |
| 783 | } |
| 784 | |
| 785 | static inline enum ffa_memory_handle_allocator ffa_memory_handle_allocator( |
| 786 | ffa_memory_handle_t handle) |
| 787 | { |
| 788 | return ((handle & FFA_MEMORY_HANDLE_ALLOCATOR_MASK) != 0) |
| 789 | ? FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR |
| 790 | : FFA_MEMORY_HANDLE_ALLOCATOR_SPMC; |
| 791 | } |
| 792 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 793 | /** |
| 794 | * A count of VMs. This has the same range as the VM IDs but we give it a |
| 795 | * different name to make the different semantics clear. |
| 796 | */ |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 797 | typedef ffa_id_t ffa_vm_count_t; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 798 | |
| 799 | /** The index of a vCPU within a particular VM. */ |
| 800 | typedef uint16_t ffa_vcpu_index_t; |
| 801 | |
| 802 | /** |
| 803 | * A count of vCPUs. This has the same range as the vCPU indices but we give it |
| 804 | * a different name to make the different semantics clear. |
| 805 | */ |
| 806 | typedef ffa_vcpu_index_t ffa_vcpu_count_t; |
| 807 | |
| 808 | /** Parameter and return type of FF-A functions. */ |
| 809 | struct ffa_value { |
| 810 | uint64_t func; |
| 811 | uint64_t arg1; |
| 812 | uint64_t arg2; |
| 813 | uint64_t arg3; |
| 814 | uint64_t arg4; |
| 815 | uint64_t arg5; |
| 816 | uint64_t arg6; |
| 817 | uint64_t arg7; |
Raghu Krishnamurthy | 567068e | 2022-12-26 07:46:38 -0800 | [diff] [blame] | 818 | |
| 819 | struct { |
| 820 | uint64_t arg8; |
| 821 | uint64_t arg9; |
| 822 | uint64_t arg10; |
| 823 | uint64_t arg11; |
| 824 | uint64_t arg12; |
| 825 | uint64_t arg13; |
| 826 | uint64_t arg14; |
| 827 | uint64_t arg15; |
| 828 | uint64_t arg16; |
| 829 | uint64_t arg17; |
| 830 | bool valid; |
| 831 | } extended_val; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 832 | }; |
| 833 | |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 834 | static inline uint32_t ffa_func_id(struct ffa_value args) |
| 835 | { |
| 836 | return args.func; |
| 837 | } |
| 838 | |
Karl Meakin | dc759f5 | 2024-05-07 16:08:02 +0100 | [diff] [blame] | 839 | static inline enum ffa_error ffa_error_code(struct ffa_value val) |
J-Alves | 13318e3 | 2021-02-22 17:21:00 +0000 | [diff] [blame] | 840 | { |
Karl Meakin | 66a38bd | 2024-05-28 16:00:56 +0100 | [diff] [blame] | 841 | /* NOLINTNEXTLINE(EnumCastOutOfRange) */ |
Karl Meakin | dc759f5 | 2024-05-07 16:08:02 +0100 | [diff] [blame] | 842 | return (enum ffa_error)val.arg2; |
J-Alves | 13318e3 | 2021-02-22 17:21:00 +0000 | [diff] [blame] | 843 | } |
| 844 | |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 845 | static inline ffa_id_t ffa_sender(struct ffa_value args) |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 846 | { |
| 847 | return (args.arg1 >> 16) & 0xffff; |
| 848 | } |
| 849 | |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 850 | static inline ffa_id_t ffa_receiver(struct ffa_value args) |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 851 | { |
| 852 | return args.arg1 & 0xffff; |
| 853 | } |
| 854 | |
| 855 | static inline uint32_t ffa_msg_send_size(struct ffa_value args) |
| 856 | { |
| 857 | return args.arg3; |
| 858 | } |
| 859 | |
Federico Recanati | 25053ee | 2022-03-14 15:01:53 +0100 | [diff] [blame] | 860 | static inline uint32_t ffa_msg_send2_flags(struct ffa_value args) |
| 861 | { |
| 862 | return args.arg2; |
| 863 | } |
| 864 | |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 865 | static inline uint32_t ffa_partition_info_get_count(struct ffa_value args) |
| 866 | { |
| 867 | return args.arg2; |
| 868 | } |
| 869 | |
Raghu Krishnamurthy | 2957b92 | 2022-12-27 10:29:12 -0800 | [diff] [blame] | 870 | static inline uint16_t ffa_partition_info_regs_get_last_idx( |
| 871 | struct ffa_value args) |
| 872 | { |
| 873 | return args.arg2 & 0xFFFF; |
| 874 | } |
| 875 | |
| 876 | static inline uint16_t ffa_partition_info_regs_get_curr_idx( |
| 877 | struct ffa_value args) |
| 878 | { |
| 879 | return (args.arg2 >> 16) & 0xFFFF; |
| 880 | } |
| 881 | |
| 882 | static inline uint16_t ffa_partition_info_regs_get_tag(struct ffa_value args) |
| 883 | { |
| 884 | return (args.arg2 >> 32) & 0xFFFF; |
| 885 | } |
| 886 | |
| 887 | static inline uint16_t ffa_partition_info_regs_get_desc_size( |
| 888 | struct ffa_value args) |
| 889 | { |
| 890 | return (args.arg2 >> 48); |
| 891 | } |
| 892 | |
Andrew Walbran | 1bbe940 | 2020-04-30 16:47:13 +0100 | [diff] [blame] | 893 | static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t a1, uint32_t a2) |
| 894 | { |
| 895 | return (uint64_t)a1 | (uint64_t)a2 << 32; |
| 896 | } |
| 897 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 898 | static inline ffa_memory_handle_t ffa_mem_success_handle(struct ffa_value args) |
| 899 | { |
Andrew Walbran | 1bbe940 | 2020-04-30 16:47:13 +0100 | [diff] [blame] | 900 | return ffa_assemble_handle(args.arg2, args.arg3); |
| 901 | } |
| 902 | |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 903 | static inline ffa_memory_handle_t ffa_frag_handle(struct ffa_value args) |
| 904 | { |
| 905 | return ffa_assemble_handle(args.arg1, args.arg2); |
| 906 | } |
| 907 | |
Andrew Walbran | 1bbe940 | 2020-04-30 16:47:13 +0100 | [diff] [blame] | 908 | static inline struct ffa_value ffa_mem_success(ffa_memory_handle_t handle) |
| 909 | { |
| 910 | return (struct ffa_value){.func = FFA_SUCCESS_32, |
| 911 | .arg2 = (uint32_t)handle, |
| 912 | .arg3 = (uint32_t)(handle >> 32)}; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 913 | } |
| 914 | |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 915 | static inline ffa_id_t ffa_vm_id(struct ffa_value args) |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 916 | { |
| 917 | return (args.arg1 >> 16) & 0xffff; |
| 918 | } |
| 919 | |
| 920 | static inline ffa_vcpu_index_t ffa_vcpu_index(struct ffa_value args) |
| 921 | { |
| 922 | return args.arg1 & 0xffff; |
| 923 | } |
| 924 | |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 925 | 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] | 926 | { |
| 927 | return ((uint32_t)vm_id << 16) | vcpu_index; |
| 928 | } |
| 929 | |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 930 | static inline ffa_id_t ffa_frag_sender(struct ffa_value args) |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 931 | { |
| 932 | return (args.arg4 >> 16) & 0xffff; |
| 933 | } |
| 934 | |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 935 | static inline uint32_t ffa_feature_intid(struct ffa_value args) |
| 936 | { |
| 937 | return (uint32_t)args.arg2; |
| 938 | } |
| 939 | |
Karl Meakin | d0356f8 | 2024-09-04 13:34:31 +0100 | [diff] [blame] | 940 | #define FFA_FRAMEWORK_MSG_BIT (UINT64_C(1) << 31) |
| 941 | #define FFA_FRAMEWORK_MSG_FUNC_MASK UINT64_C(0xFF) |
| 942 | |
| 943 | /** |
Madhukar Pappireddy | 8afab73 | 2025-02-10 09:39:36 -0600 | [diff] [blame^] | 944 | * Identifies FF-A framework messages. See sections 18.2 and 18.3 of v1.2 FF-A |
Karl Meakin | d0356f8 | 2024-09-04 13:34:31 +0100 | [diff] [blame] | 945 | * specification. |
| 946 | */ |
| 947 | enum ffa_framework_msg_func { |
Madhukar Pappireddy | 8afab73 | 2025-02-10 09:39:36 -0600 | [diff] [blame^] | 948 | /* Power management framework messages. */ |
| 949 | FFA_FRAMEWORK_MSG_PSCI_REQ = 0, |
| 950 | FFA_FRAMEWORK_MSG_PSCI_RESP = 2, |
| 951 | |
| 952 | /* The VM availability messages. */ |
Karl Meakin | d0356f8 | 2024-09-04 13:34:31 +0100 | [diff] [blame] | 953 | FFA_FRAMEWORK_MSG_VM_CREATION_REQ = 4, |
| 954 | FFA_FRAMEWORK_MSG_VM_CREATION_RESP = 5, |
Karl Meakin | d0356f8 | 2024-09-04 13:34:31 +0100 | [diff] [blame] | 955 | FFA_FRAMEWORK_MSG_VM_DESTRUCTION_REQ = 6, |
| 956 | FFA_FRAMEWORK_MSG_VM_DESTRUCTION_RESP = 7, |
Madhukar Pappireddy | 8afab73 | 2025-02-10 09:39:36 -0600 | [diff] [blame^] | 957 | |
| 958 | SPMD_FRAMEWORK_MSG_FFA_VERSION_REQ = 8, |
| 959 | SPMD_FRAMEWORK_MSG_FFA_VERSION_RESP = 9, |
| 960 | |
| 961 | FFA_FRAMEWORK_MSG_INVALID = 0xFF, |
Karl Meakin | d0356f8 | 2024-09-04 13:34:31 +0100 | [diff] [blame] | 962 | }; |
| 963 | |
Karl Meakin | 06e8b73 | 2024-09-20 18:26:49 +0100 | [diff] [blame] | 964 | #define FFA_VM_AVAILABILITY_MESSAGE_SBZ_LO 16 |
| 965 | #define FFA_VM_AVAILABILITY_MESSAGE_SBZ_HI 31 |
| 966 | |
Karl Meakin | d0356f8 | 2024-09-04 13:34:31 +0100 | [diff] [blame] | 967 | /** Get the `flags` field of a framework message */ |
| 968 | static inline uint32_t ffa_framework_msg_flags(struct ffa_value args) |
Daniel Boulby | efa381f | 2022-01-18 14:49:40 +0000 | [diff] [blame] | 969 | { |
| 970 | return (uint32_t)args.arg2; |
| 971 | } |
| 972 | |
Karl Meakin | d0356f8 | 2024-09-04 13:34:31 +0100 | [diff] [blame] | 973 | /** Is `args` a framework message? */ |
| 974 | static inline bool ffa_is_framework_msg(struct ffa_value args) |
| 975 | { |
Karl Meakin | 06e8b73 | 2024-09-20 18:26:49 +0100 | [diff] [blame] | 976 | return (args.func != FFA_MSG_SEND_DIRECT_REQ2_64) && |
| 977 | (args.func != FFA_MSG_SEND_DIRECT_RESP2_64) && |
| 978 | ((ffa_framework_msg_flags(args) & FFA_FRAMEWORK_MSG_BIT) != 0); |
Karl Meakin | d0356f8 | 2024-09-04 13:34:31 +0100 | [diff] [blame] | 979 | } |
| 980 | |
Karl Meakin | a1a0235 | 2024-09-20 18:27:18 +0100 | [diff] [blame] | 981 | /** |
| 982 | * Get the ID of the VM that has been created/destroyed from VM availability |
| 983 | * message |
| 984 | */ |
| 985 | static inline ffa_id_t ffa_vm_availability_message_vm_id(struct ffa_value args) |
| 986 | { |
| 987 | return args.arg5 & 0xFFFF; |
| 988 | } |
| 989 | |
Karl Meakin | d0356f8 | 2024-09-04 13:34:31 +0100 | [diff] [blame] | 990 | /** Get the function ID from a framework message */ |
| 991 | static inline uint32_t ffa_framework_msg_func(struct ffa_value args) |
| 992 | { |
| 993 | return ffa_framework_msg_flags(args) & FFA_FRAMEWORK_MSG_FUNC_MASK; |
| 994 | } |
| 995 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 996 | /** |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 997 | * Flags to determine the partition properties, as required by |
| 998 | * FFA_PARTITION_INFO_GET. |
| 999 | * |
Kathleen Capella | f71dee4 | 2023-08-08 16:24:14 -0400 | [diff] [blame] | 1000 | * 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] | 1001 | * specification, "Partition information descriptor, partition properties". |
| 1002 | */ |
| 1003 | typedef uint32_t ffa_partition_properties_t; |
| 1004 | |
Kathleen Capella | f71dee4 | 2023-08-08 16:24:14 -0400 | [diff] [blame] | 1005 | /** |
| 1006 | * Partition property: partition supports receipt of direct requests via the |
| 1007 | * FFA_MSG_SEND_DIRECT_REQ ABI. |
| 1008 | */ |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 1009 | #define FFA_PARTITION_DIRECT_REQ_RECV (UINT32_C(1) << 0) |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 1010 | |
Kathleen Capella | f71dee4 | 2023-08-08 16:24:14 -0400 | [diff] [blame] | 1011 | /** |
| 1012 | * Partition property: partition can send direct requests via the |
| 1013 | * FFA_MSG_SEND_DIRECT_REQ ABI. |
| 1014 | */ |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 1015 | #define FFA_PARTITION_DIRECT_REQ_SEND (UINT32_C(1) << 1) |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 1016 | |
| 1017 | /** Partition property: partition can send and receive indirect messages. */ |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 1018 | #define FFA_PARTITION_INDIRECT_MSG (UINT32_C(1) << 2) |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 1019 | |
J-Alves | 09ff9d8 | 2021-11-02 11:55:20 +0000 | [diff] [blame] | 1020 | /** Partition property: partition can receive notifications. */ |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 1021 | #define FFA_PARTITION_NOTIFICATION (UINT32_C(1) << 3) |
| 1022 | |
Karl Meakin | a603e08 | 2024-08-02 17:57:27 +0100 | [diff] [blame] | 1023 | /** |
| 1024 | * Partition property: partition must be informed about each VM that is created |
| 1025 | * by the Hypervisor. |
| 1026 | */ |
| 1027 | #define FFA_PARTITION_VM_CREATED (UINT32_C(1) << 6) |
| 1028 | |
| 1029 | /** |
| 1030 | * Partition property: partition must be informed about each VM that is |
| 1031 | * destroyed by the Hypervisor. |
| 1032 | */ |
| 1033 | #define FFA_PARTITION_VM_DESTROYED (UINT32_C(1) << 7) |
| 1034 | |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 1035 | /** Partition property: partition runs in the AArch64 execution state. */ |
| 1036 | #define FFA_PARTITION_AARCH64_EXEC (UINT32_C(1) << 8) |
J-Alves | 09ff9d8 | 2021-11-02 11:55:20 +0000 | [diff] [blame] | 1037 | |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 1038 | /** |
Kathleen Capella | f71dee4 | 2023-08-08 16:24:14 -0400 | [diff] [blame] | 1039 | * Partition property: partition supports receipt of direct requests via the |
| 1040 | * FFA_MSG_SEND_DIRECT_REQ2 ABI. |
| 1041 | */ |
| 1042 | #define FFA_PARTITION_DIRECT_REQ2_RECV (UINT32_C(1) << 9) |
| 1043 | |
| 1044 | /** |
| 1045 | * Partition property: partition can send direct requests via the |
| 1046 | * FFA_MSG_SEND_DIRECT_REQ2 ABI. |
| 1047 | */ |
| 1048 | #define FFA_PARTITION_DIRECT_REQ2_SEND (UINT32_C(1) << 10) |
| 1049 | |
| 1050 | /** |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 1051 | * Holds information returned for each partition by the FFA_PARTITION_INFO_GET |
| 1052 | * interface. |
Kathleen Capella | 402fa85 | 2022-11-09 16:16:51 -0500 | [diff] [blame] | 1053 | * This corresponds to table 13.37 "Partition information descriptor" |
| 1054 | * in FF-A 1.1 EAC0 specification. |
Daniel Boulby | 1ddb3d7 | 2021-12-16 18:16:50 +0000 | [diff] [blame] | 1055 | */ |
| 1056 | struct ffa_partition_info { |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1057 | ffa_id_t vm_id; |
Daniel Boulby | 1ddb3d7 | 2021-12-16 18:16:50 +0000 | [diff] [blame] | 1058 | ffa_vcpu_count_t vcpu_count; |
| 1059 | ffa_partition_properties_t properties; |
| 1060 | struct ffa_uuid uuid; |
| 1061 | }; |
| 1062 | |
J-Alves | dd1ad57 | 2022-01-25 17:58:26 +0000 | [diff] [blame] | 1063 | /** Length in bytes of the name in boot information descriptor. */ |
| 1064 | #define FFA_BOOT_INFO_NAME_LEN 16 |
| 1065 | |
J-Alves | 240d84c | 2022-04-22 12:19:34 +0100 | [diff] [blame] | 1066 | /** |
| 1067 | * The FF-A boot info descriptor, as defined in table 5.8 of section 5.4.1, of |
| 1068 | * the FF-A v1.1 EAC0 specification. |
| 1069 | */ |
J-Alves | dd1ad57 | 2022-01-25 17:58:26 +0000 | [diff] [blame] | 1070 | struct ffa_boot_info_desc { |
| 1071 | char name[FFA_BOOT_INFO_NAME_LEN]; |
| 1072 | uint8_t type; |
| 1073 | uint8_t reserved; |
| 1074 | uint16_t flags; |
| 1075 | uint32_t size; |
| 1076 | uint64_t content; |
| 1077 | }; |
| 1078 | |
| 1079 | /** FF-A boot information type mask. */ |
| 1080 | #define FFA_BOOT_INFO_TYPE_SHIFT 7 |
| 1081 | #define FFA_BOOT_INFO_TYPE_MASK (0x1U << FFA_BOOT_INFO_TYPE_SHIFT) |
| 1082 | #define FFA_BOOT_INFO_TYPE_STD 0U |
| 1083 | #define FFA_BOOT_INFO_TYPE_IMPDEF 1U |
| 1084 | |
| 1085 | /** Standard boot info type IDs. */ |
| 1086 | #define FFA_BOOT_INFO_TYPE_ID_MASK 0x7FU |
| 1087 | #define FFA_BOOT_INFO_TYPE_ID_FDT 0U |
| 1088 | #define FFA_BOOT_INFO_TYPE_ID_HOB 1U |
| 1089 | |
| 1090 | /** FF-A Boot Info descriptors flags. */ |
| 1091 | #define FFA_BOOT_INFO_FLAG_MBZ_MASK 0xFFF0U |
| 1092 | |
| 1093 | /** Bits [1:0] encode the format of the name field in ffa_boot_info_desc. */ |
| 1094 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT 0U |
| 1095 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK \ |
| 1096 | (0x3U << FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT) |
| 1097 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_STRING 0x0U |
| 1098 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_UUID 0x1U |
| 1099 | |
| 1100 | /** Bits [3:2] encode the format of the content field in ffa_boot_info_desc. */ |
| 1101 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT 2 |
| 1102 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK \ |
| 1103 | (0x3U << FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT) |
| 1104 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_VALUE 0x1U |
| 1105 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_ADDR 0x0U |
| 1106 | |
| 1107 | static inline uint16_t ffa_boot_info_content_format( |
| 1108 | struct ffa_boot_info_desc *desc) |
| 1109 | { |
| 1110 | return (desc->flags & FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK) >> |
| 1111 | FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT; |
| 1112 | } |
| 1113 | |
| 1114 | static inline uint16_t ffa_boot_info_name_format( |
| 1115 | struct ffa_boot_info_desc *desc) |
| 1116 | { |
| 1117 | return (desc->flags & FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK) >> |
| 1118 | FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT; |
| 1119 | } |
| 1120 | |
| 1121 | static inline uint8_t ffa_boot_info_type_id(struct ffa_boot_info_desc *desc) |
| 1122 | { |
| 1123 | return desc->type & FFA_BOOT_INFO_TYPE_ID_MASK; |
| 1124 | } |
| 1125 | |
| 1126 | static inline uint8_t ffa_boot_info_type(struct ffa_boot_info_desc *desc) |
| 1127 | { |
| 1128 | return (desc->type & FFA_BOOT_INFO_TYPE_MASK) >> |
| 1129 | FFA_BOOT_INFO_TYPE_SHIFT; |
| 1130 | } |
| 1131 | |
| 1132 | /** Length in bytes of the signature in the boot descriptor. */ |
| 1133 | #define FFA_BOOT_INFO_HEADER_SIGNATURE_LEN 4 |
| 1134 | |
J-Alves | 240d84c | 2022-04-22 12:19:34 +0100 | [diff] [blame] | 1135 | /** |
| 1136 | * The FF-A boot information header, as defined in table 5.9 of section 5.4.2, |
| 1137 | * of the FF-A v1.1 EAC0 specification. |
| 1138 | */ |
J-Alves | dd1ad57 | 2022-01-25 17:58:26 +0000 | [diff] [blame] | 1139 | struct ffa_boot_info_header { |
| 1140 | uint32_t signature; |
| 1141 | uint32_t version; |
| 1142 | uint32_t info_blob_size; |
| 1143 | uint32_t desc_size; |
| 1144 | uint32_t desc_count; |
| 1145 | uint32_t desc_offset; |
| 1146 | uint64_t reserved; |
| 1147 | struct ffa_boot_info_desc boot_info[]; |
| 1148 | }; |
| 1149 | |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 1150 | /** |
J-Alves | 980d199 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 1151 | * FF-A v1.1 specification restricts the number of notifications to a maximum |
| 1152 | * of 64. Following all possible bitmaps. |
| 1153 | */ |
Karl Meakin | 2ad6b66 | 2024-07-29 20:45:40 +0100 | [diff] [blame] | 1154 | #define FFA_NOTIFICATION_MASK(ID) (UINT64_C(1) << (ID)) |
J-Alves | 980d199 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 1155 | |
| 1156 | typedef uint64_t ffa_notifications_bitmap_t; |
| 1157 | |
| 1158 | #define MAX_FFA_NOTIFICATIONS 64U |
| 1159 | |
| 1160 | /** |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 1161 | * Flag for notification bind and set, to specify call is about per-vCPU |
| 1162 | * notifications. |
| 1163 | */ |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 1164 | #define FFA_NOTIFICATION_FLAG_PER_VCPU (UINT32_C(1) << 0) |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 1165 | |
Federico Recanati | e73d283 | 2022-04-20 11:10:52 +0200 | [diff] [blame] | 1166 | #define FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK FFA_NOTIFICATION_MASK(0) |
| 1167 | #define FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK FFA_NOTIFICATION_MASK(32) |
| 1168 | |
| 1169 | /** |
| 1170 | * Helper functions to check for buffer full notification. |
| 1171 | */ |
| 1172 | static inline bool is_ffa_hyp_buffer_full_notification( |
| 1173 | ffa_notifications_bitmap_t framework) |
| 1174 | { |
| 1175 | return (framework & FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK) != 0; |
| 1176 | } |
| 1177 | |
| 1178 | static inline bool is_ffa_spm_buffer_full_notification( |
| 1179 | ffa_notifications_bitmap_t framework) |
| 1180 | { |
| 1181 | return (framework & FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK) != 0; |
| 1182 | } |
| 1183 | |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 1184 | /** |
J-Alves | 980d199 | 2021-03-18 12:49:18 +0000 | [diff] [blame] | 1185 | * Helper function to assemble a 64-bit sized bitmap, from the 32-bit sized lo |
| 1186 | * and hi. |
| 1187 | * Helpful as FF-A specification defines that the notifications interfaces |
| 1188 | * arguments are 32-bit registers. |
| 1189 | */ |
| 1190 | static inline ffa_notifications_bitmap_t ffa_notifications_bitmap(uint32_t lo, |
| 1191 | uint32_t hi) |
| 1192 | { |
| 1193 | return (ffa_notifications_bitmap_t)hi << 32U | lo; |
| 1194 | } |
| 1195 | |
J-Alves | 98ff956 | 2021-09-09 14:39:41 +0100 | [diff] [blame] | 1196 | static inline ffa_notifications_bitmap_t ffa_notification_get_from_sp( |
| 1197 | struct ffa_value val) |
| 1198 | { |
| 1199 | return ffa_notifications_bitmap((uint32_t)val.arg2, (uint32_t)val.arg3); |
| 1200 | } |
| 1201 | |
| 1202 | static inline ffa_notifications_bitmap_t ffa_notification_get_from_vm( |
| 1203 | struct ffa_value val) |
| 1204 | { |
| 1205 | return ffa_notifications_bitmap((uint32_t)val.arg4, (uint32_t)val.arg5); |
| 1206 | } |
| 1207 | |
Federico Recanati | e73d283 | 2022-04-20 11:10:52 +0200 | [diff] [blame] | 1208 | static inline ffa_notifications_bitmap_t ffa_notification_get_from_framework( |
| 1209 | struct ffa_value val) |
| 1210 | { |
| 1211 | return ffa_notifications_bitmap((uint32_t)val.arg6, (uint32_t)val.arg7); |
| 1212 | } |
| 1213 | |
Karl Meakin | f9c73ce | 2024-07-30 17:37:13 +0100 | [diff] [blame] | 1214 | typedef uint32_t ffa_notification_flags_t; |
| 1215 | |
| 1216 | /** Flags used in calls to FFA_NOTIFICATION_BIND interface. */ |
| 1217 | #define FFA_NOTIFICATIONS_FLAG_PER_VCPU (UINT32_C(1) << 0) |
| 1218 | |
| 1219 | /** Flags used in calls to FFA_NOTIFICATION_GET interface. */ |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 1220 | #define FFA_NOTIFICATION_FLAG_BITMAP_SP (UINT32_C(1) << 0) |
| 1221 | #define FFA_NOTIFICATION_FLAG_BITMAP_VM (UINT32_C(1) << 1) |
| 1222 | #define FFA_NOTIFICATION_FLAG_BITMAP_SPM (UINT32_C(1) << 2) |
| 1223 | #define FFA_NOTIFICATION_FLAG_BITMAP_HYP (UINT32_C(1) << 3) |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 1224 | |
Karl Meakin | f9c73ce | 2024-07-30 17:37:13 +0100 | [diff] [blame] | 1225 | /** Flags used in calls to FFA_NOTIFICATION_SET interface. */ |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 1226 | #define FFA_NOTIFICATIONS_FLAG_PER_VCPU (UINT32_C(1) << 0) |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 1227 | #define FFA_NOTIFICATIONS_FLAG_DELAY_SRI (UINT32_C(1) << 1) |
Olivier Deprez | b76307d | 2022-06-09 17:17:45 +0200 | [diff] [blame] | 1228 | #define FFA_NOTIFICATIONS_FLAGS_VCPU_ID(id) \ |
| 1229 | ((((uint32_t)(id)) & UINT32_C(0xffff)) << 16) |
Karl Meakin | f9c73ce | 2024-07-30 17:37:13 +0100 | [diff] [blame] | 1230 | #define FFA_NOTIFICATIONS_FLAGS_GET_VCPU_ID(flags) \ |
| 1231 | ((ffa_vcpu_index_t)((flags) >> 16)) |
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 1232 | |
J-Alves | be6e303 | 2021-11-30 14:54:12 +0000 | [diff] [blame] | 1233 | 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] | 1234 | { |
Karl Meakin | f9c73ce | 2024-07-30 17:37:13 +0100 | [diff] [blame] | 1235 | return FFA_NOTIFICATIONS_FLAGS_GET_VCPU_ID(args.arg1); |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 1236 | } |
| 1237 | |
| 1238 | /** |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 1239 | * The max number of IDs for return of FFA_NOTIFICATION_INFO_GET. |
| 1240 | */ |
| 1241 | #define FFA_NOTIFICATIONS_INFO_GET_MAX_IDS 20U |
| 1242 | |
| 1243 | /** |
| 1244 | * Number of registers to use in successfull return of interface |
| 1245 | * FFA_NOTIFICATION_INFO_GET. |
| 1246 | */ |
| 1247 | #define FFA_NOTIFICATIONS_INFO_GET_REGS_RET 5U |
| 1248 | |
| 1249 | #define FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING 0x1U |
| 1250 | |
| 1251 | /** |
| 1252 | * Helper macros for return parameter encoding as described in section 17.7.1 |
| 1253 | * of the FF-A v1.1 Beta0 specification. |
| 1254 | */ |
| 1255 | #define FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT 0x7U |
| 1256 | #define FFA_NOTIFICATIONS_LISTS_COUNT_MASK 0x1fU |
Karl Meakin | 2ad6b66 | 2024-07-29 20:45:40 +0100 | [diff] [blame] | 1257 | #define FFA_NOTIFICATIONS_LIST_SHIFT(l) (2 * ((l) - 1) + 12) |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 1258 | #define FFA_NOTIFICATIONS_LIST_SIZE_MASK 0x3U |
Daniel Boulby | 1308a63 | 2024-09-11 15:19:16 +0100 | [diff] [blame] | 1259 | #define FFA_NOTIFICATIONS_LIST_MAX_SIZE 0x4U |
Daniel Boulby | edfdf28 | 2025-01-02 18:51:19 +0000 | [diff] [blame] | 1260 | #define FFA_NOTIFICATIONS_LIST_MAX_VCPU_IDS \ |
| 1261 | (FFA_NOTIFICATIONS_LIST_MAX_SIZE - 1) |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 1262 | |
| 1263 | static inline uint32_t ffa_notification_info_get_lists_count( |
| 1264 | struct ffa_value args) |
| 1265 | { |
| 1266 | return (uint32_t)(args.arg2 >> FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT) & |
| 1267 | FFA_NOTIFICATIONS_LISTS_COUNT_MASK; |
| 1268 | } |
| 1269 | |
| 1270 | static inline uint32_t ffa_notification_info_get_list_size( |
| 1271 | struct ffa_value args, unsigned int list_idx) |
| 1272 | { |
| 1273 | return ((uint32_t)args.arg2 >> FFA_NOTIFICATIONS_LIST_SHIFT(list_idx)) & |
| 1274 | FFA_NOTIFICATIONS_LIST_SIZE_MASK; |
| 1275 | } |
| 1276 | |
| 1277 | static inline bool ffa_notification_info_get_more_pending(struct ffa_value args) |
| 1278 | { |
| 1279 | return (args.arg2 & FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING) != 0U; |
| 1280 | } |
| 1281 | |
Daniel Boulby | 1308a63 | 2024-09-11 15:19:16 +0100 | [diff] [blame] | 1282 | void ffa_notification_info_get_and_check( |
| 1283 | const uint32_t expected_lists_count, |
| 1284 | const uint32_t *const expected_lists_sizes, |
| 1285 | const uint16_t *const expected_ids); |
| 1286 | |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 1287 | /** |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1288 | * 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] | 1289 | * to table 10.14 of the FF-A v1.1 EAC0 specification, "Constituent memory |
| 1290 | * region descriptor". |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1291 | */ |
| 1292 | struct ffa_memory_region_constituent { |
| 1293 | /** |
| 1294 | * The base IPA of the constituent memory region, aligned to 4 kiB page |
| 1295 | * size granularity. |
| 1296 | */ |
| 1297 | uint64_t address; |
| 1298 | /** The number of 4 kiB pages in the constituent memory region. */ |
| 1299 | uint32_t page_count; |
| 1300 | /** Reserved field, must be 0. */ |
| 1301 | uint32_t reserved; |
| 1302 | }; |
| 1303 | |
| 1304 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 1305 | * A set of pages comprising a memory region. This corresponds to table 10.13 of |
| 1306 | * the FF-A v1.1 EAC0 specification, "Composite memory region descriptor". |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1307 | */ |
| 1308 | struct ffa_composite_memory_region { |
| 1309 | /** |
| 1310 | * The total number of 4 kiB pages included in this memory region. This |
| 1311 | * must be equal to the sum of page counts specified in each |
| 1312 | * `ffa_memory_region_constituent`. |
| 1313 | */ |
| 1314 | uint32_t page_count; |
| 1315 | /** |
| 1316 | * The number of constituents (`ffa_memory_region_constituent`) |
| 1317 | * included in this memory region range. |
| 1318 | */ |
| 1319 | uint32_t constituent_count; |
| 1320 | /** Reserved field, must be 0. */ |
| 1321 | uint64_t reserved_0; |
| 1322 | /** An array of `constituent_count` memory region constituents. */ |
| 1323 | struct ffa_memory_region_constituent constituents[]; |
| 1324 | }; |
| 1325 | |
| 1326 | /** Flags to indicate properties of receivers during memory region retrieval. */ |
| 1327 | typedef uint8_t ffa_memory_receiver_flags_t; |
| 1328 | |
| 1329 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 1330 | * 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] | 1331 | * access permissions descriptor". |
| 1332 | */ |
| 1333 | struct ffa_memory_region_attributes { |
| 1334 | /** 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] | 1335 | ffa_id_t receiver; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1336 | /** |
| 1337 | * The permissions with which the memory region should be mapped in the |
| 1338 | * receiver's page table. |
| 1339 | */ |
| 1340 | ffa_memory_access_permissions_t permissions; |
| 1341 | /** |
| 1342 | * Flags used during FFA_MEM_RETRIEVE_REQ and FFA_MEM_RETRIEVE_RESP |
| 1343 | * for memory regions with multiple borrowers. |
| 1344 | */ |
| 1345 | ffa_memory_receiver_flags_t flags; |
| 1346 | }; |
| 1347 | |
| 1348 | /** Flags to control the behaviour of a memory sharing transaction. */ |
| 1349 | typedef uint32_t ffa_memory_region_flags_t; |
| 1350 | |
| 1351 | /** |
| 1352 | * Clear memory region contents after unmapping it from the sender and before |
| 1353 | * mapping it for any receiver. |
| 1354 | */ |
| 1355 | #define FFA_MEMORY_REGION_FLAG_CLEAR 0x1 |
| 1356 | |
| 1357 | /** |
| 1358 | * Whether the hypervisor may time slice the memory sharing or retrieval |
| 1359 | * operation. |
| 1360 | */ |
| 1361 | #define FFA_MEMORY_REGION_FLAG_TIME_SLICE 0x2 |
| 1362 | |
| 1363 | /** |
| 1364 | * Whether the hypervisor should clear the memory region after the receiver |
| 1365 | * relinquishes it or is aborted. |
| 1366 | */ |
| 1367 | #define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH 0x4 |
| 1368 | |
J-Alves | 3456e03 | 2023-07-20 12:20:05 +0100 | [diff] [blame] | 1369 | /** |
| 1370 | * On retrieve request, bypass the multi-borrower check. |
| 1371 | */ |
| 1372 | #define FFA_MEMORY_REGION_FLAG_BYPASS_BORROWERS_CHECK (0x1U << 10) |
| 1373 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1374 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_MASK ((0x3U) << 3) |
| 1375 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_UNSPECIFIED ((0x0U) << 3) |
| 1376 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE ((0x1U) << 3) |
| 1377 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_LEND ((0x2U) << 3) |
| 1378 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_DONATE ((0x3U) << 3) |
| 1379 | |
Federico Recanati | 85090c4 | 2021-12-15 13:17:54 +0100 | [diff] [blame] | 1380 | #define FFA_MEMORY_REGION_ADDRESS_RANGE_HINT_VALID ((0x1U) << 9) |
| 1381 | #define FFA_MEMORY_REGION_ADDRESS_RANGE_HINT_MASK ((0xFU) << 5) |
| 1382 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1383 | /** |
Daniel Boulby | de974ca | 2023-12-12 13:53:31 +0000 | [diff] [blame] | 1384 | * Struct to store the impdef value seen in Table 11.16 of the |
| 1385 | * FF-A v1.2 ALP0 specification "Endpoint memory access descriptor". |
| 1386 | */ |
| 1387 | struct ffa_memory_access_impdef { |
| 1388 | uint64_t val[2]; |
| 1389 | }; |
| 1390 | |
Daniel Boulby | e0ca9a0 | 2024-03-05 18:40:59 +0000 | [diff] [blame] | 1391 | static inline struct ffa_memory_access_impdef ffa_memory_access_impdef_init( |
| 1392 | uint64_t impdef_hi, uint64_t impdef_lo) |
| 1393 | { |
| 1394 | return (struct ffa_memory_access_impdef){{impdef_hi, impdef_lo}}; |
| 1395 | } |
| 1396 | |
Daniel Boulby | de974ca | 2023-12-12 13:53:31 +0000 | [diff] [blame] | 1397 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 1398 | * This corresponds to table 10.16 of the FF-A v1.1 EAC0 specification, |
| 1399 | * "Endpoint memory access descriptor". |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1400 | */ |
| 1401 | struct ffa_memory_access { |
| 1402 | struct ffa_memory_region_attributes receiver_permissions; |
| 1403 | /** |
| 1404 | * Offset in bytes from the start of the outer `ffa_memory_region` to |
| 1405 | * an `ffa_composite_memory_region` struct. |
| 1406 | */ |
| 1407 | uint32_t composite_memory_region_offset; |
Daniel Boulby | de974ca | 2023-12-12 13:53:31 +0000 | [diff] [blame] | 1408 | struct ffa_memory_access_impdef impdef; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1409 | uint64_t reserved_0; |
| 1410 | }; |
| 1411 | |
J-Alves | 363f572 | 2022-04-25 17:37:37 +0100 | [diff] [blame] | 1412 | /** The maximum number of recipients a memory region may be sent to. */ |
J-Alves | ba0e617 | 2022-04-25 17:41:40 +0100 | [diff] [blame] | 1413 | #define MAX_MEM_SHARE_RECIPIENTS UINT32_C(2) |
J-Alves | 363f572 | 2022-04-25 17:37:37 +0100 | [diff] [blame] | 1414 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1415 | /** |
| 1416 | * 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] | 1417 | * table 10.20 of the FF-A v1.1 EAC0 specification, "Lend, donate or share |
| 1418 | * memory transaction descriptor". Note that it is also used for retrieve |
| 1419 | * requests and responses. |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1420 | */ |
| 1421 | struct ffa_memory_region { |
| 1422 | /** |
| 1423 | * The ID of the VM which originally sent the memory region, i.e. the |
| 1424 | * owner. |
| 1425 | */ |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1426 | ffa_id_t sender; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1427 | ffa_memory_attributes_t attributes; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1428 | /** Flags to control behaviour of the transaction. */ |
| 1429 | ffa_memory_region_flags_t flags; |
| 1430 | ffa_memory_handle_t handle; |
| 1431 | /** |
| 1432 | * An implementation defined value associated with the receiver and the |
| 1433 | * memory region. |
| 1434 | */ |
| 1435 | uint64_t tag; |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 1436 | /* Size of the memory access descriptor. */ |
| 1437 | uint32_t memory_access_desc_size; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1438 | /** |
| 1439 | * The number of `ffa_memory_access` entries included in this |
| 1440 | * transaction. |
| 1441 | */ |
| 1442 | uint32_t receiver_count; |
| 1443 | /** |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 1444 | * Offset of the 'receivers' field, which relates to the memory access |
| 1445 | * descriptors. |
| 1446 | */ |
| 1447 | uint32_t receivers_offset; |
| 1448 | /** Reserved field (12 bytes) must be 0. */ |
| 1449 | uint32_t reserved[3]; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1450 | }; |
| 1451 | |
| 1452 | /** |
| 1453 | * Descriptor used for FFA_MEM_RELINQUISH requests. This corresponds to table |
J-Alves | 0b6653d | 2022-04-22 13:17:38 +0100 | [diff] [blame] | 1454 | * 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] | 1455 | * region". |
| 1456 | */ |
| 1457 | struct ffa_mem_relinquish { |
| 1458 | ffa_memory_handle_t handle; |
| 1459 | ffa_memory_region_flags_t flags; |
| 1460 | uint32_t endpoint_count; |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1461 | ffa_id_t endpoints[]; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1462 | }; |
| 1463 | |
| 1464 | /** |
Daniel Boulby | 59ffee9 | 2023-11-02 18:26:26 +0000 | [diff] [blame] | 1465 | * Returns the first FF-A version that matches the memory access descriptor |
| 1466 | * size. |
Daniel Boulby | de974ca | 2023-12-12 13:53:31 +0000 | [diff] [blame] | 1467 | */ |
Karl Meakin | 0e617d9 | 2024-04-05 12:55:22 +0100 | [diff] [blame] | 1468 | enum ffa_version ffa_version_from_memory_access_desc_size( |
Daniel Boulby | c7dc932 | 2023-10-27 15:12:07 +0100 | [diff] [blame] | 1469 | uint32_t memory_access_desc_size); |
| 1470 | |
| 1471 | /** |
Daniel Boulby | d5ae44b | 2023-12-12 12:18:11 +0000 | [diff] [blame] | 1472 | * To maintain forwards compatability we can't make assumptions about the size |
| 1473 | * of the endpoint memory access descriptor so provide a helper function |
| 1474 | * to get a receiver from the receiver array using the memory access descriptor |
| 1475 | * size field from the memory region descriptor struct. |
| 1476 | * Returns NULL if we cannot return the receiver. |
| 1477 | */ |
| 1478 | static inline struct ffa_memory_access *ffa_memory_region_get_receiver( |
| 1479 | struct ffa_memory_region *memory_region, uint32_t receiver_index) |
| 1480 | { |
| 1481 | uint32_t memory_access_desc_size = |
| 1482 | memory_region->memory_access_desc_size; |
| 1483 | |
| 1484 | if (receiver_index >= memory_region->receiver_count) { |
| 1485 | return NULL; |
| 1486 | } |
| 1487 | |
| 1488 | /* |
| 1489 | * Memory access descriptor size cannot be greater than the size of |
| 1490 | * the memory access descriptor defined by the current FF-A version. |
| 1491 | */ |
| 1492 | if (memory_access_desc_size > sizeof(struct ffa_memory_access)) { |
| 1493 | return NULL; |
| 1494 | } |
| 1495 | |
Daniel Boulby | 41ef8ba | 2023-10-13 17:01:22 +0100 | [diff] [blame] | 1496 | /* Check we cannot use receivers offset to cause overflow. */ |
| 1497 | if (memory_region->receivers_offset != |
| 1498 | sizeof(struct ffa_memory_region)) { |
| 1499 | return NULL; |
| 1500 | } |
| 1501 | |
Karl Meakin | 2ad6b66 | 2024-07-29 20:45:40 +0100 | [diff] [blame] | 1502 | return (struct ffa_memory_access |
| 1503 | *)((uint8_t *)memory_region + |
| 1504 | (size_t)memory_region->receivers_offset + |
| 1505 | (size_t)(receiver_index * memory_access_desc_size)); |
Daniel Boulby | d5ae44b | 2023-12-12 12:18:11 +0000 | [diff] [blame] | 1506 | } |
| 1507 | |
| 1508 | /** |
Daniel Boulby | 59ffee9 | 2023-11-02 18:26:26 +0000 | [diff] [blame] | 1509 | * Gets the receiver's access permissions from 'struct ffa_memory_region' and |
| 1510 | * returns its index in the receiver's array. If receiver's ID doesn't exist |
| 1511 | * in the array, return the region's 'receivers_count'. |
| 1512 | */ |
| 1513 | static inline uint32_t ffa_memory_region_get_receiver_index( |
| 1514 | struct ffa_memory_region *memory_region, ffa_id_t receiver_id) |
| 1515 | { |
| 1516 | uint32_t i; |
| 1517 | |
| 1518 | for (i = 0U; i < memory_region->receiver_count; i++) { |
| 1519 | struct ffa_memory_access *receiver = |
| 1520 | ffa_memory_region_get_receiver(memory_region, i); |
| 1521 | if (receiver->receiver_permissions.receiver == receiver_id) { |
| 1522 | break; |
| 1523 | } |
| 1524 | } |
| 1525 | |
| 1526 | return i; |
| 1527 | } |
| 1528 | |
| 1529 | /** |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1530 | * Gets the `ffa_composite_memory_region` for the given receiver from an |
| 1531 | * `ffa_memory_region`, or NULL if it is not valid. |
| 1532 | */ |
| 1533 | static inline struct ffa_composite_memory_region * |
| 1534 | ffa_memory_region_get_composite(struct ffa_memory_region *memory_region, |
| 1535 | uint32_t receiver_index) |
| 1536 | { |
Daniel Boulby | d5ae44b | 2023-12-12 12:18:11 +0000 | [diff] [blame] | 1537 | struct ffa_memory_access *receiver = |
| 1538 | ffa_memory_region_get_receiver(memory_region, receiver_index); |
| 1539 | uint32_t offset; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1540 | |
Daniel Boulby | d5ae44b | 2023-12-12 12:18:11 +0000 | [diff] [blame] | 1541 | if (receiver == NULL) { |
| 1542 | return NULL; |
| 1543 | } |
| 1544 | |
| 1545 | offset = receiver->composite_memory_region_offset; |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1546 | if (offset == 0) { |
| 1547 | return NULL; |
| 1548 | } |
| 1549 | |
| 1550 | return (struct ffa_composite_memory_region *)((uint8_t *)memory_region + |
| 1551 | offset); |
| 1552 | } |
| 1553 | |
| 1554 | static inline uint32_t ffa_mem_relinquish_init( |
| 1555 | struct ffa_mem_relinquish *relinquish_request, |
| 1556 | ffa_memory_handle_t handle, ffa_memory_region_flags_t flags, |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1557 | ffa_id_t sender) |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1558 | { |
| 1559 | relinquish_request->handle = handle; |
| 1560 | relinquish_request->flags = flags; |
| 1561 | relinquish_request->endpoint_count = 1; |
| 1562 | relinquish_request->endpoints[0] = sender; |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1563 | return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_id_t); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1564 | } |
| 1565 | |
J-Alves | 126ab50 | 2022-09-29 11:37:33 +0100 | [diff] [blame] | 1566 | void ffa_copy_memory_region_constituents( |
| 1567 | struct ffa_memory_region_constituent *dest, |
| 1568 | const struct ffa_memory_region_constituent *src); |
| 1569 | |
Karl Meakin | 0fd6729 | 2024-02-06 17:33:05 +0000 | [diff] [blame] | 1570 | struct ffa_features_rxtx_map_params { |
| 1571 | /* |
| 1572 | * Bit[0:1]: |
| 1573 | * Minimum buffer size and alignment boundary: |
| 1574 | * 0b00: 4K |
| 1575 | * 0b01: 64K |
| 1576 | * 0b10: 16K |
| 1577 | * 0b11: Reserved |
| 1578 | */ |
| 1579 | uint8_t min_buf_size : 2; |
| 1580 | /* |
| 1581 | * Bit[2:15]: |
| 1582 | * Reserved (MBZ) |
| 1583 | */ |
| 1584 | uint16_t mbz : 14; |
| 1585 | /* |
| 1586 | * Bit[16:32]: |
| 1587 | * Maximum buffer size in number of pages |
| 1588 | * Only present on version 1.2 or later |
| 1589 | */ |
| 1590 | uint16_t max_buf_size : 16; |
| 1591 | }; |
| 1592 | |
Karl Meakin | 49ec1e4 | 2024-05-10 13:08:24 +0100 | [diff] [blame] | 1593 | enum ffa_features_rxtx_map_buf_size { |
| 1594 | FFA_RXTX_MAP_MIN_BUF_4K = 0, |
| 1595 | FFA_RXTX_MAP_MAX_BUF_PAGE_COUNT = 1, |
| 1596 | }; |
Karl Meakin | 0fd6729 | 2024-02-06 17:33:05 +0000 | [diff] [blame] | 1597 | |
Karl Meakin | f786130 | 2024-02-20 14:39:33 +0000 | [diff] [blame] | 1598 | static inline struct ffa_features_rxtx_map_params ffa_features_rxtx_map_params( |
| 1599 | struct ffa_value args) |
| 1600 | { |
| 1601 | struct ffa_features_rxtx_map_params params; |
| 1602 | uint32_t arg2 = args.arg2; |
| 1603 | |
| 1604 | params = *(struct ffa_features_rxtx_map_params *)(&arg2); |
| 1605 | |
| 1606 | return params; |
| 1607 | } |
| 1608 | |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 1609 | /** |
| 1610 | * Endpoint RX/TX descriptor, as defined by Table 13.27 in FF-A v1.1 EAC0. |
| 1611 | * It's used by the Hypervisor to describe the RX/TX buffers mapped by a VM |
| 1612 | * to the SPMC, in order to allow indirect messaging. |
| 1613 | */ |
| 1614 | struct ffa_endpoint_rx_tx_descriptor { |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1615 | ffa_id_t endpoint_id; |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 1616 | uint16_t reserved; |
| 1617 | |
| 1618 | /* |
| 1619 | * 8-byte aligned offset from the base address of this descriptor to the |
| 1620 | * `ffa_composite_memory_region` describing the RX buffer. |
| 1621 | */ |
| 1622 | uint32_t rx_offset; |
| 1623 | |
| 1624 | /* |
| 1625 | * 8-byte aligned offset from the base address of this descriptor to the |
| 1626 | * `ffa_composite_memory_region` describing the TX buffer. |
| 1627 | */ |
| 1628 | uint32_t tx_offset; |
| 1629 | |
| 1630 | /* Pad to align on 16-byte boundary. */ |
| 1631 | uint32_t pad; |
| 1632 | }; |
| 1633 | |
| 1634 | static inline struct ffa_composite_memory_region * |
Karl Meakin | b9705e2 | 2024-04-05 13:58:28 +0100 | [diff] [blame] | 1635 | ffa_endpoint_get_rx_memory_region(struct ffa_endpoint_rx_tx_descriptor *desc) |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 1636 | { |
Karl Meakin | 2ad6b66 | 2024-07-29 20:45:40 +0100 | [diff] [blame] | 1637 | return (struct ffa_composite_memory_region *)((char *)desc + |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 1638 | desc->rx_offset); |
| 1639 | } |
| 1640 | |
| 1641 | static inline struct ffa_composite_memory_region * |
Karl Meakin | b9705e2 | 2024-04-05 13:58:28 +0100 | [diff] [blame] | 1642 | ffa_endpoint_get_tx_memory_region(struct ffa_endpoint_rx_tx_descriptor *desc) |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 1643 | { |
Karl Meakin | 2ad6b66 | 2024-07-29 20:45:40 +0100 | [diff] [blame] | 1644 | return (struct ffa_composite_memory_region *)((char *)desc + |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 1645 | desc->tx_offset); |
| 1646 | } |
| 1647 | |
J-Alves | 2d8457f | 2022-10-05 11:06:41 +0100 | [diff] [blame] | 1648 | void ffa_memory_region_init_header(struct ffa_memory_region *memory_region, |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1649 | ffa_id_t sender, |
J-Alves | 2d8457f | 2022-10-05 11:06:41 +0100 | [diff] [blame] | 1650 | ffa_memory_attributes_t attributes, |
| 1651 | ffa_memory_region_flags_t flags, |
| 1652 | ffa_memory_handle_t handle, uint32_t tag, |
Daniel Boulby | d5ae44b | 2023-12-12 12:18:11 +0000 | [diff] [blame] | 1653 | uint32_t receiver_count, |
| 1654 | uint32_t receiver_desc_size); |
Daniel Boulby | 59ffee9 | 2023-11-02 18:26:26 +0000 | [diff] [blame] | 1655 | void ffa_memory_access_init(struct ffa_memory_access *receiver, |
| 1656 | ffa_id_t receiver_id, |
| 1657 | enum ffa_data_access data_access, |
| 1658 | enum ffa_instruction_access instruction_access, |
| 1659 | ffa_memory_receiver_flags_t flags, |
| 1660 | struct ffa_memory_access_impdef *impdef_val); |
J-Alves | 4508543 | 2022-04-22 16:19:20 +0100 | [diff] [blame] | 1661 | uint32_t ffa_memory_region_init_single_receiver( |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 1662 | struct ffa_memory_region *memory_region, size_t memory_region_max_size, |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1663 | ffa_id_t sender, ffa_id_t receiver, |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1664 | const struct ffa_memory_region_constituent constituents[], |
| 1665 | uint32_t constituent_count, uint32_t tag, |
| 1666 | ffa_memory_region_flags_t flags, enum ffa_data_access data_access, |
| 1667 | enum ffa_instruction_access instruction_access, |
| 1668 | enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, |
Daniel Boulby | 59ffee9 | 2023-11-02 18:26:26 +0000 | [diff] [blame] | 1669 | enum ffa_memory_shareability shareability, |
| 1670 | struct ffa_memory_access_impdef *impdef_val, uint32_t *fragment_length, |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 1671 | uint32_t *total_length); |
J-Alves | f4eecf7 | 2022-07-20 16:05:34 +0100 | [diff] [blame] | 1672 | uint32_t ffa_memory_region_init( |
| 1673 | struct ffa_memory_region *memory_region, size_t memory_region_max_size, |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1674 | ffa_id_t sender, struct ffa_memory_access receivers[], |
Daniel Boulby | d5ae44b | 2023-12-12 12:18:11 +0000 | [diff] [blame] | 1675 | uint32_t receiver_count, uint32_t receiver_desc_size, |
J-Alves | f4eecf7 | 2022-07-20 16:05:34 +0100 | [diff] [blame] | 1676 | const struct ffa_memory_region_constituent constituents[], |
| 1677 | uint32_t constituent_count, uint32_t tag, |
| 1678 | ffa_memory_region_flags_t flags, enum ffa_memory_type type, |
| 1679 | enum ffa_memory_cacheability cacheability, |
| 1680 | enum ffa_memory_shareability shareability, uint32_t *fragment_length, |
| 1681 | uint32_t *total_length); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1682 | uint32_t ffa_memory_retrieve_request_init( |
| 1683 | struct ffa_memory_region *memory_region, ffa_memory_handle_t handle, |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1684 | ffa_id_t sender, struct ffa_memory_access receivers[], |
Daniel Boulby | d5ae44b | 2023-12-12 12:18:11 +0000 | [diff] [blame] | 1685 | uint32_t receiver_count, uint32_t receiver_desc_size, uint32_t tag, |
| 1686 | ffa_memory_region_flags_t flags, enum ffa_memory_type type, |
| 1687 | enum ffa_memory_cacheability cacheability, |
J-Alves | 9b24ed8 | 2022-08-04 13:12:45 +0100 | [diff] [blame] | 1688 | enum ffa_memory_shareability shareability); |
| 1689 | uint32_t ffa_memory_retrieve_request_init_single_receiver( |
| 1690 | struct ffa_memory_region *memory_region, ffa_memory_handle_t handle, |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1691 | ffa_id_t sender, ffa_id_t receiver, uint32_t tag, |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1692 | ffa_memory_region_flags_t flags, enum ffa_data_access data_access, |
| 1693 | enum ffa_instruction_access instruction_access, |
| 1694 | enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, |
Daniel Boulby | 59ffee9 | 2023-11-02 18:26:26 +0000 | [diff] [blame] | 1695 | enum ffa_memory_shareability shareability, |
| 1696 | struct ffa_memory_access_impdef *impdef_val); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 1697 | uint32_t ffa_memory_lender_retrieve_request_init( |
| 1698 | struct ffa_memory_region *memory_region, ffa_memory_handle_t handle, |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1699 | ffa_id_t sender); |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 1700 | uint32_t ffa_memory_fragment_init( |
| 1701 | struct ffa_memory_region_constituent *fragment, |
| 1702 | size_t fragment_max_size, |
| 1703 | const struct ffa_memory_region_constituent constituents[], |
| 1704 | uint32_t constituent_count, uint32_t *fragment_length); |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 1705 | void ffa_endpoint_rx_tx_descriptor_init( |
J-Alves | 19e20cf | 2023-08-02 12:48:55 +0100 | [diff] [blame] | 1706 | struct ffa_endpoint_rx_tx_descriptor *desc, ffa_id_t endpoint_id, |
Federico Recanati | 392be39 | 2022-02-08 20:53:03 +0100 | [diff] [blame] | 1707 | uint64_t rx_address, uint64_t tx_address); |