J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 1 | /* |
Madhukar Pappireddy | 41416cc | 2023-03-02 16:04:38 -0600 | [diff] [blame] | 2 | * Copyright (c) 2020-2023, Arm Limited. All rights reserved. |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef FFA_SVC_H |
| 8 | #define FFA_SVC_H |
| 9 | |
Marc Bonnici | 8e1a755 | 2021-12-01 17:57:04 +0000 | [diff] [blame] | 10 | #include <stdbool.h> |
| 11 | |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 12 | #include <lib/smccc.h> |
| 13 | #include <lib/utils_def.h> |
| 14 | #include <tools_share/uuid.h> |
| 15 | |
| 16 | /* FFA error codes. */ |
J-Alves | 4c95c70 | 2020-05-26 14:03:05 +0100 | [diff] [blame] | 17 | #define FFA_ERROR_NOT_SUPPORTED -1 |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 18 | #define FFA_ERROR_INVALID_PARAMETER -2 |
| 19 | #define FFA_ERROR_NO_MEMORY -3 |
| 20 | #define FFA_ERROR_BUSY -4 |
| 21 | #define FFA_ERROR_INTERRUPTED -5 |
| 22 | #define FFA_ERROR_DENIED -6 |
J-Alves | 4c95c70 | 2020-05-26 14:03:05 +0100 | [diff] [blame] | 23 | #define FFA_ERROR_RETRY -7 |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 24 | |
| 25 | /* The macros below are used to identify FFA calls from the SMC function ID */ |
| 26 | #define FFA_FNUM_MIN_VALUE U(0x60) |
Madhukar Pappireddy | 41416cc | 2023-03-02 16:04:38 -0600 | [diff] [blame] | 27 | #define FFA_FNUM_MAX_VALUE U(0x8C) |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 28 | #define is_ffa_fid(fid) __extension__ ({ \ |
| 29 | __typeof__(fid) _fid = (fid); \ |
| 30 | ((GET_SMC_NUM(_fid) >= FFA_FNUM_MIN_VALUE) && \ |
| 31 | (GET_SMC_NUM(_fid) <= FFA_FNUM_MAX_VALUE)); }) |
| 32 | |
| 33 | /* FFA_VERSION helpers */ |
| 34 | #define FFA_VERSION_MAJOR U(1) |
J-Alves | 4c95c70 | 2020-05-26 14:03:05 +0100 | [diff] [blame] | 35 | #define FFA_VERSION_MAJOR_SHIFT 16 |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 36 | #define FFA_VERSION_MAJOR_MASK U(0x7FFF) |
Kathleen Capella | fa435ea | 2023-09-05 14:33:29 -0400 | [diff] [blame] | 37 | #define FFA_VERSION_MINOR U(2) |
J-Alves | 4c95c70 | 2020-05-26 14:03:05 +0100 | [diff] [blame] | 38 | #define FFA_VERSION_MINOR_SHIFT 0 |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 39 | #define FFA_VERSION_MINOR_MASK U(0xFFFF) |
J-Alves | 4c95c70 | 2020-05-26 14:03:05 +0100 | [diff] [blame] | 40 | #define FFA_VERSION_BIT31_MASK U(0x1u << 31) |
Marc Bonnici | e95eb7c | 2021-12-08 14:24:03 +0000 | [diff] [blame] | 41 | #define FFA_VERSION_MASK U(0xFFFFFFFF) |
J-Alves | 4c95c70 | 2020-05-26 14:03:05 +0100 | [diff] [blame] | 42 | |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 43 | |
J-Alves | 4c95c70 | 2020-05-26 14:03:05 +0100 | [diff] [blame] | 44 | #define MAKE_FFA_VERSION(major, minor) \ |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 45 | ((((major) & FFA_VERSION_MAJOR_MASK) << FFA_VERSION_MAJOR_SHIFT) | \ |
| 46 | (((minor) & FFA_VERSION_MINOR_MASK) << FFA_VERSION_MINOR_SHIFT)) |
| 47 | #define FFA_VERSION_COMPILED MAKE_FFA_VERSION(FFA_VERSION_MAJOR, \ |
| 48 | FFA_VERSION_MINOR) |
| 49 | |
| 50 | /* FFA_MSG_SEND helpers */ |
| 51 | #define FFA_MSG_SEND_ATTRS_BLK_SHIFT U(0) |
| 52 | #define FFA_MSG_SEND_ATTRS_BLK_MASK U(0x1) |
| 53 | #define FFA_MSG_SEND_ATTRS_BLK U(0) |
| 54 | #define FFA_MSG_SEND_ATTRS_BLK_NOT U(1) |
| 55 | #define FFA_MSG_SEND_ATTRS(blk) \ |
| 56 | (((blk) & FFA_MSG_SEND_ATTRS_BLK_MASK) \ |
| 57 | << FFA_MSG_SEND_ATTRS_BLK_SHIFT) |
| 58 | |
Marc Bonnici | 25f4b54 | 2022-04-12 17:18:13 +0100 | [diff] [blame] | 59 | /* Defines for FF-A framework messages exchanged using direct messages. */ |
| 60 | #define FFA_FWK_MSG_BIT BIT(31) |
| 61 | #define FFA_FWK_MSG_MASK 0xFF |
| 62 | #define FFA_FWK_MSG_PSCI U(0x0) |
| 63 | |
| 64 | /* Defines for FF-A power management messages framework messages. */ |
| 65 | #define FFA_PM_MSG_WB_REQ U(0x1) /* Warm boot request. */ |
| 66 | #define FFA_PM_MSG_PM_RESP U(0x2) /* Response to PSCI or warmboot req. */ |
| 67 | |
| 68 | /* FF-A warm boot types. */ |
| 69 | #define FFA_WB_TYPE_S2RAM 0x0 |
| 70 | #define FFA_WB_TYPE_NOTS2RAM 0x1 |
| 71 | |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 72 | /* Get FFA fastcall std FID from function number */ |
| 73 | #define FFA_FID(smc_cc, func_num) \ |
| 74 | ((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \ |
| 75 | ((smc_cc) << FUNCID_CC_SHIFT) | \ |
| 76 | (OEN_STD_START << FUNCID_OEN_SHIFT) | \ |
| 77 | ((func_num) << FUNCID_NUM_SHIFT)) |
| 78 | |
| 79 | /* FFA function numbers */ |
J-Alves | 481c52f | 2021-03-11 17:46:47 +0000 | [diff] [blame] | 80 | #define FFA_FNUM_ERROR U(0x60) |
| 81 | #define FFA_FNUM_SUCCESS U(0x61) |
| 82 | #define FFA_FNUM_INTERRUPT U(0x62) |
| 83 | #define FFA_FNUM_VERSION U(0x63) |
| 84 | #define FFA_FNUM_FEATURES U(0x64) |
| 85 | #define FFA_FNUM_RX_RELEASE U(0x65) |
| 86 | #define FFA_FNUM_RXTX_MAP U(0x66) |
| 87 | #define FFA_FNUM_RXTX_UNMAP U(0x67) |
| 88 | #define FFA_FNUM_PARTITION_INFO_GET U(0x68) |
| 89 | #define FFA_FNUM_ID_GET U(0x69) |
| 90 | #define FFA_FNUM_MSG_POLL U(0x6A) /* Legacy FF-A v1.0 */ |
| 91 | #define FFA_FNUM_MSG_WAIT U(0x6B) |
| 92 | #define FFA_FNUM_MSG_YIELD U(0x6C) |
| 93 | #define FFA_FNUM_MSG_RUN U(0x6D) |
| 94 | #define FFA_FNUM_MSG_SEND U(0x6E) /* Legacy FF-A v1.0 */ |
| 95 | #define FFA_FNUM_MSG_SEND_DIRECT_REQ U(0x6F) |
| 96 | #define FFA_FNUM_MSG_SEND_DIRECT_RESP U(0x70) |
| 97 | #define FFA_FNUM_MEM_DONATE U(0x71) |
| 98 | #define FFA_FNUM_MEM_LEND U(0x72) |
| 99 | #define FFA_FNUM_MEM_SHARE U(0x73) |
| 100 | #define FFA_FNUM_MEM_RETRIEVE_REQ U(0x74) |
| 101 | #define FFA_FNUM_MEM_RETRIEVE_RESP U(0x75) |
| 102 | #define FFA_FNUM_MEM_RELINQUISH U(0x76) |
| 103 | #define FFA_FNUM_MEM_RECLAIM U(0x77) |
Marc Bonnici | 9fa01e9 | 2021-09-23 09:44:14 +0100 | [diff] [blame] | 104 | #define FFA_FNUM_MEM_FRAG_RX U(0x7A) |
| 105 | #define FFA_FNUM_MEM_FRAG_TX U(0x7B) |
J-Alves | 481c52f | 2021-03-11 17:46:47 +0000 | [diff] [blame] | 106 | #define FFA_FNUM_NORMAL_WORLD_RESUME U(0x7C) |
| 107 | |
| 108 | /* FF-A v1.1 */ |
| 109 | #define FFA_FNUM_NOTIFICATION_BITMAP_CREATE U(0x7D) |
| 110 | #define FFA_FNUM_NOTIFICATION_BITMAP_DESTROY U(0x7E) |
| 111 | #define FFA_FNUM_NOTIFICATION_BIND U(0x7F) |
| 112 | #define FFA_FNUM_NOTIFICATION_UNBIND U(0x80) |
| 113 | #define FFA_FNUM_NOTIFICATION_SET U(0x81) |
| 114 | #define FFA_FNUM_NOTIFICATION_GET U(0x82) |
| 115 | #define FFA_FNUM_NOTIFICATION_INFO_GET U(0x83) |
| 116 | #define FFA_FNUM_RX_ACQUIRE U(0x84) |
| 117 | #define FFA_FNUM_SPM_ID_GET U(0x85) |
| 118 | #define FFA_FNUM_MSG_SEND2 U(0x86) |
| 119 | #define FFA_FNUM_SECONDARY_EP_REGISTER U(0x87) |
Nishant Sharma | 789052c | 2022-03-25 23:52:34 +0000 | [diff] [blame] | 120 | #define FFA_FNUM_MEM_PERM_GET U(0x88) |
| 121 | #define FFA_FNUM_MEM_PERM_SET U(0x89) |
Kathleen Capella | fa435ea | 2023-09-05 14:33:29 -0400 | [diff] [blame] | 122 | |
| 123 | /* FF-A v1.2 */ |
Raghu Krishnamurthy | 435f11c | 2022-12-25 13:02:00 -0800 | [diff] [blame] | 124 | #define FFA_FNUM_PARTITION_INFO_GET_REGS U(0x8B) |
Madhukar Pappireddy | 41416cc | 2023-03-02 16:04:38 -0600 | [diff] [blame] | 125 | #define FFA_FNUM_EL3_INTR_HANDLE U(0x8C) |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 126 | |
Shruti Gupta | a5a1cbd | 2023-01-19 21:50:55 +0000 | [diff] [blame] | 127 | #define FFA_FNUM_CONSOLE_LOG U(0x8A) |
| 128 | |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 129 | /* FFA SMC32 FIDs */ |
| 130 | #define FFA_ERROR FFA_FID(SMC_32, FFA_FNUM_ERROR) |
| 131 | #define FFA_SUCCESS_SMC32 FFA_FID(SMC_32, FFA_FNUM_SUCCESS) |
| 132 | #define FFA_INTERRUPT FFA_FID(SMC_32, FFA_FNUM_INTERRUPT) |
| 133 | #define FFA_VERSION FFA_FID(SMC_32, FFA_FNUM_VERSION) |
| 134 | #define FFA_FEATURES FFA_FID(SMC_32, FFA_FNUM_FEATURES) |
| 135 | #define FFA_RX_RELEASE FFA_FID(SMC_32, FFA_FNUM_RX_RELEASE) |
Federico Recanati | 5c7c5c4 | 2022-03-18 10:30:00 +0100 | [diff] [blame] | 136 | #define FFA_RX_ACQUIRE FFA_FID(SMC_32, FFA_FNUM_RX_ACQUIRE) |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 137 | #define FFA_RXTX_MAP_SMC32 FFA_FID(SMC_32, FFA_FNUM_RXTX_MAP) |
| 138 | #define FFA_RXTX_UNMAP FFA_FID(SMC_32, FFA_FNUM_RXTX_UNMAP) |
| 139 | #define FFA_PARTITION_INFO_GET FFA_FID(SMC_32, FFA_FNUM_PARTITION_INFO_GET) |
| 140 | #define FFA_ID_GET FFA_FID(SMC_32, FFA_FNUM_ID_GET) |
| 141 | #define FFA_MSG_POLL FFA_FID(SMC_32, FFA_FNUM_MSG_POLL) |
| 142 | #define FFA_MSG_WAIT FFA_FID(SMC_32, FFA_FNUM_MSG_WAIT) |
| 143 | #define FFA_MSG_YIELD FFA_FID(SMC_32, FFA_FNUM_MSG_YIELD) |
| 144 | #define FFA_MSG_RUN FFA_FID(SMC_32, FFA_FNUM_MSG_RUN) |
| 145 | #define FFA_MSG_SEND FFA_FID(SMC_32, FFA_FNUM_MSG_SEND) |
Federico Recanati | eecb4b0 | 2022-02-03 17:22:37 +0100 | [diff] [blame] | 146 | #define FFA_MSG_SEND2 FFA_FID(SMC_32, FFA_FNUM_MSG_SEND2) |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 147 | #define FFA_MSG_SEND_DIRECT_REQ_SMC32 \ |
| 148 | FFA_FID(SMC_32, FFA_FNUM_MSG_SEND_DIRECT_REQ) |
| 149 | #define FFA_MSG_SEND_DIRECT_RESP_SMC32 \ |
| 150 | FFA_FID(SMC_32, FFA_FNUM_MSG_SEND_DIRECT_RESP) |
| 151 | #define FFA_MEM_DONATE_SMC32 FFA_FID(SMC_32, FFA_FNUM_MEM_DONATE) |
| 152 | #define FFA_MEM_LEND_SMC32 FFA_FID(SMC_32, FFA_FNUM_MEM_LEND) |
| 153 | #define FFA_MEM_SHARE_SMC32 FFA_FID(SMC_32, FFA_FNUM_MEM_SHARE) |
| 154 | #define FFA_MEM_RETRIEVE_REQ_SMC32 \ |
| 155 | FFA_FID(SMC_32, FFA_FNUM_MEM_RETRIEVE_REQ) |
| 156 | #define FFA_MEM_RETRIEVE_RESP FFA_FID(SMC_32, FFA_FNUM_MEM_RETRIEVE_RESP) |
| 157 | #define FFA_MEM_RELINQUISH FFA_FID(SMC_32, FFA_FNUM_MEM_RELINQUISH) |
| 158 | #define FFA_MEM_RECLAIM FFA_FID(SMC_32, FFA_FNUM_MEM_RECLAIM) |
J-Alves | 2621cfd | 2021-03-11 17:46:47 +0000 | [diff] [blame] | 159 | #define FFA_NOTIFICATION_BITMAP_CREATE \ |
| 160 | FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_BITMAP_CREATE) |
| 161 | #define FFA_NOTIFICATION_BITMAP_DESTROY \ |
| 162 | FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_BITMAP_DESTROY) |
| 163 | #define FFA_NOTIFICATION_BIND FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_BIND) |
| 164 | #define FFA_NOTIFICATION_UNBIND FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_UNBIND) |
| 165 | #define FFA_NOTIFICATION_SET FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_SET) |
| 166 | #define FFA_NOTIFICATION_GET FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_GET) |
| 167 | #define FFA_NOTIFICATION_INFO_GET \ |
| 168 | FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_INFO_GET) |
Marc Bonnici | 9fa01e9 | 2021-09-23 09:44:14 +0100 | [diff] [blame] | 169 | #define FFA_MEM_FRAG_RX FFA_FID(SMC_32, FFA_FNUM_MEM_FRAG_RX) |
| 170 | #define FFA_MEM_FRAG_TX FFA_FID(SMC_32, FFA_FNUM_MEM_FRAG_TX) |
Daniel Boulby | 27f35df | 2021-02-03 12:13:19 +0000 | [diff] [blame] | 171 | #define FFA_SPM_ID_GET FFA_FID(SMC_32, FFA_FNUM_SPM_ID_GET) |
Olivier Deprez | a664c49 | 2020-08-05 11:27:42 +0200 | [diff] [blame] | 172 | #define FFA_NORMAL_WORLD_RESUME FFA_FID(SMC_32, FFA_FNUM_NORMAL_WORLD_RESUME) |
Madhukar Pappireddy | 41416cc | 2023-03-02 16:04:38 -0600 | [diff] [blame] | 173 | #define FFA_EL3_INTR_HANDLE FFA_FID(SMC_32, FFA_FNUM_EL3_INTR_HANDLE) |
Nishant Sharma | 789052c | 2022-03-25 23:52:34 +0000 | [diff] [blame] | 174 | #define FFA_MEM_PERM_GET FFA_FID(SMC_32, FFA_FNUM_MEM_PERM_GET) |
| 175 | #define FFA_MEM_PERM_SET FFA_FID(SMC_32, FFA_FNUM_MEM_PERM_SET) |
Shruti Gupta | a5a1cbd | 2023-01-19 21:50:55 +0000 | [diff] [blame] | 176 | #define FFA_CONSOLE_LOG_SMC32 FFA_FID(SMC_32, FFA_FNUM_CONSOLE_LOG) |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 177 | |
| 178 | /* FFA SMC64 FIDs */ |
Olivier Deprez | eae4596 | 2021-01-19 15:06:47 +0100 | [diff] [blame] | 179 | #define FFA_ERROR_SMC64 FFA_FID(SMC_64, FFA_FNUM_ERROR) |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 180 | #define FFA_SUCCESS_SMC64 FFA_FID(SMC_64, FFA_FNUM_SUCCESS) |
| 181 | #define FFA_RXTX_MAP_SMC64 FFA_FID(SMC_64, FFA_FNUM_RXTX_MAP) |
| 182 | #define FFA_MSG_SEND_DIRECT_REQ_SMC64 \ |
| 183 | FFA_FID(SMC_64, FFA_FNUM_MSG_SEND_DIRECT_REQ) |
| 184 | #define FFA_MSG_SEND_DIRECT_RESP_SMC64 \ |
| 185 | FFA_FID(SMC_64, FFA_FNUM_MSG_SEND_DIRECT_RESP) |
| 186 | #define FFA_MEM_DONATE_SMC64 FFA_FID(SMC_64, FFA_FNUM_MEM_DONATE) |
| 187 | #define FFA_MEM_LEND_SMC64 FFA_FID(SMC_64, FFA_FNUM_MEM_LEND) |
| 188 | #define FFA_MEM_SHARE_SMC64 FFA_FID(SMC_64, FFA_FNUM_MEM_SHARE) |
| 189 | #define FFA_MEM_RETRIEVE_REQ_SMC64 \ |
| 190 | FFA_FID(SMC_64, FFA_FNUM_MEM_RETRIEVE_REQ) |
Olivier Deprez | eae4596 | 2021-01-19 15:06:47 +0100 | [diff] [blame] | 191 | #define FFA_SECONDARY_EP_REGISTER_SMC64 \ |
| 192 | FFA_FID(SMC_64, FFA_FNUM_SECONDARY_EP_REGISTER) |
J-Alves | 2621cfd | 2021-03-11 17:46:47 +0000 | [diff] [blame] | 193 | #define FFA_NOTIFICATION_INFO_GET_SMC64 \ |
| 194 | FFA_FID(SMC_64, FFA_FNUM_NOTIFICATION_INFO_GET) |
Raghu Krishnamurthy | 435f11c | 2022-12-25 13:02:00 -0800 | [diff] [blame] | 195 | #define FFA_PARTITION_INFO_GET_REGS_SMC64 \ |
| 196 | FFA_FID(SMC_64, FFA_FNUM_PARTITION_INFO_GET_REGS) |
Shruti Gupta | a5a1cbd | 2023-01-19 21:50:55 +0000 | [diff] [blame] | 197 | #define FFA_CONSOLE_LOG_SMC64 FFA_FID(SMC_64, FFA_FNUM_CONSOLE_LOG) |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 198 | |
| 199 | /* |
Marc Bonnici | 9a29704 | 2022-02-14 17:06:09 +0000 | [diff] [blame] | 200 | * FF-A partition properties values. |
| 201 | */ |
| 202 | #define FFA_PARTITION_DIRECT_REQ_RECV U(1 << 0) |
| 203 | #define FFA_PARTITION_DIRECT_REQ_SEND U(1 << 1) |
| 204 | #define FFA_PARTITION_INDIRECT_MSG U(1 << 2) |
| 205 | |
| 206 | /* |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 207 | * Reserve a special value for traffic targeted to the Hypervisor or SPM. |
| 208 | */ |
| 209 | #define FFA_TARGET_INFO_MBZ U(0x0) |
| 210 | |
| 211 | /* |
| 212 | * Reserve a special value for MBZ parameters. |
| 213 | */ |
| 214 | #define FFA_PARAM_MBZ U(0x0) |
| 215 | |
Olivier Deprez | ebc3477 | 2020-04-16 16:59:21 +0200 | [diff] [blame] | 216 | /* |
| 217 | * Maximum FF-A endpoint id value |
| 218 | */ |
| 219 | #define FFA_ENDPOINT_ID_MAX U(1 << 16) |
| 220 | |
| 221 | /* |
Marc Bonnici | 8e1a755 | 2021-12-01 17:57:04 +0000 | [diff] [blame] | 222 | * Reserve endpoint id for the SPMD. |
| 223 | */ |
| 224 | #define SPMD_DIRECT_MSG_ENDPOINT_ID U(FFA_ENDPOINT_ID_MAX - 1) |
| 225 | |
| 226 | /* Mask and shift to check valid secure FF-A Endpoint ID. */ |
| 227 | #define SPMC_SECURE_ID_MASK U(1) |
| 228 | #define SPMC_SECURE_ID_SHIFT U(15) |
| 229 | |
| 230 | /* |
Marc Bonnici | 37dd8e1 | 2021-08-17 18:00:07 +0100 | [diff] [blame] | 231 | * Partition Count Flag in FFA_PARTITION_INFO_GET. |
| 232 | */ |
| 233 | #define FFA_PARTITION_INFO_GET_COUNT_FLAG_MASK U(1 << 0) |
| 234 | |
| 235 | /* |
Olivier Deprez | ebc3477 | 2020-04-16 16:59:21 +0200 | [diff] [blame] | 236 | * Mask for source and destination endpoint id in |
| 237 | * a direct message request/response. |
| 238 | */ |
| 239 | #define FFA_DIRECT_MSG_ENDPOINT_ID_MASK U(0xffff) |
| 240 | |
| 241 | /* |
| 242 | * Bit shift for destination endpoint id in a direct message request/response. |
| 243 | */ |
| 244 | #define FFA_DIRECT_MSG_DESTINATION_SHIFT U(0) |
| 245 | |
| 246 | /* |
| 247 | * Bit shift for source endpoint id in a direct message request/response. |
| 248 | */ |
| 249 | #define FFA_DIRECT_MSG_SOURCE_SHIFT U(16) |
| 250 | |
| 251 | /****************************************************************************** |
| 252 | * ffa_endpoint_destination |
| 253 | *****************************************************************************/ |
| 254 | static inline uint16_t ffa_endpoint_destination(unsigned int ep) |
| 255 | { |
| 256 | return (ep >> FFA_DIRECT_MSG_DESTINATION_SHIFT) & |
| 257 | FFA_DIRECT_MSG_ENDPOINT_ID_MASK; |
| 258 | } |
| 259 | |
| 260 | /****************************************************************************** |
| 261 | * ffa_endpoint_source |
| 262 | *****************************************************************************/ |
| 263 | static inline uint16_t ffa_endpoint_source(unsigned int ep) |
| 264 | { |
| 265 | return (ep >> FFA_DIRECT_MSG_SOURCE_SHIFT) & |
| 266 | FFA_DIRECT_MSG_ENDPOINT_ID_MASK; |
| 267 | } |
| 268 | |
Marc Bonnici | 8e1a755 | 2021-12-01 17:57:04 +0000 | [diff] [blame] | 269 | /****************************************************************************** |
| 270 | * FF-A helper functions to determine partition ID world. |
| 271 | *****************************************************************************/ |
| 272 | |
| 273 | /* |
| 274 | * Determine if provided ID is in the secure world. |
| 275 | */ |
| 276 | static inline bool ffa_is_secure_world_id(uint16_t id) |
| 277 | { |
| 278 | return ((id >> SPMC_SECURE_ID_SHIFT) & SPMC_SECURE_ID_MASK) == 1; |
| 279 | } |
| 280 | |
| 281 | /* |
| 282 | * Determine if provided ID is in the normal world. |
| 283 | */ |
| 284 | static inline bool ffa_is_normal_world_id(uint16_t id) |
| 285 | { |
| 286 | return !ffa_is_secure_world_id(id); |
| 287 | } |
| 288 | |
Achin Gupta | eaf1716 | 2021-10-19 12:21:16 +0100 | [diff] [blame] | 289 | |
| 290 | /****************************************************************************** |
| 291 | * Boot information protocol as per the FF-A v1.1 spec. |
| 292 | *****************************************************************************/ |
| 293 | #define FFA_INIT_DESC_SIGNATURE 0x00000FFA |
| 294 | |
| 295 | /* Boot information type. */ |
| 296 | #define FFA_BOOT_INFO_TYPE_STD U(0x0) |
| 297 | #define FFA_BOOT_INFO_TYPE_IMPL U(0x1) |
| 298 | |
| 299 | #define FFA_BOOT_INFO_TYPE_MASK U(0x1) |
| 300 | #define FFA_BOOT_INFO_TYPE_SHIFT U(0x7) |
| 301 | #define FFA_BOOT_INFO_TYPE(type) \ |
| 302 | (((type) & FFA_BOOT_INFO_TYPE_MASK) \ |
| 303 | << FFA_BOOT_INFO_TYPE_SHIFT) |
| 304 | |
| 305 | /* Boot information identifier. */ |
| 306 | #define FFA_BOOT_INFO_TYPE_ID_FDT U(0x0) |
| 307 | #define FFA_BOOT_INFO_TYPE_ID_HOB U(0x1) |
| 308 | |
| 309 | #define FFA_BOOT_INFO_TYPE_ID_MASK U(0x3F) |
| 310 | #define FFA_BOOT_INFO_TYPE_ID_SHIFT U(0x0) |
| 311 | #define FFA_BOOT_INFO_TYPE_ID(type) \ |
| 312 | (((type) & FFA_BOOT_INFO_TYPE_ID_MASK) \ |
| 313 | << FFA_BOOT_INFO_TYPE_ID_SHIFT) |
| 314 | |
| 315 | /* Format of Flags Name field. */ |
| 316 | #define FFA_BOOT_INFO_FLAG_NAME_STRING U(0x0) |
| 317 | #define FFA_BOOT_INFO_FLAG_NAME_UUID U(0x1) |
| 318 | |
| 319 | #define FFA_BOOT_INFO_FLAG_NAME_MASK U(0x3) |
| 320 | #define FFA_BOOT_INFO_FLAG_NAME_SHIFT U(0x0) |
| 321 | #define FFA_BOOT_INFO_FLAG_NAME(type) \ |
| 322 | (((type) & FFA_BOOT_INFO_FLAG_NAME_MASK)\ |
| 323 | << FFA_BOOT_INFO_FLAG_NAME_SHIFT) |
| 324 | |
| 325 | /* Format of Flags Contents field. */ |
| 326 | #define FFA_BOOT_INFO_FLAG_CONTENT_ADR U(0x0) |
| 327 | #define FFA_BOOT_INFO_FLAG_CONTENT_VAL U(0x1) |
| 328 | |
| 329 | #define FFA_BOOT_INFO_FLAG_CONTENT_MASK U(0x1) |
| 330 | #define FFA_BOOT_INFO_FLAG_CONTENT_SHIFT U(0x2) |
| 331 | #define FFA_BOOT_INFO_FLAG_CONTENT(content) \ |
| 332 | (((content) & FFA_BOOT_INFO_FLAG_CONTENT_MASK) \ |
| 333 | << FFA_BOOT_INFO_FLAG_CONTENT_SHIFT) |
| 334 | |
| 335 | /* Boot information descriptor. */ |
| 336 | struct ffa_boot_info_desc { |
| 337 | uint8_t name[16]; |
| 338 | uint8_t type; |
| 339 | uint8_t reserved; |
| 340 | uint16_t flags; |
| 341 | uint32_t size_boot_info; |
| 342 | uint64_t content; |
| 343 | }; |
| 344 | |
| 345 | /* Boot information header. */ |
| 346 | struct ffa_boot_info_header { |
| 347 | uint32_t signature; /* 0xFFA */ |
| 348 | uint32_t version; |
| 349 | uint32_t size_boot_info_blob; |
| 350 | uint32_t size_boot_info_desc; |
| 351 | uint32_t count_boot_info_desc; |
| 352 | uint32_t offset_boot_info_desc; |
| 353 | uint64_t reserved; |
| 354 | }; |
| 355 | |
Raghu Krishnamurthy | 2b7b584 | 2023-04-22 11:21:58 -0700 | [diff] [blame] | 356 | /* FF-A Partition Info Get related macros. */ |
| 357 | #define FFA_PARTITION_INFO_GET_PROPERTIES_V1_0_MASK U(0x7) |
| 358 | #define FFA_PARTITION_INFO_GET_EXEC_STATE_SHIFT U(8) |
| 359 | #define FFA_PARTITION_INFO_GET_AARCH32_STATE U(0) |
| 360 | #define FFA_PARTITION_INFO_GET_AARCH64_STATE U(1) |
| 361 | |
| 362 | /** |
| 363 | * Holds information returned for each partition by the FFA_PARTITION_INFO_GET |
| 364 | * interface. |
| 365 | */ |
| 366 | struct ffa_partition_info_v1_0 { |
| 367 | uint16_t ep_id; |
| 368 | uint16_t execution_ctx_count; |
| 369 | uint32_t properties; |
| 370 | }; |
| 371 | |
| 372 | /* Extended structure for FF-A v1.1. */ |
| 373 | struct ffa_partition_info_v1_1 { |
| 374 | uint16_t ep_id; |
| 375 | uint16_t execution_ctx_count; |
| 376 | uint32_t properties; |
| 377 | uint32_t uuid[4]; |
| 378 | }; |
| 379 | |
J-Alves | 2672cde | 2020-05-07 18:42:25 +0100 | [diff] [blame] | 380 | #endif /* FFA_SVC_H */ |