Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
Manish V Badarkhe | 82e1a25 | 2022-01-04 13:45:31 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2022, Arm Limited. All rights reserved. |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
J-Alves | d708c03 | 2020-11-19 12:14:21 +0000 | [diff] [blame] | 7 | #ifndef TEST_HELPERS_H__ |
| 8 | #define TEST_HELPERS_H__ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 9 | |
Joel Hutton | 8790f02 | 2019-03-15 14:47:02 +0000 | [diff] [blame] | 10 | #include <arch_features.h> |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 11 | #include <ffa_svc.h> |
J-Alves | d56c53c | 2021-07-01 16:32:16 +0100 | [diff] [blame] | 12 | #include <events.h> |
J-Alves | f7535f4 | 2021-07-30 11:58:41 +0100 | [diff] [blame] | 13 | #include <plat_topology.h> |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 14 | #include <psci.h> |
Max Shvetsov | 103e056 | 2021-02-04 16:58:31 +0000 | [diff] [blame] | 15 | #include <spm_common.h> |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 16 | #include <tftf_lib.h> |
| 17 | #include <trusted_os.h> |
| 18 | #include <tsp.h> |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 19 | #include <uuid_utils.h> |
Max Shvetsov | 103e056 | 2021-02-04 16:58:31 +0000 | [diff] [blame] | 20 | #include <uuid.h> |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 21 | |
| 22 | typedef struct { |
| 23 | uintptr_t addr; |
| 24 | size_t size; |
| 25 | unsigned int attr; |
| 26 | void *arg; |
| 27 | } map_args_unmap_t; |
| 28 | |
| 29 | typedef test_result_t (*test_function_arg_t)(void *arg); |
| 30 | |
Deepika Bhavnani | c249d5e | 2020-02-06 16:29:45 -0600 | [diff] [blame] | 31 | #ifndef __aarch64__ |
Joel Hutton | 8790f02 | 2019-03-15 14:47:02 +0000 | [diff] [blame] | 32 | #define SKIP_TEST_IF_AARCH32() \ |
| 33 | do { \ |
| 34 | tftf_testcase_printf("Test not supported on aarch32\n"); \ |
| 35 | return TEST_RESULT_SKIPPED; \ |
| 36 | } while (0) |
| 37 | #else |
| 38 | #define SKIP_TEST_IF_AARCH32() |
| 39 | #endif |
| 40 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 41 | #define SKIP_TEST_IF_LESS_THAN_N_CLUSTERS(n) \ |
| 42 | do { \ |
| 43 | unsigned int clusters_cnt; \ |
| 44 | clusters_cnt = tftf_get_total_clusters_count(); \ |
| 45 | if (clusters_cnt < (n)) { \ |
| 46 | tftf_testcase_printf( \ |
| 47 | "Need at least %u clusters, only found %u\n", \ |
| 48 | (n), clusters_cnt); \ |
| 49 | return TEST_RESULT_SKIPPED; \ |
| 50 | } \ |
| 51 | } while (0) |
| 52 | |
| 53 | #define SKIP_TEST_IF_LESS_THAN_N_CPUS(n) \ |
| 54 | do { \ |
| 55 | unsigned int cpus_cnt; \ |
| 56 | cpus_cnt = tftf_get_total_cpus_count(); \ |
| 57 | if (cpus_cnt < (n)) { \ |
| 58 | tftf_testcase_printf( \ |
| 59 | "Need at least %u CPUs, only found %u\n", \ |
| 60 | (n), cpus_cnt); \ |
| 61 | return TEST_RESULT_SKIPPED; \ |
| 62 | } \ |
| 63 | } while (0) |
| 64 | |
| 65 | #define SKIP_TEST_IF_TRUSTED_OS_NOT_PRESENT() \ |
| 66 | do { \ |
| 67 | uuid_t tos_uuid; \ |
| 68 | \ |
| 69 | if (!is_trusted_os_present(&tos_uuid)) { \ |
| 70 | tftf_testcase_printf("No Trusted OS detected\n"); \ |
| 71 | return TEST_RESULT_SKIPPED; \ |
| 72 | } \ |
| 73 | } while (0) |
| 74 | |
| 75 | #define SKIP_TEST_IF_TSP_NOT_PRESENT() \ |
| 76 | do { \ |
| 77 | uuid_t tos_uuid; \ |
| 78 | char tos_uuid_str[UUID_STR_SIZE]; \ |
| 79 | \ |
| 80 | if (!is_trusted_os_present(&tos_uuid)) { \ |
| 81 | tftf_testcase_printf("No Trusted OS detected\n"); \ |
| 82 | return TEST_RESULT_SKIPPED; \ |
| 83 | } \ |
| 84 | \ |
| 85 | if (!uuid_equal(&tos_uuid, &tsp_uuid)) { \ |
| 86 | tftf_testcase_printf( \ |
| 87 | "Trusted OS is not the TSP, its UUID is: %s\n", \ |
| 88 | uuid_to_str(&tos_uuid, tos_uuid_str)); \ |
| 89 | return TEST_RESULT_SKIPPED; \ |
| 90 | } \ |
| 91 | } while (0) |
| 92 | |
Daniel Boulby | 0e4629f | 2021-10-26 14:01:23 +0100 | [diff] [blame] | 93 | #define SKIP_TEST_IF_DIT_NOT_SUPPORTED() \ |
| 94 | do { \ |
| 95 | if (!is_armv8_4_dit_present()) { \ |
| 96 | tftf_testcase_printf( \ |
| 97 | "DIT not supported\n"); \ |
| 98 | return TEST_RESULT_SKIPPED; \ |
| 99 | } \ |
| 100 | } while (0) |
| 101 | |
Joel Hutton | 8790f02 | 2019-03-15 14:47:02 +0000 | [diff] [blame] | 102 | #define SKIP_TEST_IF_PAUTH_NOT_SUPPORTED() \ |
| 103 | do { \ |
| 104 | if (!is_armv8_3_pauth_present()) { \ |
| 105 | tftf_testcase_printf( \ |
| 106 | "Pointer Authentication not supported\n"); \ |
| 107 | return TEST_RESULT_SKIPPED; \ |
| 108 | } \ |
| 109 | } while (0) |
| 110 | |
Jimmy Brisson | 90f1d5c | 2020-04-16 10:54:51 -0500 | [diff] [blame] | 111 | #define SKIP_TEST_IF_FGT_NOT_SUPPORTED() \ |
| 112 | do { \ |
| 113 | if (!is_armv8_6_fgt_present()) { \ |
| 114 | tftf_testcase_printf( \ |
| 115 | "Fine Grained Traps not supported\n"); \ |
| 116 | return TEST_RESULT_SKIPPED; \ |
| 117 | } \ |
| 118 | } while (0) |
| 119 | |
Max Shvetsov | 959be33 | 2021-03-16 14:18:13 +0000 | [diff] [blame] | 120 | #define SKIP_TEST_IF_SVE_NOT_SUPPORTED() \ |
| 121 | do { \ |
| 122 | if (!is_armv8_2_sve_present()) { \ |
| 123 | tftf_testcase_printf("SVE not supported\n"); \ |
| 124 | return TEST_RESULT_SKIPPED; \ |
| 125 | } \ |
| 126 | } while (0) |
| 127 | |
Jimmy Brisson | 945095a | 2020-04-16 10:54:59 -0500 | [diff] [blame] | 128 | #define SKIP_TEST_IF_ECV_NOT_SELF_SYNC() \ |
| 129 | do { \ |
| 130 | if (get_armv8_6_ecv_support() != \ |
| 131 | ID_AA64MMFR0_EL1_ECV_SELF_SYNCH) { \ |
| 132 | tftf_testcase_printf("ARMv8.6-ECV not supported\n"); \ |
| 133 | return TEST_RESULT_SKIPPED; \ |
| 134 | } \ |
| 135 | } while (0) |
| 136 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 137 | #define SKIP_TEST_IF_MM_NOT_PRESENT() \ |
| 138 | do { \ |
| 139 | smc_args version_smc = { MM_VERSION_AARCH32 }; \ |
| 140 | smc_ret_values smc_ret = tftf_smc(&version_smc); \ |
| 141 | uint32_t version = smc_ret.ret0; \ |
| 142 | \ |
| 143 | if (version == (uint32_t) SMC_UNKNOWN) { \ |
| 144 | tftf_testcase_printf("SPM not detected.\n"); \ |
| 145 | return TEST_RESULT_SKIPPED; \ |
| 146 | } \ |
| 147 | } while (0) |
| 148 | |
Sandrine Bailleux | 277fb76 | 2019-10-08 12:10:45 +0200 | [diff] [blame] | 149 | #define SKIP_TEST_IF_MTE_SUPPORT_LESS_THAN(n) \ |
| 150 | do { \ |
| 151 | if (get_armv8_5_mte_support() < (n)) { \ |
| 152 | tftf_testcase_printf( \ |
| 153 | "Memory Tagging Extension not supported\n"); \ |
| 154 | return TEST_RESULT_SKIPPED; \ |
| 155 | } \ |
| 156 | } while (0) |
| 157 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 158 | #define SKIP_TEST_IF_MM_VERSION_LESS_THAN(major, minor) \ |
| 159 | do { \ |
| 160 | smc_args version_smc = { MM_VERSION_AARCH32 }; \ |
| 161 | smc_ret_values smc_ret = tftf_smc(&version_smc); \ |
| 162 | uint32_t version = smc_ret.ret0; \ |
| 163 | \ |
| 164 | if (version == (uint32_t) SMC_UNKNOWN) { \ |
| 165 | tftf_testcase_printf("SPM not detected.\n"); \ |
| 166 | return TEST_RESULT_SKIPPED; \ |
| 167 | } \ |
| 168 | \ |
| 169 | if (version < MM_VERSION_FORM(major, minor)) { \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 170 | tftf_testcase_printf("MM_VERSION returned %u.%u\n" \ |
| 171 | "The required version is %u.%u\n", \ |
| 172 | version >> MM_VERSION_MAJOR_SHIFT, \ |
| 173 | version & MM_VERSION_MINOR_MASK, \ |
| 174 | major, minor); \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 175 | return TEST_RESULT_SKIPPED; \ |
| 176 | } \ |
| 177 | \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 178 | VERBOSE("MM_VERSION returned %u.%u\n", \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 179 | version >> MM_VERSION_MAJOR_SHIFT, \ |
| 180 | version & MM_VERSION_MINOR_MASK); \ |
| 181 | } while (0) |
| 182 | |
J-Alves | 7581c38 | 2020-05-07 18:34:20 +0100 | [diff] [blame] | 183 | #define SKIP_TEST_IF_FFA_VERSION_LESS_THAN(major, minor) \ |
Antonio Nino Diaz | 652d20a | 2018-12-10 17:17:33 +0000 | [diff] [blame] | 184 | do { \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 185 | smc_ret_values smc_ret = ffa_version( \ |
| 186 | MAKE_FFA_VERSION(major, minor)); \ |
| 187 | uint32_t version = smc_ret.ret0; \ |
Antonio Nino Diaz | 652d20a | 2018-12-10 17:17:33 +0000 | [diff] [blame] | 188 | \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 189 | if (version == FFA_ERROR_NOT_SUPPORTED) { \ |
| 190 | tftf_testcase_printf("FFA_VERSION not supported.\n"); \ |
Antonio Nino Diaz | 652d20a | 2018-12-10 17:17:33 +0000 | [diff] [blame] | 191 | return TEST_RESULT_SKIPPED; \ |
| 192 | } \ |
| 193 | \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 194 | if ((version & FFA_VERSION_BIT31_MASK) != 0U) { \ |
| 195 | tftf_testcase_printf("FFA_VERSION bad response: %x\n", \ |
| 196 | version); \ |
| 197 | return TEST_RESULT_FAIL; \ |
| 198 | } \ |
| 199 | \ |
| 200 | if (version < MAKE_FFA_VERSION(major, minor)) { \ |
| 201 | tftf_testcase_printf("FFA_VERSION returned %u.%u\n" \ |
| 202 | "The required version is %u.%u\n", \ |
| 203 | version >> FFA_VERSION_MAJOR_SHIFT, \ |
| 204 | version & FFA_VERSION_MINOR_MASK, \ |
| 205 | major, minor); \ |
Antonio Nino Diaz | 652d20a | 2018-12-10 17:17:33 +0000 | [diff] [blame] | 206 | return TEST_RESULT_SKIPPED; \ |
| 207 | } \ |
| 208 | } while (0) |
| 209 | |
Petre-Ionut Tudor | f68ebdb | 2019-09-18 16:13:00 +0100 | [diff] [blame] | 210 | #define SKIP_TEST_IF_ARCH_DEBUG_VERSION_LESS_THAN(version) \ |
| 211 | do { \ |
Petre-Ionut Tudor | f1a45f7 | 2019-10-08 16:51:45 +0100 | [diff] [blame] | 212 | uint32_t debug_ver = arch_get_debug_version(); \ |
Petre-Ionut Tudor | f68ebdb | 2019-09-18 16:13:00 +0100 | [diff] [blame] | 213 | \ |
Petre-Ionut Tudor | f1a45f7 | 2019-10-08 16:51:45 +0100 | [diff] [blame] | 214 | if (debug_ver < version) { \ |
Petre-Ionut Tudor | f68ebdb | 2019-09-18 16:13:00 +0100 | [diff] [blame] | 215 | tftf_testcase_printf("Debug version returned %d\n" \ |
| 216 | "The required version is %d\n", \ |
Petre-Ionut Tudor | f1a45f7 | 2019-10-08 16:51:45 +0100 | [diff] [blame] | 217 | debug_ver, \ |
Petre-Ionut Tudor | f68ebdb | 2019-09-18 16:13:00 +0100 | [diff] [blame] | 218 | version); \ |
| 219 | return TEST_RESULT_SKIPPED; \ |
| 220 | } \ |
| 221 | } while (0) |
| 222 | |
J-Alves | d708c03 | 2020-11-19 12:14:21 +0000 | [diff] [blame] | 223 | #define SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, ffa_uuid) \ |
J-Alves | f474306 | 2020-10-27 19:39:57 +0000 | [diff] [blame] | 224 | do { \ |
J-Alves | f474306 | 2020-10-27 19:39:57 +0000 | [diff] [blame] | 225 | smc_ret_values smc_ret = ffa_partition_info_get(ffa_uuid); \ |
| 226 | ffa_rx_release(); \ |
Olivier Deprez | 58757e8 | 2021-07-30 10:18:00 +0200 | [diff] [blame] | 227 | if (ffa_func_id(smc_ret) == FFA_ERROR && \ |
| 228 | ffa_error_code(smc_ret) == FFA_ERROR_INVALID_PARAMETER) { \ |
J-Alves | f474306 | 2020-10-27 19:39:57 +0000 | [diff] [blame] | 229 | tftf_testcase_printf("FFA endpoint not deployed!\n"); \ |
| 230 | return TEST_RESULT_SKIPPED; \ |
| 231 | } else if (smc_ret.ret0 != FFA_SUCCESS_SMC32) { \ |
| 232 | ERROR("ffa_partition_info_get failed!\n"); \ |
| 233 | return TEST_RESULT_FAIL; \ |
| 234 | } \ |
| 235 | } while (0) |
| 236 | |
J-Alves | d708c03 | 2020-11-19 12:14:21 +0000 | [diff] [blame] | 237 | #define GET_TFTF_MAILBOX(mb) \ |
| 238 | do { \ |
| 239 | if (!get_tftf_mailbox(&mb)) { \ |
| 240 | ERROR("Mailbox not configured!\nThis test relies on" \ |
| 241 | " test suite \"FF-A RXTX Mapping\" to map/configure" \ |
| 242 | " RXTX buffers\n"); \ |
| 243 | return TEST_RESULT_FAIL; \ |
| 244 | } \ |
| 245 | } while (false); |
| 246 | |
J-Alves | 0446930 | 2021-01-21 14:48:13 +0000 | [diff] [blame] | 247 | #define CHECK_SPMC_TESTING_SETUP(ffa_major, ffa_minor, expected_uuids) \ |
J-Alves | d708c03 | 2020-11-19 12:14:21 +0000 | [diff] [blame] | 248 | do { \ |
Max Shvetsov | 959be33 | 2021-03-16 14:18:13 +0000 | [diff] [blame] | 249 | SKIP_TEST_IF_AARCH32(); \ |
J-Alves | d708c03 | 2020-11-19 12:14:21 +0000 | [diff] [blame] | 250 | const size_t expected_uuids_size = \ |
| 251 | sizeof(expected_uuids) / sizeof(struct ffa_uuid); \ |
J-Alves | 0446930 | 2021-01-21 14:48:13 +0000 | [diff] [blame] | 252 | test_result_t ret = check_spmc_testing_set_up( \ |
J-Alves | d708c03 | 2020-11-19 12:14:21 +0000 | [diff] [blame] | 253 | ffa_major, ffa_minor, expected_uuids, \ |
| 254 | expected_uuids_size); \ |
| 255 | if (ret != TEST_RESULT_SUCCESS) { \ |
| 256 | return ret; \ |
| 257 | } \ |
| 258 | } while (false); |
| 259 | |
Manish V Badarkhe | 87c03d1 | 2021-07-06 22:57:11 +0100 | [diff] [blame] | 260 | #define SKIP_TEST_IF_TRBE_NOT_SUPPORTED() \ |
| 261 | do { \ |
| 262 | if (!get_armv9_0_trbe_support()) { \ |
| 263 | tftf_testcase_printf("ARMv9-TRBE not supported\n"); \ |
| 264 | return TEST_RESULT_SKIPPED; \ |
| 265 | } \ |
| 266 | } while (false) |
| 267 | |
Manish V Badarkhe | 2c518e5 | 2021-07-08 16:36:57 +0100 | [diff] [blame] | 268 | #define SKIP_TEST_IF_TRF_NOT_SUPPORTED() \ |
| 269 | do { \ |
| 270 | if (!get_armv8_4_trf_support()) { \ |
| 271 | tftf_testcase_printf("ARMv8.4-TRF not supported\n"); \ |
| 272 | return TEST_RESULT_SKIPPED; \ |
| 273 | } \ |
| 274 | } while (false) |
| 275 | |
Manish V Badarkhe | 6d0e1b6 | 2021-07-09 13:58:28 +0100 | [diff] [blame] | 276 | #define SKIP_TEST_IF_SYS_REG_TRACE_NOT_SUPPORTED() \ |
| 277 | do { \ |
| 278 | if (!get_armv8_0_sys_reg_trace_support()) { \ |
| 279 | tftf_testcase_printf("ARMv8-system register" \ |
| 280 | "trace not supported\n"); \ |
| 281 | return TEST_RESULT_SKIPPED; \ |
| 282 | } \ |
| 283 | } while (false) |
| 284 | |
Manish V Badarkhe | 82e1a25 | 2022-01-04 13:45:31 +0000 | [diff] [blame] | 285 | #define SKIP_TEST_IF_AFP_NOT_SUPPORTED() \ |
| 286 | do { \ |
| 287 | if (!get_feat_afp_present()) { \ |
| 288 | tftf_testcase_printf("ARMv8.7-afp not supported"); \ |
| 289 | return TEST_RESULT_SKIPPED; \ |
| 290 | } \ |
| 291 | } while (false) |
| 292 | |
Federico Recanati | 6328fb0 | 2022-01-14 15:48:16 +0100 | [diff] [blame] | 293 | #ifdef __aarch64__ |
Federico Recanati | d3749b0 | 2022-01-14 15:44:45 +0100 | [diff] [blame] | 294 | #define SKIP_TEST_IF_PA_SIZE_LESS_THAN(n) \ |
| 295 | do { \ |
| 296 | static const unsigned int pa_range_bits_arr[] = { \ |
| 297 | PARANGE_0000, PARANGE_0001, PARANGE_0010, PARANGE_0011,\ |
| 298 | PARANGE_0100, PARANGE_0101, PARANGE_0110 \ |
| 299 | }; \ |
| 300 | if (pa_range_bits_arr[get_pa_range()] < n) { \ |
| 301 | tftf_testcase_printf("PA size less than %d bit\n", n); \ |
| 302 | return TEST_RESULT_SKIPPED; \ |
| 303 | } \ |
| 304 | } while (false) |
Federico Recanati | 6328fb0 | 2022-01-14 15:48:16 +0100 | [diff] [blame] | 305 | #else |
| 306 | #define SKIP_TEST_IF_PA_SIZE_LESS_THAN(n) \ |
| 307 | do { \ |
| 308 | return TEST_RESULT_SKIPPED; \ |
| 309 | } while (false) |
| 310 | #endif |
Federico Recanati | d3749b0 | 2022-01-14 15:44:45 +0100 | [diff] [blame] | 311 | |
johpow01 | 8c3da8b | 2022-01-31 18:14:41 -0600 | [diff] [blame^] | 312 | #define SKIP_TEST_IF_BRBE_NOT_SUPPORTED() \ |
| 313 | do { \ |
| 314 | if (!get_feat_brbe_support()) { \ |
| 315 | tftf_testcase_printf("FEAT_BRBE not supported\n"); \ |
| 316 | return TEST_RESULT_SKIPPED; \ |
| 317 | } \ |
| 318 | } while (false) |
| 319 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 320 | /* Helper macro to verify if system suspend API is supported */ |
| 321 | #define is_psci_sys_susp_supported() \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 322 | (tftf_get_psci_feature_info(SMC_PSCI_SYSTEM_SUSPEND) \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 323 | == PSCI_E_SUCCESS) |
| 324 | |
| 325 | /* Helper macro to verify if PSCI_STAT_COUNT API is supported */ |
| 326 | #define is_psci_stat_count_supported() \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 327 | (tftf_get_psci_feature_info(SMC_PSCI_STAT_COUNT) \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 328 | == PSCI_E_SUCCESS) |
| 329 | |
| 330 | /* |
| 331 | * Helper function to verify the system state is ready for system |
| 332 | * suspend. i.e., a single CPU is running and all other CPUs are powered off. |
| 333 | * Returns 1 if the system is ready to suspend, 0 otherwise. |
| 334 | */ |
| 335 | int is_sys_suspend_state_ready(void); |
| 336 | |
| 337 | /* |
| 338 | * Helper function to reset the system. This function shouldn't return. |
| 339 | * It is not marked with __dead to help the test to catch some error in |
| 340 | * TF |
| 341 | */ |
| 342 | void psci_system_reset(void); |
| 343 | |
| 344 | /* |
| 345 | * Helper function that enables/disables the mem_protect mechanism |
| 346 | */ |
| 347 | int psci_mem_protect(int val); |
| 348 | |
| 349 | |
| 350 | /* |
| 351 | * Helper function to call PSCI MEM_PROTECT_CHECK |
| 352 | */ |
| 353 | int psci_mem_protect_check(uintptr_t addr, size_t size); |
| 354 | |
| 355 | |
| 356 | /* |
| 357 | * Helper function to get a sentinel address that can be used to test mem_protect |
| 358 | */ |
| 359 | unsigned char *psci_mem_prot_get_sentinel(void); |
| 360 | |
| 361 | /* |
| 362 | * Helper function to memory map and unmap a region needed by a test. |
| 363 | * |
| 364 | * Return TEST_RESULT_FAIL if the memory could not be successfully mapped or |
| 365 | * unmapped. Otherwise, return the test functions's result. |
| 366 | */ |
| 367 | test_result_t map_test_unmap(const map_args_unmap_t *args, |
| 368 | test_function_arg_t test); |
| 369 | |
J-Alves | f1126f2 | 2020-11-02 17:28:20 +0000 | [diff] [blame] | 370 | /* |
| 371 | * Helper function to set TFTF global mailbox for SPM related tests. |
| 372 | * This function should be invoked by the first TFTF test that requires |
| 373 | * RX and/or TX buffers. |
| 374 | */ |
| 375 | void set_tftf_mailbox(const struct mailbox_buffers *mb); |
| 376 | |
| 377 | /* |
| 378 | * Helper function to get TFTF global mailbox for SPM related tests. |
| 379 | * This function should be called by all tests that require access to RX or TX |
| 380 | * buffers, after the function 'set_tftf_mailbox' has been used by the first |
| 381 | * test to rely on RX and TX buffers. |
| 382 | */ |
| 383 | bool get_tftf_mailbox(struct mailbox_buffers *mb); |
| 384 | |
J-Alves | 0446930 | 2021-01-21 14:48:13 +0000 | [diff] [blame] | 385 | test_result_t check_spmc_testing_set_up(uint32_t ffa_version_major, |
J-Alves | d708c03 | 2020-11-19 12:14:21 +0000 | [diff] [blame] | 386 | uint32_t ffa_version_minor, const struct ffa_uuid *ffa_uuids, |
| 387 | size_t ffa_uuids_size); |
| 388 | |
J-Alves | d56c53c | 2021-07-01 16:32:16 +0100 | [diff] [blame] | 389 | /** |
| 390 | * Turn on all cpus to execute a test in all. |
| 391 | * - 'cpu_on_handler' should have the code containing the test. |
| 392 | * - 'cpu_booted' is used for notifying which cores the test has been executed. |
| 393 | * This should be used in the test executed by cpu_on_handler at the end of |
| 394 | * processing to make sure it complies with this function's implementation. |
| 395 | */ |
| 396 | test_result_t spm_run_multi_core_test(uintptr_t cpu_on_handler, |
| 397 | event_t *cpu_booted); |
| 398 | |
J-Alves | 952e1f7 | 2021-07-30 17:19:09 +0100 | [diff] [blame] | 399 | /** |
J-Alves | 79c08f1 | 2021-10-27 15:15:16 +0100 | [diff] [blame] | 400 | * Call FFA_RUN in the designated SP to make it reach the message loop. |
| 401 | * Used within CPU_ON handlers, to bring up the SP in the current core. |
| 402 | */ |
| 403 | bool spm_core_sp_init(ffa_id_t sp_id); |
| 404 | |
| 405 | /** |
J-Alves | 952e1f7 | 2021-07-30 17:19:09 +0100 | [diff] [blame] | 406 | * Enable/Disable managed exit interrupt for the provided SP. |
| 407 | */ |
| 408 | bool spm_set_managed_exit_int(ffa_id_t sp_id, bool enable); |
| 409 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 410 | #endif /* __TEST_HELPERS_H__ */ |