J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 1 | /* |
Daniel Boulby | 8aa994c | 2022-01-05 19:44:30 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2022, Arm Limited. All rights reserved. |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef FFA_HELPERS_H |
| 8 | #define FFA_HELPERS_H |
| 9 | |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 10 | #include <ffa_svc.h> |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 11 | #include <tftf_lib.h> |
| 12 | #include <utils_def.h> |
| 13 | |
| 14 | /* This error code must be different to the ones used by FFA */ |
| 15 | #define FFA_TFTF_ERROR -42 |
| 16 | |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 17 | typedef unsigned short ffa_id_t; |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 18 | typedef unsigned short ffa_vm_count_t; |
| 19 | typedef unsigned short ffa_vcpu_count_t; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 20 | typedef uint64_t ffa_memory_handle_t; |
| 21 | /** Flags to indicate properties of receivers during memory region retrieval. */ |
| 22 | typedef uint8_t ffa_memory_receiver_flags_t; |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 23 | |
J-Alves | d708c03 | 2020-11-19 12:14:21 +0000 | [diff] [blame] | 24 | struct ffa_uuid { |
| 25 | const uint32_t uuid[4]; |
| 26 | }; |
| 27 | |
J-Alves | da3e6d4 | 2022-01-25 10:19:56 +0000 | [diff] [blame] | 28 | /** Length in bytes of the name in boot information descriptor. */ |
| 29 | #define FFA_BOOT_INFO_NAME_LEN 16 |
| 30 | |
| 31 | /** |
| 32 | * The FF-A boot info descriptor, as defined in table 5.8 of section 5.4.1, of |
| 33 | * the FF-A v1.1 EAC0 specification. |
| 34 | */ |
| 35 | struct ffa_boot_info_desc { |
| 36 | char name[FFA_BOOT_INFO_NAME_LEN]; |
| 37 | uint8_t type; |
| 38 | uint8_t reserved; |
| 39 | uint16_t flags; |
| 40 | uint32_t size; |
| 41 | uint64_t content; |
| 42 | }; |
| 43 | |
| 44 | /** FF-A boot information type mask. */ |
| 45 | #define FFA_BOOT_INFO_TYPE_SHIFT 7 |
| 46 | #define FFA_BOOT_INFO_TYPE_MASK (0x1U << FFA_BOOT_INFO_TYPE_SHIFT) |
| 47 | #define FFA_BOOT_INFO_TYPE_STD 0U |
| 48 | #define FFA_BOOT_INFO_TYPE_IMPDEF 1U |
| 49 | |
| 50 | /** Standard boot info type IDs. */ |
| 51 | #define FFA_BOOT_INFO_TYPE_ID_MASK 0x7FU |
| 52 | #define FFA_BOOT_INFO_TYPE_ID_FDT 0U |
| 53 | #define FFA_BOOT_INFO_TYPE_ID_HOB 1U |
| 54 | |
| 55 | /** FF-A Boot Info descriptors flags. */ |
| 56 | #define FFA_BOOT_INFO_FLAG_MBZ_MASK 0xFFF0U |
| 57 | |
| 58 | /** Bits [1:0] encode the format of the name field in ffa_boot_info_desc. */ |
| 59 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT 0U |
| 60 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK \ |
| 61 | (0x3U << FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT) |
| 62 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_STRING 0x0U |
| 63 | #define FFA_BOOT_INFO_FLAG_NAME_FORMAT_UUID 0x1U |
| 64 | |
| 65 | /** Bits [3:2] encode the format of the content field in ffa_boot_info_desc. */ |
| 66 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT 2 |
| 67 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK \ |
| 68 | (0x3U << FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT) |
| 69 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_VALUE 0x1U |
| 70 | #define FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_ADDR 0x0U |
| 71 | |
| 72 | static inline uint16_t ffa_boot_info_content_format( |
| 73 | struct ffa_boot_info_desc *desc) |
| 74 | { |
| 75 | return (desc->flags & FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_MASK) >> |
| 76 | FFA_BOOT_INFO_FLAG_CONTENT_FORMAT_SHIFT; |
| 77 | } |
| 78 | |
| 79 | static inline uint16_t ffa_boot_info_name_format( |
| 80 | struct ffa_boot_info_desc *desc) |
| 81 | { |
| 82 | return (desc->flags & FFA_BOOT_INFO_FLAG_NAME_FORMAT_MASK) >> |
| 83 | FFA_BOOT_INFO_FLAG_NAME_FORMAT_SHIFT; |
| 84 | } |
| 85 | |
| 86 | static inline uint8_t ffa_boot_info_type_id(struct ffa_boot_info_desc *desc) |
| 87 | { |
| 88 | return desc->type & FFA_BOOT_INFO_TYPE_ID_MASK; |
| 89 | } |
| 90 | |
| 91 | static inline uint8_t ffa_boot_info_type(struct ffa_boot_info_desc *desc) |
| 92 | { |
| 93 | return (desc->type & FFA_BOOT_INFO_TYPE_MASK) >> |
| 94 | FFA_BOOT_INFO_TYPE_SHIFT; |
| 95 | } |
| 96 | |
| 97 | /** Length in bytes of the signature in the boot descriptor. */ |
| 98 | #define FFA_BOOT_INFO_HEADER_SIGNATURE_LEN 4 |
| 99 | |
| 100 | /** |
| 101 | * The FF-A boot information header, as defined in table 5.9 of section 5.4.2, |
| 102 | * of the FF-A v1.1 EAC0 specification. |
| 103 | */ |
| 104 | struct ffa_boot_info_header { |
| 105 | uint32_t signature; |
| 106 | uint32_t version; |
| 107 | uint32_t info_blob_size; |
| 108 | uint32_t desc_size; |
| 109 | uint32_t desc_count; |
| 110 | uint32_t desc_offset; |
| 111 | uint64_t reserved; |
| 112 | struct ffa_boot_info_desc boot_info[]; |
| 113 | }; |
| 114 | |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 115 | #ifndef __ASSEMBLY__ |
| 116 | |
J-Alves | 18c2805 | 2021-03-09 09:58:53 +0000 | [diff] [blame] | 117 | #include <cassert.h> |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 118 | #include <stdint.h> |
| 119 | |
J-Alves | 4439ece | 2021-11-05 11:52:54 +0000 | [diff] [blame] | 120 | /** |
| 121 | * FF-A Feature ID, to be used with interface FFA_FEATURES. |
| 122 | * As defined in the FF-A v1.1 Beta specification, table 13.10, in section |
| 123 | * 13.2. |
| 124 | */ |
| 125 | |
| 126 | /** Query interrupt ID of Notification Pending Interrupt. */ |
| 127 | #define FFA_FEATURE_NPI 0x1U |
| 128 | |
| 129 | /** Query interrupt ID of Schedule Receiver Interrupt. */ |
| 130 | #define FFA_FEATURE_SRI 0x2U |
| 131 | |
| 132 | /** Query interrupt ID of the Managed Exit Interrupt. */ |
| 133 | #define FFA_FEATURE_MEI 0x3U |
| 134 | |
Max Shvetsov | 0b7d25f | 2021-03-05 13:46:42 +0000 | [diff] [blame] | 135 | /** Partition property: partition supports receipt of direct requests. */ |
| 136 | #define FFA_PARTITION_DIRECT_REQ_RECV 0x1 |
| 137 | |
| 138 | /** Partition property: partition can send direct requests. */ |
| 139 | #define FFA_PARTITION_DIRECT_REQ_SEND 0x2 |
| 140 | |
| 141 | /** Partition property: partition can send and receive indirect messages. */ |
| 142 | #define FFA_PARTITION_INDIRECT_MSG 0x4 |
| 143 | |
J-Alves | 4d05dec | 2021-11-02 11:52:27 +0000 | [diff] [blame] | 144 | /** Partition property: partition can receive notifications. */ |
| 145 | #define FFA_PARTITION_NOTIFICATION 0x8 |
| 146 | |
Daniel Boulby | 8aa994c | 2022-01-05 19:44:30 +0000 | [diff] [blame] | 147 | /** |
| 148 | * Partition info descriptor as defined in Table 13.34 of the v1.1 BETA0 |
| 149 | * FF-A Specification |
| 150 | */ |
Max Shvetsov | c32f478 | 2020-06-23 09:41:15 +0100 | [diff] [blame] | 151 | struct ffa_partition_info { |
| 152 | /** The ID of the VM the information is about */ |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 153 | ffa_id_t id; |
Max Shvetsov | c32f478 | 2020-06-23 09:41:15 +0100 | [diff] [blame] | 154 | /** The number of execution contexts implemented by the partition */ |
| 155 | uint16_t exec_context; |
| 156 | /** The Partition's properties, e.g. supported messaging methods */ |
| 157 | uint32_t properties; |
Daniel Boulby | 8aa994c | 2022-01-05 19:44:30 +0000 | [diff] [blame] | 158 | /** The uuid of the partition */ |
| 159 | struct ffa_uuid uuid; |
Max Shvetsov | c32f478 | 2020-06-23 09:41:15 +0100 | [diff] [blame] | 160 | }; |
| 161 | |
Daniel Boulby | 2ac55f2 | 2022-01-21 12:08:08 +0000 | [diff] [blame] | 162 | /** |
| 163 | * Partition info descriptor as defined in Table 8.25 of the v1.0 |
| 164 | * FF-A Specification |
| 165 | */ |
| 166 | struct ffa_partition_info_v1_0 { |
| 167 | /** The ID of the VM the information is about */ |
| 168 | ffa_id_t id; |
| 169 | /** The number of execution contexts implemented by the partition */ |
| 170 | uint16_t exec_context; |
| 171 | /** The Partition's properties, e.g. supported messaging methods */ |
| 172 | uint32_t properties; |
| 173 | }; |
| 174 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 175 | struct ffa_value { |
| 176 | u_register_t fid; |
| 177 | u_register_t arg1; |
| 178 | u_register_t arg2; |
| 179 | u_register_t arg3; |
| 180 | u_register_t arg4; |
| 181 | u_register_t arg5; |
| 182 | u_register_t arg6; |
| 183 | u_register_t arg7; |
| 184 | }; |
| 185 | |
| 186 | /* Function to make an SMC or SVC service call depending on the exception |
| 187 | * level of the SP. |
| 188 | */ |
| 189 | struct ffa_value ffa_service_call(struct ffa_value *args); |
| 190 | |
| 191 | /* |
| 192 | * Functions to trigger a service call. |
| 193 | * |
| 194 | * The arguments to pass through the service call must be stored in the |
| 195 | * ffa_value structure. The return values of the service call will be stored |
| 196 | * in the same structure (overriding the input arguments). |
| 197 | * |
| 198 | * Return the first return value. It is equivalent to args.fid but is also |
| 199 | * provided as the return value for convenience. |
| 200 | */ |
| 201 | u_register_t ffa_svc(struct ffa_value *args); |
| 202 | u_register_t ffa_smc(struct ffa_value *args); |
| 203 | |
| 204 | static inline uint32_t ffa_func_id(struct ffa_value val) |
J-Alves | f156ae9 | 2021-10-08 12:10:05 +0100 | [diff] [blame] | 205 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 206 | return (uint32_t)val.fid; |
J-Alves | 6cb21d9 | 2021-01-07 15:18:12 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 209 | static inline int32_t ffa_error_code(struct ffa_value val) |
J-Alves | f156ae9 | 2021-10-08 12:10:05 +0100 | [diff] [blame] | 210 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 211 | return (int32_t)val.arg2; |
J-Alves | 6cb21d9 | 2021-01-07 15:18:12 +0000 | [diff] [blame] | 212 | } |
| 213 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 214 | static inline ffa_id_t ffa_endpoint_id(struct ffa_value val) { |
| 215 | return (ffa_id_t)val.arg2 & 0xffff; |
Daniel Boulby | 198deda | 2021-03-03 11:35:25 +0000 | [diff] [blame] | 216 | } |
| 217 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 218 | static inline uint32_t ffa_partition_info_count(struct ffa_value val) |
Daniel Boulby | 2ac55f2 | 2022-01-21 12:08:08 +0000 | [diff] [blame] | 219 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 220 | return (uint32_t)val.arg2; |
Daniel Boulby | 2ac55f2 | 2022-01-21 12:08:08 +0000 | [diff] [blame] | 221 | } |
| 222 | |
Daniel Boulby | 07d751e | 2022-05-30 17:32:00 +0100 | [diff] [blame] | 223 | static inline uint32_t ffa_partition_info_desc_size(struct ffa_value val) |
| 224 | { |
| 225 | return (uint32_t)val.arg3; |
| 226 | } |
| 227 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 228 | static inline uint32_t ffa_feature_intid(struct ffa_value val) |
J-Alves | 4439ece | 2021-11-05 11:52:54 +0000 | [diff] [blame] | 229 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 230 | return (uint32_t)val.arg2; |
J-Alves | 4439ece | 2021-11-05 11:52:54 +0000 | [diff] [blame] | 231 | } |
| 232 | |
J-Alves | 18c2805 | 2021-03-09 09:58:53 +0000 | [diff] [blame] | 233 | typedef uint64_t ffa_notification_bitmap_t; |
| 234 | |
| 235 | #define FFA_NOTIFICATION(ID) (UINT64_C(1) << ID) |
| 236 | |
| 237 | #define MAX_FFA_NOTIFICATIONS UINT32_C(64) |
| 238 | |
| 239 | #define FFA_NOTIFICATIONS_FLAG_PER_VCPU UINT32_C(0x1 << 0) |
| 240 | |
J-Alves | b0cb5d0 | 2021-07-08 11:19:33 +0100 | [diff] [blame] | 241 | /** Flag to delay Schedule Receiver Interrupt. */ |
| 242 | #define FFA_NOTIFICATIONS_FLAG_DELAY_SRI UINT32_C(0x1 << 1) |
| 243 | |
J-Alves | 18c2805 | 2021-03-09 09:58:53 +0000 | [diff] [blame] | 244 | #define FFA_NOTIFICATIONS_FLAGS_VCPU_ID(id) UINT32_C((id & 0xFFFF) << 16) |
| 245 | |
J-Alves | f156ae9 | 2021-10-08 12:10:05 +0100 | [diff] [blame] | 246 | #define FFA_NOTIFICATIONS_FLAG_BITMAP_SP UINT32_C(0x1 << 0) |
| 247 | #define FFA_NOTIFICATIONS_FLAG_BITMAP_VM UINT32_C(0x1 << 1) |
| 248 | #define FFA_NOTIFICATIONS_FLAG_BITMAP_SPM UINT32_C(0x1 << 2) |
| 249 | #define FFA_NOTIFICATIONS_FLAG_BITMAP_HYP UINT32_C(0x1 << 3) |
| 250 | |
J-Alves | 269118a | 2021-09-22 09:46:11 +0100 | [diff] [blame] | 251 | /** |
| 252 | * The following is an SGI ID, that the SPMC configures as non-secure, as |
| 253 | * suggested by the FF-A v1.1 specification, in section 9.4.1. |
| 254 | */ |
| 255 | #define FFA_SCHEDULE_RECEIVER_INTERRUPT_ID 8 |
| 256 | |
J-Alves | f156ae9 | 2021-10-08 12:10:05 +0100 | [diff] [blame] | 257 | #define FFA_NOTIFICATIONS_BITMAP(lo, hi) \ |
| 258 | (ffa_notification_bitmap_t)(lo) | \ |
| 259 | (((ffa_notification_bitmap_t)hi << 32) & 0xFFFFFFFF00000000ULL) |
| 260 | |
| 261 | #define FFA_NOTIFICATIONS_FLAGS_VCPU_ID(id) UINT32_C((id & 0xFFFF) << 16) |
| 262 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 263 | static inline ffa_notification_bitmap_t ffa_notifications_get_from_sp( |
| 264 | struct ffa_value val) |
J-Alves | f156ae9 | 2021-10-08 12:10:05 +0100 | [diff] [blame] | 265 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 266 | return FFA_NOTIFICATIONS_BITMAP(val.arg2, val.arg3); |
J-Alves | f156ae9 | 2021-10-08 12:10:05 +0100 | [diff] [blame] | 267 | } |
| 268 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 269 | static inline ffa_notification_bitmap_t ffa_notifications_get_from_vm( |
| 270 | struct ffa_value val) |
J-Alves | f156ae9 | 2021-10-08 12:10:05 +0100 | [diff] [blame] | 271 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 272 | return FFA_NOTIFICATIONS_BITMAP(val.arg4, val.arg5); |
J-Alves | f156ae9 | 2021-10-08 12:10:05 +0100 | [diff] [blame] | 273 | } |
| 274 | |
J-Alves | 5bce250 | 2021-06-14 14:27:45 +0100 | [diff] [blame] | 275 | /* |
| 276 | * FFA_NOTIFICATION_INFO_GET is a SMC64 interface. |
| 277 | * The following macros are defined for SMC64 implementation. |
| 278 | */ |
| 279 | #define FFA_NOTIFICATIONS_INFO_GET_MAX_IDS 20U |
| 280 | |
| 281 | #define FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING UINT64_C(0x1) |
| 282 | |
| 283 | #define FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT 0x7U |
| 284 | #define FFA_NOTIFICATIONS_LISTS_COUNT_MASK 0x1FU |
| 285 | #define FFA_NOTIFICATIONS_LIST_SHIFT(l) (2 * (l - 1) + 12) |
| 286 | #define FFA_NOTIFICATIONS_LIST_SIZE_MASK 0x3U |
| 287 | |
| 288 | static inline uint32_t ffa_notifications_info_get_lists_count( |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 289 | struct ffa_value ret) |
J-Alves | 5bce250 | 2021-06-14 14:27:45 +0100 | [diff] [blame] | 290 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 291 | return (uint32_t)(ret.arg2 >> FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT) |
J-Alves | 5bce250 | 2021-06-14 14:27:45 +0100 | [diff] [blame] | 292 | & FFA_NOTIFICATIONS_LISTS_COUNT_MASK; |
| 293 | } |
| 294 | |
| 295 | static inline uint32_t ffa_notifications_info_get_list_size( |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 296 | struct ffa_value ret, uint32_t list) |
J-Alves | 5bce250 | 2021-06-14 14:27:45 +0100 | [diff] [blame] | 297 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 298 | return (uint32_t)(ret.arg2 >> FFA_NOTIFICATIONS_LIST_SHIFT(list)) & |
J-Alves | 5bce250 | 2021-06-14 14:27:45 +0100 | [diff] [blame] | 299 | FFA_NOTIFICATIONS_LIST_SIZE_MASK; |
| 300 | } |
| 301 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 302 | static inline bool ffa_notifications_info_get_more_pending(struct ffa_value ret) |
J-Alves | 5bce250 | 2021-06-14 14:27:45 +0100 | [diff] [blame] | 303 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 304 | return (ret.arg2 & FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING) != 0U; |
J-Alves | 5bce250 | 2021-06-14 14:27:45 +0100 | [diff] [blame] | 305 | } |
| 306 | |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 307 | enum ffa_data_access { |
| 308 | FFA_DATA_ACCESS_NOT_SPECIFIED, |
| 309 | FFA_DATA_ACCESS_RO, |
| 310 | FFA_DATA_ACCESS_RW, |
| 311 | FFA_DATA_ACCESS_RESERVED, |
| 312 | }; |
| 313 | |
| 314 | enum ffa_instruction_access { |
| 315 | FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, |
| 316 | FFA_INSTRUCTION_ACCESS_NX, |
| 317 | FFA_INSTRUCTION_ACCESS_X, |
| 318 | FFA_INSTRUCTION_ACCESS_RESERVED, |
| 319 | }; |
| 320 | |
| 321 | enum ffa_memory_type { |
| 322 | FFA_MEMORY_NOT_SPECIFIED_MEM, |
| 323 | FFA_MEMORY_DEVICE_MEM, |
| 324 | FFA_MEMORY_NORMAL_MEM, |
| 325 | }; |
| 326 | |
| 327 | enum ffa_memory_cacheability { |
| 328 | FFA_MEMORY_CACHE_RESERVED = 0x0, |
| 329 | FFA_MEMORY_CACHE_NON_CACHEABLE = 0x1, |
| 330 | FFA_MEMORY_CACHE_RESERVED_1 = 0x2, |
| 331 | FFA_MEMORY_CACHE_WRITE_BACK = 0x3, |
| 332 | FFA_MEMORY_DEV_NGNRNE = 0x0, |
| 333 | FFA_MEMORY_DEV_NGNRE = 0x1, |
| 334 | FFA_MEMORY_DEV_NGRE = 0x2, |
| 335 | FFA_MEMORY_DEV_GRE = 0x3, |
| 336 | }; |
| 337 | |
| 338 | enum ffa_memory_shareability { |
| 339 | FFA_MEMORY_SHARE_NON_SHAREABLE, |
| 340 | FFA_MEMORY_SHARE_RESERVED, |
| 341 | FFA_MEMORY_OUTER_SHAREABLE, |
| 342 | FFA_MEMORY_INNER_SHAREABLE, |
| 343 | }; |
| 344 | |
| 345 | typedef uint8_t ffa_memory_access_permissions_t; |
| 346 | |
| 347 | /** |
| 348 | * This corresponds to table "Memory region attributes descriptor" of the FF-A |
| 349 | * 1.0 specification. |
| 350 | */ |
| 351 | typedef uint8_t ffa_memory_attributes_t; |
| 352 | |
| 353 | #define FFA_DATA_ACCESS_OFFSET (0x0U) |
| 354 | #define FFA_DATA_ACCESS_MASK ((0x3U) << FFA_DATA_ACCESS_OFFSET) |
| 355 | |
| 356 | #define FFA_INSTRUCTION_ACCESS_OFFSET (0x2U) |
| 357 | #define FFA_INSTRUCTION_ACCESS_MASK ((0x3U) << FFA_INSTRUCTION_ACCESS_OFFSET) |
| 358 | |
| 359 | #define FFA_MEMORY_TYPE_OFFSET (0x4U) |
| 360 | #define FFA_MEMORY_TYPE_MASK ((0x3U) << FFA_MEMORY_TYPE_OFFSET) |
| 361 | |
| 362 | #define FFA_MEMORY_CACHEABILITY_OFFSET (0x2U) |
| 363 | #define FFA_MEMORY_CACHEABILITY_MASK ((0x3U) << FFA_MEMORY_CACHEABILITY_OFFSET) |
| 364 | |
| 365 | #define FFA_MEMORY_SHAREABILITY_OFFSET (0x0U) |
| 366 | #define FFA_MEMORY_SHAREABILITY_MASK ((0x3U) << FFA_MEMORY_SHAREABILITY_OFFSET) |
| 367 | |
| 368 | #define ATTR_FUNCTION_SET(name, container_type, offset, mask) \ |
| 369 | static inline void ffa_set_##name##_attr(container_type *attr, \ |
| 370 | const enum ffa_##name perm) \ |
| 371 | { \ |
| 372 | *attr = (*attr & ~(mask)) | ((perm << offset) & mask); \ |
| 373 | } |
| 374 | |
| 375 | #define ATTR_FUNCTION_GET(name, container_type, offset, mask) \ |
| 376 | static inline enum ffa_##name ffa_get_##name##_attr( \ |
| 377 | container_type attr) \ |
| 378 | { \ |
| 379 | return (enum ffa_##name)((attr & mask) >> offset); \ |
| 380 | } |
| 381 | |
| 382 | ATTR_FUNCTION_SET(data_access, ffa_memory_access_permissions_t, |
| 383 | FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK) |
| 384 | ATTR_FUNCTION_GET(data_access, ffa_memory_access_permissions_t, |
| 385 | FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK) |
| 386 | |
| 387 | ATTR_FUNCTION_SET(instruction_access, ffa_memory_access_permissions_t, |
| 388 | FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK) |
| 389 | ATTR_FUNCTION_GET(instruction_access, ffa_memory_access_permissions_t, |
| 390 | FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK) |
| 391 | |
| 392 | ATTR_FUNCTION_SET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET, |
| 393 | FFA_MEMORY_TYPE_MASK) |
| 394 | ATTR_FUNCTION_GET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET, |
| 395 | FFA_MEMORY_TYPE_MASK) |
| 396 | |
| 397 | ATTR_FUNCTION_SET(memory_cacheability, ffa_memory_attributes_t, |
| 398 | FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK) |
| 399 | ATTR_FUNCTION_GET(memory_cacheability, ffa_memory_attributes_t, |
| 400 | FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK) |
| 401 | |
| 402 | ATTR_FUNCTION_SET(memory_shareability, ffa_memory_attributes_t, |
| 403 | FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK) |
| 404 | ATTR_FUNCTION_GET(memory_shareability, ffa_memory_attributes_t, |
| 405 | FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK) |
| 406 | |
| 407 | #define FFA_MEMORY_HANDLE_ALLOCATOR_MASK \ |
| 408 | ((ffa_memory_handle_t)(UINT64_C(1) << 63)) |
| 409 | #define FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR \ |
| 410 | ((ffa_memory_handle_t)(UINT64_C(1) << 63)) |
| 411 | #define FFA_MEMORY_HANDLE_INVALID (~UINT64_C(0)) |
| 412 | |
| 413 | /** |
| 414 | * A set of contiguous pages which is part of a memory region. This corresponds |
| 415 | * to table "Constituent memory region descriptor" of the FFA 1.0 specification. |
| 416 | */ |
| 417 | struct ffa_memory_region_constituent { |
| 418 | /** |
| 419 | * The base IPA of the constituent memory region, aligned to 4 kiB page |
| 420 | * size granularity. |
| 421 | */ |
| 422 | void *address; |
| 423 | /** The number of 4 kiB pages in the constituent memory region. */ |
| 424 | uint32_t page_count; |
| 425 | /** Reserved field, must be 0. */ |
| 426 | uint32_t reserved; |
| 427 | }; |
| 428 | |
| 429 | /** |
| 430 | * A set of pages comprising a memory region. This corresponds to table |
| 431 | * "Composite memory region descriptor" of the FFA 1.0 specification. |
| 432 | */ |
| 433 | struct ffa_composite_memory_region { |
| 434 | /** |
| 435 | * The total number of 4 kiB pages included in this memory region. This |
| 436 | * must be equal to the sum of page counts specified in each |
| 437 | * `ffa_memory_region_constituent`. |
| 438 | */ |
| 439 | uint32_t page_count; |
| 440 | /** |
| 441 | * The number of constituents (`ffa_memory_region_constituent`) |
| 442 | * included in this memory region range. |
| 443 | */ |
| 444 | uint32_t constituent_count; |
| 445 | /** Reserved field, must be 0. */ |
| 446 | uint64_t reserved_0; |
| 447 | /** An array of `constituent_count` memory region constituents. */ |
| 448 | struct ffa_memory_region_constituent constituents[]; |
| 449 | }; |
| 450 | |
| 451 | /** |
| 452 | * This corresponds to table "Memory access permissions descriptor" of the FFA |
| 453 | * 1.0 specification. |
| 454 | */ |
| 455 | struct ffa_memory_region_attributes { |
| 456 | /** The ID of the VM to which the memory is being given or shared. */ |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 457 | ffa_id_t receiver; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 458 | /** |
| 459 | * The permissions with which the memory region should be mapped in the |
| 460 | * receiver's page table. |
| 461 | */ |
| 462 | ffa_memory_access_permissions_t permissions; |
| 463 | /** |
| 464 | * Flags used during FFA_MEM_RETRIEVE_REQ and FFA_MEM_RETRIEVE_RESP |
| 465 | * for memory regions with multiple borrowers. |
| 466 | */ |
| 467 | ffa_memory_receiver_flags_t flags; |
| 468 | }; |
| 469 | |
| 470 | /** Flags to control the behaviour of a memory sharing transaction. */ |
| 471 | typedef uint32_t ffa_memory_region_flags_t; |
| 472 | |
| 473 | /** |
| 474 | * Clear memory region contents after unmapping it from the sender and before |
| 475 | * mapping it for any receiver. |
| 476 | */ |
| 477 | #define FFA_MEMORY_REGION_FLAG_CLEAR 0x1U |
| 478 | |
| 479 | /** |
| 480 | * Whether the hypervisor may time slice the memory sharing or retrieval |
| 481 | * operation. |
| 482 | */ |
| 483 | #define FFA_MEMORY_REGION_FLAG_TIME_SLICE 0x2U |
| 484 | |
| 485 | /** |
| 486 | * Whether the hypervisor should clear the memory region after the receiver |
| 487 | * relinquishes it or is aborted. |
| 488 | */ |
| 489 | #define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH 0x4U |
| 490 | |
| 491 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_MASK ((0x3U) << 3) |
| 492 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_UNSPECIFIED ((0x0U) << 3) |
| 493 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE ((0x1U) << 3) |
| 494 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_LEND ((0x2U) << 3) |
| 495 | #define FFA_MEMORY_REGION_TRANSACTION_TYPE_DONATE ((0x3U) << 3) |
| 496 | |
J-Alves | 0435cae | 2020-11-06 10:49:56 +0000 | [diff] [blame] | 497 | /** The maximum number of recipients a memory region may be sent to. */ |
| 498 | #define MAX_MEM_SHARE_RECIPIENTS 1U |
| 499 | |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 500 | /** |
| 501 | * This corresponds to table "Endpoint memory access descriptor" of the FFA 1.0 |
| 502 | * specification. |
| 503 | */ |
| 504 | struct ffa_memory_access { |
| 505 | struct ffa_memory_region_attributes receiver_permissions; |
| 506 | /** |
| 507 | * Offset in bytes from the start of the outer `ffa_memory_region` to |
| 508 | * an `ffa_composite_memory_region` struct. |
| 509 | */ |
| 510 | uint32_t composite_memory_region_offset; |
| 511 | uint64_t reserved_0; |
| 512 | }; |
| 513 | |
| 514 | /** |
| 515 | * Information about a set of pages which are being shared. This corresponds to |
| 516 | * table "Lend, donate or share memory transaction descriptor" of the FFA |
| 517 | * 1.0 specification. Note that it is also used for retrieve requests and |
| 518 | * responses. |
| 519 | */ |
| 520 | struct ffa_memory_region { |
| 521 | /** |
| 522 | * The ID of the VM which originally sent the memory region, i.e. the |
| 523 | * owner. |
| 524 | */ |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 525 | ffa_id_t sender; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 526 | ffa_memory_attributes_t attributes; |
| 527 | /** Reserved field, must be 0. */ |
| 528 | uint8_t reserved_0; |
| 529 | /** Flags to control behaviour of the transaction. */ |
| 530 | ffa_memory_region_flags_t flags; |
| 531 | ffa_memory_handle_t handle; |
| 532 | /** |
| 533 | * An implementation defined value associated with the receiver and the |
| 534 | * memory region. |
| 535 | */ |
| 536 | uint64_t tag; |
| 537 | /** Reserved field, must be 0. */ |
| 538 | uint32_t reserved_1; |
| 539 | /** |
| 540 | * The number of `ffa_memory_access` entries included in this |
| 541 | * transaction. |
| 542 | */ |
| 543 | uint32_t receiver_count; |
| 544 | /** |
| 545 | * An array of `attribute_count` endpoint memory access descriptors. |
| 546 | * Each one specifies a memory region offset, an endpoint and the |
| 547 | * attributes with which this memory region should be mapped in that |
| 548 | * endpoint's page table. |
| 549 | */ |
| 550 | struct ffa_memory_access receivers[]; |
| 551 | }; |
| 552 | |
| 553 | /** |
| 554 | * Descriptor used for FFA_MEM_RELINQUISH requests. This corresponds to table |
| 555 | * "Descriptor to relinquish a memory region" of the FFA 1.0 specification. |
| 556 | */ |
| 557 | struct ffa_mem_relinquish { |
| 558 | ffa_memory_handle_t handle; |
| 559 | ffa_memory_region_flags_t flags; |
| 560 | uint32_t endpoint_count; |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 561 | ffa_id_t endpoints[]; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 562 | }; |
| 563 | |
| 564 | static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t h1, uint32_t h2) |
| 565 | { |
J-Alves | 18c2805 | 2021-03-09 09:58:53 +0000 | [diff] [blame] | 566 | return (ffa_notification_bitmap_t)h1 | |
| 567 | (ffa_notification_bitmap_t)h2 << 32; |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 568 | } |
| 569 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 570 | static inline ffa_memory_handle_t ffa_mem_success_handle(struct ffa_value r) |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 571 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 572 | return ffa_assemble_handle(r.arg2, r.arg3); |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | /** |
| 576 | * Gets the `ffa_composite_memory_region` for the given receiver from an |
| 577 | * `ffa_memory_region`, or NULL if it is not valid. |
| 578 | */ |
| 579 | static inline struct ffa_composite_memory_region * |
| 580 | ffa_memory_region_get_composite(struct ffa_memory_region *memory_region, |
| 581 | uint32_t receiver_index) |
| 582 | { |
| 583 | uint32_t offset = memory_region->receivers[receiver_index] |
| 584 | .composite_memory_region_offset; |
| 585 | |
| 586 | if (offset == 0) { |
| 587 | return NULL; |
| 588 | } |
| 589 | |
| 590 | return (struct ffa_composite_memory_region *)((uint8_t *)memory_region + |
| 591 | offset); |
| 592 | } |
| 593 | |
| 594 | static inline uint32_t ffa_mem_relinquish_init( |
| 595 | struct ffa_mem_relinquish *relinquish_request, |
| 596 | ffa_memory_handle_t handle, ffa_memory_region_flags_t flags, |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 597 | ffa_id_t sender) |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 598 | { |
| 599 | relinquish_request->handle = handle; |
| 600 | relinquish_request->flags = flags; |
| 601 | relinquish_request->endpoint_count = 1; |
| 602 | relinquish_request->endpoints[0] = sender; |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 603 | return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_id_t); |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | uint32_t ffa_memory_retrieve_request_init( |
| 607 | struct ffa_memory_region *memory_region, ffa_memory_handle_t handle, |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 608 | ffa_id_t sender, ffa_id_t receiver, uint32_t tag, |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 609 | ffa_memory_region_flags_t flags, enum ffa_data_access data_access, |
| 610 | enum ffa_instruction_access instruction_access, |
| 611 | enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, |
| 612 | enum ffa_memory_shareability shareability); |
| 613 | |
| 614 | uint32_t ffa_memory_region_init( |
| 615 | struct ffa_memory_region *memory_region, size_t memory_region_max_size, |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 616 | ffa_id_t sender, ffa_id_t receiver, |
J-Alves | f3a393c | 2020-10-23 16:00:39 +0100 | [diff] [blame] | 617 | const struct ffa_memory_region_constituent constituents[], |
| 618 | uint32_t constituent_count, uint32_t tag, |
| 619 | ffa_memory_region_flags_t flags, enum ffa_data_access data_access, |
| 620 | enum ffa_instruction_access instruction_access, |
| 621 | enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, |
| 622 | enum ffa_memory_shareability shareability, uint32_t *total_length, |
| 623 | uint32_t *fragment_length); |
| 624 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 625 | static inline ffa_id_t ffa_dir_msg_dest(struct ffa_value val) { |
| 626 | return (ffa_id_t)val.arg1 & U(0xFFFF); |
J-Alves | 6cb21d9 | 2021-01-07 15:18:12 +0000 | [diff] [blame] | 627 | } |
| 628 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 629 | static inline ffa_id_t ffa_dir_msg_source(struct ffa_value val) { |
| 630 | return (ffa_id_t)(val.arg1 >> 16U); |
J-Alves | 6cb21d9 | 2021-01-07 15:18:12 +0000 | [diff] [blame] | 631 | } |
| 632 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 633 | struct ffa_value ffa_msg_send_direct_req64(ffa_id_t source_id, |
| 634 | ffa_id_t dest_id, uint64_t arg0, |
| 635 | uint64_t arg1, uint64_t arg2, |
| 636 | uint64_t arg3, uint64_t arg4); |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 637 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 638 | struct ffa_value ffa_msg_send_direct_req32(ffa_id_t source_id, |
| 639 | ffa_id_t dest_id, uint32_t arg0, |
| 640 | uint32_t arg1, uint32_t arg2, |
| 641 | uint32_t arg3, uint32_t arg4); |
J-Alves | ecd3074 | 2021-02-19 18:31:06 +0000 | [diff] [blame] | 642 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 643 | struct ffa_value ffa_msg_send_direct_resp64(ffa_id_t source_id, |
| 644 | ffa_id_t dest_id, uint64_t arg0, |
| 645 | uint64_t arg1, uint64_t arg2, |
| 646 | uint64_t arg3, uint64_t arg4); |
J-Alves | ecd3074 | 2021-02-19 18:31:06 +0000 | [diff] [blame] | 647 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 648 | struct ffa_value ffa_msg_send_direct_resp32(ffa_id_t source_id, |
| 649 | ffa_id_t dest_id, uint32_t arg0, |
| 650 | uint32_t arg1, uint32_t arg2, |
| 651 | uint32_t arg3, uint32_t arg4); |
J-Alves | 035b7d0 | 2021-02-11 10:40:35 +0000 | [diff] [blame] | 652 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 653 | struct ffa_value ffa_run(uint32_t dest_id, uint32_t vcpu_id); |
| 654 | struct ffa_value ffa_version(uint32_t input_version); |
| 655 | struct ffa_value ffa_id_get(void); |
| 656 | struct ffa_value ffa_spm_id_get(void); |
| 657 | struct ffa_value ffa_msg_wait(void); |
| 658 | struct ffa_value ffa_error(int32_t error_code); |
| 659 | struct ffa_value ffa_features(uint32_t feature); |
| 660 | struct ffa_value ffa_partition_info_get(const struct ffa_uuid uuid); |
| 661 | struct ffa_value ffa_rx_release(void); |
| 662 | struct ffa_value ffa_rxtx_map(uintptr_t send, uintptr_t recv, uint32_t pages); |
| 663 | struct ffa_value ffa_rxtx_unmap(void); |
| 664 | struct ffa_value ffa_mem_donate(uint32_t descriptor_length, |
| 665 | uint32_t fragment_length); |
| 666 | struct ffa_value ffa_mem_lend(uint32_t descriptor_length, |
J-Alves | 3ea46d1 | 2020-09-09 11:13:05 +0100 | [diff] [blame] | 667 | uint32_t fragment_length); |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 668 | struct ffa_value ffa_mem_share(uint32_t descriptor_length, |
| 669 | uint32_t fragment_length); |
| 670 | struct ffa_value ffa_mem_retrieve_req(uint32_t descriptor_length, |
| 671 | uint32_t fragment_length); |
| 672 | struct ffa_value ffa_mem_relinquish(void); |
| 673 | struct ffa_value ffa_mem_reclaim(uint64_t handle, uint32_t flags); |
| 674 | struct ffa_value ffa_notification_bitmap_create(ffa_id_t vm_id, |
| 675 | ffa_vcpu_count_t vcpu_count); |
| 676 | struct ffa_value ffa_notification_bitmap_destroy(ffa_id_t vm_id); |
| 677 | struct ffa_value ffa_notification_bind(ffa_id_t sender, ffa_id_t receiver, |
| 678 | uint32_t flags, |
J-Alves | 18c2805 | 2021-03-09 09:58:53 +0000 | [diff] [blame] | 679 | ffa_notification_bitmap_t notifications); |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 680 | struct ffa_value ffa_notification_unbind(ffa_id_t sender, ffa_id_t receiver, |
| 681 | ffa_notification_bitmap_t notifications); |
| 682 | struct ffa_value ffa_notification_set(ffa_id_t sender, ffa_id_t receiver, |
| 683 | uint32_t flags, |
| 684 | ffa_notification_bitmap_t bitmap); |
| 685 | struct ffa_value ffa_notification_get(ffa_id_t receiver, uint32_t vcpu_id, |
| 686 | uint32_t flags); |
| 687 | struct ffa_value ffa_notification_info_get(void); |
Maksims Svecovs | 0b45223 | 2022-05-24 11:30:34 +0100 | [diff] [blame^] | 688 | |
| 689 | struct ffa_value ffa_console_log(const char* message, size_t char_count); |
| 690 | |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 691 | #endif /* __ASSEMBLY__ */ |
| 692 | |
| 693 | #endif /* FFA_HELPERS_H */ |