Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
Jayanth Dodderi Chidanand | b3ffd3c | 2023-02-13 12:15:11 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2023, 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 | f7535f4 | 2021-07-30 11:58:41 +0100 | [diff] [blame] | 11 | #include <plat_topology.h> |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 12 | #include <psci.h> |
Jayanth Dodderi Chidanand | b3ffd3c | 2023-02-13 12:15:11 +0000 | [diff] [blame] | 13 | #include <sme.h> |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 14 | #include <tftf_lib.h> |
| 15 | #include <trusted_os.h> |
| 16 | #include <tsp.h> |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 17 | #include <uuid_utils.h> |
Max Shvetsov | 103e056 | 2021-02-04 16:58:31 +0000 | [diff] [blame] | 18 | #include <uuid.h> |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 19 | |
| 20 | typedef struct { |
| 21 | uintptr_t addr; |
| 22 | size_t size; |
| 23 | unsigned int attr; |
| 24 | void *arg; |
| 25 | } map_args_unmap_t; |
| 26 | |
| 27 | typedef test_result_t (*test_function_arg_t)(void *arg); |
| 28 | |
Deepika Bhavnani | c249d5e | 2020-02-06 16:29:45 -0600 | [diff] [blame] | 29 | #ifndef __aarch64__ |
Joel Hutton | 8790f02 | 2019-03-15 14:47:02 +0000 | [diff] [blame] | 30 | #define SKIP_TEST_IF_AARCH32() \ |
| 31 | do { \ |
| 32 | tftf_testcase_printf("Test not supported on aarch32\n"); \ |
| 33 | return TEST_RESULT_SKIPPED; \ |
| 34 | } while (0) |
| 35 | #else |
| 36 | #define SKIP_TEST_IF_AARCH32() |
| 37 | #endif |
| 38 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 39 | #define SKIP_TEST_IF_LESS_THAN_N_CLUSTERS(n) \ |
| 40 | do { \ |
| 41 | unsigned int clusters_cnt; \ |
| 42 | clusters_cnt = tftf_get_total_clusters_count(); \ |
| 43 | if (clusters_cnt < (n)) { \ |
| 44 | tftf_testcase_printf( \ |
| 45 | "Need at least %u clusters, only found %u\n", \ |
| 46 | (n), clusters_cnt); \ |
| 47 | return TEST_RESULT_SKIPPED; \ |
| 48 | } \ |
| 49 | } while (0) |
| 50 | |
| 51 | #define SKIP_TEST_IF_LESS_THAN_N_CPUS(n) \ |
| 52 | do { \ |
| 53 | unsigned int cpus_cnt; \ |
| 54 | cpus_cnt = tftf_get_total_cpus_count(); \ |
| 55 | if (cpus_cnt < (n)) { \ |
| 56 | tftf_testcase_printf( \ |
| 57 | "Need at least %u CPUs, only found %u\n", \ |
| 58 | (n), cpus_cnt); \ |
| 59 | return TEST_RESULT_SKIPPED; \ |
| 60 | } \ |
| 61 | } while (0) |
| 62 | |
| 63 | #define SKIP_TEST_IF_TRUSTED_OS_NOT_PRESENT() \ |
| 64 | do { \ |
| 65 | uuid_t tos_uuid; \ |
| 66 | \ |
| 67 | if (!is_trusted_os_present(&tos_uuid)) { \ |
| 68 | tftf_testcase_printf("No Trusted OS detected\n"); \ |
| 69 | return TEST_RESULT_SKIPPED; \ |
| 70 | } \ |
| 71 | } while (0) |
| 72 | |
| 73 | #define SKIP_TEST_IF_TSP_NOT_PRESENT() \ |
| 74 | do { \ |
| 75 | uuid_t tos_uuid; \ |
| 76 | char tos_uuid_str[UUID_STR_SIZE]; \ |
| 77 | \ |
| 78 | if (!is_trusted_os_present(&tos_uuid)) { \ |
| 79 | tftf_testcase_printf("No Trusted OS detected\n"); \ |
| 80 | return TEST_RESULT_SKIPPED; \ |
| 81 | } \ |
| 82 | \ |
| 83 | if (!uuid_equal(&tos_uuid, &tsp_uuid)) { \ |
| 84 | tftf_testcase_printf( \ |
| 85 | "Trusted OS is not the TSP, its UUID is: %s\n", \ |
| 86 | uuid_to_str(&tos_uuid, tos_uuid_str)); \ |
| 87 | return TEST_RESULT_SKIPPED; \ |
| 88 | } \ |
| 89 | } while (0) |
| 90 | |
Daniel Boulby | 0e4629f | 2021-10-26 14:01:23 +0100 | [diff] [blame] | 91 | #define SKIP_TEST_IF_DIT_NOT_SUPPORTED() \ |
| 92 | do { \ |
| 93 | if (!is_armv8_4_dit_present()) { \ |
| 94 | tftf_testcase_printf( \ |
| 95 | "DIT not supported\n"); \ |
| 96 | return TEST_RESULT_SKIPPED; \ |
| 97 | } \ |
| 98 | } while (0) |
| 99 | |
Joel Hutton | 8790f02 | 2019-03-15 14:47:02 +0000 | [diff] [blame] | 100 | #define SKIP_TEST_IF_PAUTH_NOT_SUPPORTED() \ |
| 101 | do { \ |
| 102 | if (!is_armv8_3_pauth_present()) { \ |
| 103 | tftf_testcase_printf( \ |
| 104 | "Pointer Authentication not supported\n"); \ |
| 105 | return TEST_RESULT_SKIPPED; \ |
| 106 | } \ |
| 107 | } while (0) |
| 108 | |
Jimmy Brisson | 90f1d5c | 2020-04-16 10:54:51 -0500 | [diff] [blame] | 109 | #define SKIP_TEST_IF_FGT_NOT_SUPPORTED() \ |
| 110 | do { \ |
| 111 | if (!is_armv8_6_fgt_present()) { \ |
| 112 | tftf_testcase_printf( \ |
| 113 | "Fine Grained Traps not supported\n"); \ |
| 114 | return TEST_RESULT_SKIPPED; \ |
| 115 | } \ |
| 116 | } while (0) |
| 117 | |
Max Shvetsov | 959be33 | 2021-03-16 14:18:13 +0000 | [diff] [blame] | 118 | #define SKIP_TEST_IF_SVE_NOT_SUPPORTED() \ |
| 119 | do { \ |
| 120 | if (!is_armv8_2_sve_present()) { \ |
| 121 | tftf_testcase_printf("SVE not supported\n"); \ |
| 122 | return TEST_RESULT_SKIPPED; \ |
| 123 | } \ |
| 124 | } while (0) |
| 125 | |
Jimmy Brisson | 945095a | 2020-04-16 10:54:59 -0500 | [diff] [blame] | 126 | #define SKIP_TEST_IF_ECV_NOT_SELF_SYNC() \ |
| 127 | do { \ |
| 128 | if (get_armv8_6_ecv_support() != \ |
| 129 | ID_AA64MMFR0_EL1_ECV_SELF_SYNCH) { \ |
| 130 | tftf_testcase_printf("ARMv8.6-ECV not supported\n"); \ |
| 131 | return TEST_RESULT_SKIPPED; \ |
| 132 | } \ |
| 133 | } while (0) |
| 134 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 135 | #define SKIP_TEST_IF_MM_NOT_PRESENT() \ |
| 136 | do { \ |
| 137 | smc_args version_smc = { MM_VERSION_AARCH32 }; \ |
| 138 | smc_ret_values smc_ret = tftf_smc(&version_smc); \ |
| 139 | uint32_t version = smc_ret.ret0; \ |
| 140 | \ |
| 141 | if (version == (uint32_t) SMC_UNKNOWN) { \ |
| 142 | tftf_testcase_printf("SPM not detected.\n"); \ |
| 143 | return TEST_RESULT_SKIPPED; \ |
| 144 | } \ |
| 145 | } while (0) |
| 146 | |
Sandrine Bailleux | 277fb76 | 2019-10-08 12:10:45 +0200 | [diff] [blame] | 147 | #define SKIP_TEST_IF_MTE_SUPPORT_LESS_THAN(n) \ |
| 148 | do { \ |
| 149 | if (get_armv8_5_mte_support() < (n)) { \ |
| 150 | tftf_testcase_printf( \ |
| 151 | "Memory Tagging Extension not supported\n"); \ |
| 152 | return TEST_RESULT_SKIPPED; \ |
| 153 | } \ |
| 154 | } while (0) |
| 155 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 156 | #define SKIP_TEST_IF_MM_VERSION_LESS_THAN(major, minor) \ |
| 157 | do { \ |
| 158 | smc_args version_smc = { MM_VERSION_AARCH32 }; \ |
| 159 | smc_ret_values smc_ret = tftf_smc(&version_smc); \ |
| 160 | uint32_t version = smc_ret.ret0; \ |
| 161 | \ |
| 162 | if (version == (uint32_t) SMC_UNKNOWN) { \ |
| 163 | tftf_testcase_printf("SPM not detected.\n"); \ |
| 164 | return TEST_RESULT_SKIPPED; \ |
| 165 | } \ |
| 166 | \ |
| 167 | if (version < MM_VERSION_FORM(major, minor)) { \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 168 | tftf_testcase_printf("MM_VERSION returned %u.%u\n" \ |
| 169 | "The required version is %u.%u\n", \ |
| 170 | version >> MM_VERSION_MAJOR_SHIFT, \ |
| 171 | version & MM_VERSION_MINOR_MASK, \ |
| 172 | major, minor); \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 173 | return TEST_RESULT_SKIPPED; \ |
| 174 | } \ |
| 175 | \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 176 | VERBOSE("MM_VERSION returned %u.%u\n", \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 177 | version >> MM_VERSION_MAJOR_SHIFT, \ |
| 178 | version & MM_VERSION_MINOR_MASK); \ |
| 179 | } while (0) |
| 180 | |
Petre-Ionut Tudor | f68ebdb | 2019-09-18 16:13:00 +0100 | [diff] [blame] | 181 | #define SKIP_TEST_IF_ARCH_DEBUG_VERSION_LESS_THAN(version) \ |
| 182 | do { \ |
Petre-Ionut Tudor | f1a45f7 | 2019-10-08 16:51:45 +0100 | [diff] [blame] | 183 | uint32_t debug_ver = arch_get_debug_version(); \ |
Petre-Ionut Tudor | f68ebdb | 2019-09-18 16:13:00 +0100 | [diff] [blame] | 184 | \ |
Petre-Ionut Tudor | f1a45f7 | 2019-10-08 16:51:45 +0100 | [diff] [blame] | 185 | if (debug_ver < version) { \ |
Petre-Ionut Tudor | f68ebdb | 2019-09-18 16:13:00 +0100 | [diff] [blame] | 186 | tftf_testcase_printf("Debug version returned %d\n" \ |
| 187 | "The required version is %d\n", \ |
Petre-Ionut Tudor | f1a45f7 | 2019-10-08 16:51:45 +0100 | [diff] [blame] | 188 | debug_ver, \ |
Petre-Ionut Tudor | f68ebdb | 2019-09-18 16:13:00 +0100 | [diff] [blame] | 189 | version); \ |
| 190 | return TEST_RESULT_SKIPPED; \ |
| 191 | } \ |
| 192 | } while (0) |
| 193 | |
Manish V Badarkhe | 87c03d1 | 2021-07-06 22:57:11 +0100 | [diff] [blame] | 194 | #define SKIP_TEST_IF_TRBE_NOT_SUPPORTED() \ |
| 195 | do { \ |
| 196 | if (!get_armv9_0_trbe_support()) { \ |
| 197 | tftf_testcase_printf("ARMv9-TRBE not supported\n"); \ |
| 198 | return TEST_RESULT_SKIPPED; \ |
| 199 | } \ |
| 200 | } while (false) |
| 201 | |
Manish V Badarkhe | 2c518e5 | 2021-07-08 16:36:57 +0100 | [diff] [blame] | 202 | #define SKIP_TEST_IF_TRF_NOT_SUPPORTED() \ |
| 203 | do { \ |
| 204 | if (!get_armv8_4_trf_support()) { \ |
| 205 | tftf_testcase_printf("ARMv8.4-TRF not supported\n"); \ |
| 206 | return TEST_RESULT_SKIPPED; \ |
| 207 | } \ |
| 208 | } while (false) |
| 209 | |
Manish V Badarkhe | 6d0e1b6 | 2021-07-09 13:58:28 +0100 | [diff] [blame] | 210 | #define SKIP_TEST_IF_SYS_REG_TRACE_NOT_SUPPORTED() \ |
| 211 | do { \ |
| 212 | if (!get_armv8_0_sys_reg_trace_support()) { \ |
| 213 | tftf_testcase_printf("ARMv8-system register" \ |
| 214 | "trace not supported\n"); \ |
| 215 | return TEST_RESULT_SKIPPED; \ |
| 216 | } \ |
| 217 | } while (false) |
| 218 | |
Manish V Badarkhe | 82e1a25 | 2022-01-04 13:45:31 +0000 | [diff] [blame] | 219 | #define SKIP_TEST_IF_AFP_NOT_SUPPORTED() \ |
| 220 | do { \ |
| 221 | if (!get_feat_afp_present()) { \ |
Manish V Badarkhe | b31bc75 | 2021-12-24 08:52:52 +0000 | [diff] [blame] | 222 | tftf_testcase_printf("ARMv8.7-afp not supported\n"); \ |
Manish V Badarkhe | 82e1a25 | 2022-01-04 13:45:31 +0000 | [diff] [blame] | 223 | return TEST_RESULT_SKIPPED; \ |
| 224 | } \ |
| 225 | } while (false) |
| 226 | |
Federico Recanati | 6328fb0 | 2022-01-14 15:48:16 +0100 | [diff] [blame] | 227 | #ifdef __aarch64__ |
Federico Recanati | d3749b0 | 2022-01-14 15:44:45 +0100 | [diff] [blame] | 228 | #define SKIP_TEST_IF_PA_SIZE_LESS_THAN(n) \ |
| 229 | do { \ |
| 230 | static const unsigned int pa_range_bits_arr[] = { \ |
| 231 | PARANGE_0000, PARANGE_0001, PARANGE_0010, PARANGE_0011,\ |
| 232 | PARANGE_0100, PARANGE_0101, PARANGE_0110 \ |
| 233 | }; \ |
| 234 | if (pa_range_bits_arr[get_pa_range()] < n) { \ |
| 235 | tftf_testcase_printf("PA size less than %d bit\n", n); \ |
| 236 | return TEST_RESULT_SKIPPED; \ |
| 237 | } \ |
| 238 | } while (false) |
Federico Recanati | 6328fb0 | 2022-01-14 15:48:16 +0100 | [diff] [blame] | 239 | #else |
| 240 | #define SKIP_TEST_IF_PA_SIZE_LESS_THAN(n) \ |
| 241 | do { \ |
| 242 | return TEST_RESULT_SKIPPED; \ |
| 243 | } while (false) |
| 244 | #endif |
Federico Recanati | d3749b0 | 2022-01-14 15:44:45 +0100 | [diff] [blame] | 245 | |
johpow01 | 8c3da8b | 2022-01-31 18:14:41 -0600 | [diff] [blame] | 246 | #define SKIP_TEST_IF_BRBE_NOT_SUPPORTED() \ |
| 247 | do { \ |
| 248 | if (!get_feat_brbe_support()) { \ |
| 249 | tftf_testcase_printf("FEAT_BRBE not supported\n"); \ |
| 250 | return TEST_RESULT_SKIPPED; \ |
| 251 | } \ |
| 252 | } while (false) |
| 253 | |
Manish V Badarkhe | b31bc75 | 2021-12-24 08:52:52 +0000 | [diff] [blame] | 254 | #define SKIP_TEST_IF_WFXT_NOT_SUPPORTED() \ |
| 255 | do { \ |
| 256 | if (!get_feat_wfxt_present()) { \ |
| 257 | tftf_testcase_printf("ARMv8.7-WFxT not supported\n"); \ |
| 258 | return TEST_RESULT_SKIPPED; \ |
| 259 | } \ |
| 260 | } while (false) |
| 261 | |
Juan Pablo Conde | 9303f4d | 2022-07-25 16:38:01 -0400 | [diff] [blame] | 262 | #define SKIP_TEST_IF_RNG_TRAP_NOT_SUPPORTED() \ |
| 263 | do { \ |
| 264 | if (!is_feat_rng_trap_present()) { \ |
| 265 | tftf_testcase_printf("ARMv8.5-RNG_TRAP not" \ |
| 266 | "supported\n"); \ |
| 267 | return TEST_RESULT_SKIPPED; \ |
| 268 | } \ |
| 269 | } while (false) |
| 270 | |
Boyan Karatotev | 35e3ca0 | 2022-10-10 16:39:45 +0100 | [diff] [blame] | 271 | #define SKIP_TEST_IF_PMUV3_NOT_SUPPORTED() \ |
| 272 | do { \ |
| 273 | if (!get_feat_pmuv3_supported()) { \ |
| 274 | tftf_testcase_printf("FEAT_PMUv3 not supported\n"); \ |
| 275 | return TEST_RESULT_SKIPPED; \ |
| 276 | } \ |
| 277 | } while (false) |
| 278 | |
Jayanth Dodderi Chidanand | b3ffd3c | 2023-02-13 12:15:11 +0000 | [diff] [blame] | 279 | #define SKIP_TEST_IF_SME_NOT_SUPPORTED() \ |
| 280 | do { \ |
| 281 | if(!is_feat_sme_supported()) { \ |
| 282 | tftf_testcase_printf("FEAT_SME not supported\n"); \ |
| 283 | return TEST_RESULT_SKIPPED; \ |
| 284 | } \ |
| 285 | } while (false) |
| 286 | |
Jayanth Dodderi Chidanand | 95d5d27 | 2023-01-16 17:58:47 +0000 | [diff] [blame] | 287 | #define SKIP_TEST_IF_SME2_NOT_SUPPORTED() \ |
| 288 | do { \ |
| 289 | if(!is_feat_sme2_supported()) { \ |
| 290 | tftf_testcase_printf("FEAT_SME2 not supported\n"); \ |
| 291 | return TEST_RESULT_SKIPPED; \ |
| 292 | } \ |
| 293 | } while (false) |
| 294 | |
Arunachalam Ganapathy | 4b22111 | 2023-04-05 14:19:03 +0100 | [diff] [blame] | 295 | #define SKIP_TEST_IF_RME_NOT_SUPPORTED_OR_RMM_IS_TRP() \ |
| 296 | do { \ |
Shruti Gupta | 40de8ec | 2023-10-12 21:45:12 +0100 | [diff] [blame^] | 297 | u_register_t retrmm = 0U; \ |
Arunachalam Ganapathy | 4b22111 | 2023-04-05 14:19:03 +0100 | [diff] [blame] | 298 | \ |
| 299 | if (!get_armv9_2_feat_rme_support()) { \ |
| 300 | tftf_testcase_printf("FEAT_RME not supported\n"); \ |
| 301 | return TEST_RESULT_SKIPPED; \ |
| 302 | } \ |
| 303 | \ |
| 304 | host_rmi_init_cmp_result(); \ |
Shruti Gupta | 40de8ec | 2023-10-12 21:45:12 +0100 | [diff] [blame^] | 305 | retrmm = host_rmi_version(RMI_ABI_VERSION_VAL); \ |
Arunachalam Ganapathy | 4b22111 | 2023-04-05 14:19:03 +0100 | [diff] [blame] | 306 | \ |
| 307 | VERBOSE("RMM version is: %lu.%lu\n", \ |
| 308 | RMI_ABI_VERSION_GET_MAJOR(retrmm), \ |
| 309 | RMI_ABI_VERSION_GET_MINOR(retrmm)); \ |
| 310 | \ |
| 311 | /* \ |
| 312 | * TODO: Remove this once SMC_RMM_REALM_CREATE is implemented \ |
| 313 | * in TRP. For the moment skip the test if RMM is TRP, TRP \ |
| 314 | * version is always 0. \ |
| 315 | */ \ |
| 316 | if (retrmm == 0U) { \ |
| 317 | tftf_testcase_printf("RMM is TRP\n"); \ |
| 318 | return TEST_RESULT_SKIPPED; \ |
| 319 | } \ |
| 320 | } while (false) |
| 321 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 322 | /* Helper macro to verify if system suspend API is supported */ |
| 323 | #define is_psci_sys_susp_supported() \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 324 | (tftf_get_psci_feature_info(SMC_PSCI_SYSTEM_SUSPEND) \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 325 | == PSCI_E_SUCCESS) |
| 326 | |
| 327 | /* Helper macro to verify if PSCI_STAT_COUNT API is supported */ |
| 328 | #define is_psci_stat_count_supported() \ |
J-Alves | 8f08a05 | 2020-05-26 17:14:40 +0100 | [diff] [blame] | 329 | (tftf_get_psci_feature_info(SMC_PSCI_STAT_COUNT) \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 330 | == PSCI_E_SUCCESS) |
| 331 | |
| 332 | /* |
| 333 | * Helper function to verify the system state is ready for system |
| 334 | * suspend. i.e., a single CPU is running and all other CPUs are powered off. |
| 335 | * Returns 1 if the system is ready to suspend, 0 otherwise. |
| 336 | */ |
| 337 | int is_sys_suspend_state_ready(void); |
| 338 | |
| 339 | /* |
| 340 | * Helper function to reset the system. This function shouldn't return. |
| 341 | * It is not marked with __dead to help the test to catch some error in |
| 342 | * TF |
| 343 | */ |
| 344 | void psci_system_reset(void); |
| 345 | |
| 346 | /* |
| 347 | * Helper function that enables/disables the mem_protect mechanism |
| 348 | */ |
| 349 | int psci_mem_protect(int val); |
| 350 | |
| 351 | |
| 352 | /* |
| 353 | * Helper function to call PSCI MEM_PROTECT_CHECK |
| 354 | */ |
| 355 | int psci_mem_protect_check(uintptr_t addr, size_t size); |
| 356 | |
| 357 | |
| 358 | /* |
| 359 | * Helper function to get a sentinel address that can be used to test mem_protect |
| 360 | */ |
| 361 | unsigned char *psci_mem_prot_get_sentinel(void); |
| 362 | |
| 363 | /* |
| 364 | * Helper function to memory map and unmap a region needed by a test. |
| 365 | * |
| 366 | * Return TEST_RESULT_FAIL if the memory could not be successfully mapped or |
| 367 | * unmapped. Otherwise, return the test functions's result. |
| 368 | */ |
| 369 | test_result_t map_test_unmap(const map_args_unmap_t *args, |
| 370 | test_function_arg_t test); |
| 371 | |
J-Alves | f1126f2 | 2020-11-02 17:28:20 +0000 | [diff] [blame] | 372 | /* |
nabkah01 | 9ea1664 | 2022-03-01 19:39:59 +0000 | [diff] [blame] | 373 | * Utility function to wait for all CPUs other than the caller to be |
| 374 | * OFF. |
| 375 | */ |
| 376 | void wait_for_non_lead_cpus(void); |
| 377 | |
| 378 | /* |
| 379 | * Utility function to wait for a given CPU other than the caller to be |
| 380 | * OFF. |
| 381 | */ |
| 382 | void wait_for_core_to_turn_off(unsigned int mpidr); |
AlexeiFedorov | 2f30f10 | 2023-03-13 19:37:46 +0000 | [diff] [blame] | 383 | |
| 384 | /* Generate 64-bit random number */ |
| 385 | unsigned long long rand64(void); |
| 386 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 387 | #endif /* __TEST_HELPERS_H__ */ |