blob: 6a4b4123e4eab56d2aacd5d9bc7f48002be6b3d9 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Javier Almansa Sobrino82cd82e2025-01-17 17:37:42 +00002 * Copyright (c) 2018-2025, Arm Limited. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
J-Alvesd708c032020-11-19 12:14:21 +00007#ifndef TEST_HELPERS_H__
8#define TEST_HELPERS_H__
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02009
Joel Hutton8790f022019-03-15 14:47:02 +000010#include <arch_features.h>
J-Alvesf7535f42021-07-30 11:58:41 +010011#include <plat_topology.h>
J-Alves8f08a052020-05-26 17:14:40 +010012#include <psci.h>
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000013#include <sme.h>
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020014#include <tftf_lib.h>
15#include <trusted_os.h>
16#include <tsp.h>
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020017#include <uuid_utils.h>
Max Shvetsov103e0562021-02-04 16:58:31 +000018#include <uuid.h>
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020019
Juan Pablo Condedc23fcd2025-04-05 14:26:13 -050020#define TEST_MECID1 (unsigned short)1
21#define TEST_MECID2 (unsigned short)2
22
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020023typedef struct {
24 uintptr_t addr;
25 size_t size;
26 unsigned int attr;
27 void *arg;
28} map_args_unmap_t;
29
30typedef test_result_t (*test_function_arg_t)(void *arg);
31
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -060032#ifndef __aarch64__
Joel Hutton8790f022019-03-15 14:47:02 +000033#define SKIP_TEST_IF_AARCH32() \
34 do { \
35 tftf_testcase_printf("Test not supported on aarch32\n"); \
36 return TEST_RESULT_SKIPPED; \
37 } while (0)
38#else
39#define SKIP_TEST_IF_AARCH32()
40#endif
41
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020042#define SKIP_TEST_IF_LESS_THAN_N_CLUSTERS(n) \
43 do { \
44 unsigned int clusters_cnt; \
45 clusters_cnt = tftf_get_total_clusters_count(); \
46 if (clusters_cnt < (n)) { \
47 tftf_testcase_printf( \
48 "Need at least %u clusters, only found %u\n", \
49 (n), clusters_cnt); \
50 return TEST_RESULT_SKIPPED; \
51 } \
52 } while (0)
53
54#define SKIP_TEST_IF_LESS_THAN_N_CPUS(n) \
55 do { \
56 unsigned int cpus_cnt; \
57 cpus_cnt = tftf_get_total_cpus_count(); \
58 if (cpus_cnt < (n)) { \
59 tftf_testcase_printf( \
60 "Need at least %u CPUs, only found %u\n", \
61 (n), cpus_cnt); \
62 return TEST_RESULT_SKIPPED; \
63 } \
64 } while (0)
65
66#define SKIP_TEST_IF_TRUSTED_OS_NOT_PRESENT() \
67 do { \
68 uuid_t tos_uuid; \
69 \
70 if (!is_trusted_os_present(&tos_uuid)) { \
71 tftf_testcase_printf("No Trusted OS detected\n"); \
72 return TEST_RESULT_SKIPPED; \
73 } \
74 } while (0)
75
76#define SKIP_TEST_IF_TSP_NOT_PRESENT() \
77 do { \
78 uuid_t tos_uuid; \
79 char tos_uuid_str[UUID_STR_SIZE]; \
80 \
81 if (!is_trusted_os_present(&tos_uuid)) { \
82 tftf_testcase_printf("No Trusted OS detected\n"); \
83 return TEST_RESULT_SKIPPED; \
84 } \
85 \
86 if (!uuid_equal(&tos_uuid, &tsp_uuid)) { \
87 tftf_testcase_printf( \
88 "Trusted OS is not the TSP, its UUID is: %s\n", \
89 uuid_to_str(&tos_uuid, tos_uuid_str)); \
90 return TEST_RESULT_SKIPPED; \
91 } \
92 } while (0)
93
Boyan Karatotev566f07d2024-10-25 13:31:48 +010094#define SKIP_TEST_IF_SMCCC_VERSION_LT(major, minor) \
95 do { \
96 smc_args args = {0}; \
97 smc_ret_values ret; \
98 args.fid = SMCCC_VERSION; \
99 ret = tftf_smc(&args); \
100 if ((int32_t)ret.ret0 < MAKE_SMCCC_VERSION(major, minor)) { \
101 tftf_testcase_printf( \
102 "Unexpected SMCCC version: 0x%x\n", \
103 (int)ret.ret0); \
104 return TEST_RESULT_SKIPPED; \
105 } \
106 } while (0)
107
Boyan Karatotev7b7ca222024-10-25 13:33:18 +0100108#define SKIP_TEST_IF_SMCCC_FUNC_NOT_SUPPORTED(func) \
109 do { \
110 smc_ret_values ret; \
111 smc_args args = {0}; \
112 args.fid = SMCCC_ARCH_FEATURES; \
113 args.arg1 = func; \
114 ret = tftf_smc(&args); \
115 if ((int)ret.ret0 == SMC_ARCH_CALL_NOT_SUPPORTED) { \
116 tftf_testcase_printf( \
117 #func " is not implemented\n"); \
118 return TEST_RESULT_SKIPPED; \
119 } \
120 } while (0)
121
Daniel Boulby0e4629f2021-10-26 14:01:23 +0100122#define SKIP_TEST_IF_DIT_NOT_SUPPORTED() \
123 do { \
124 if (!is_armv8_4_dit_present()) { \
125 tftf_testcase_printf( \
126 "DIT not supported\n"); \
127 return TEST_RESULT_SKIPPED; \
128 } \
129 } while (0)
130
Joel Hutton8790f022019-03-15 14:47:02 +0000131#define SKIP_TEST_IF_PAUTH_NOT_SUPPORTED() \
132 do { \
133 if (!is_armv8_3_pauth_present()) { \
134 tftf_testcase_printf( \
135 "Pointer Authentication not supported\n"); \
136 return TEST_RESULT_SKIPPED; \
137 } \
138 } while (0)
139
Jimmy Brisson90f1d5c2020-04-16 10:54:51 -0500140#define SKIP_TEST_IF_FGT_NOT_SUPPORTED() \
141 do { \
142 if (!is_armv8_6_fgt_present()) { \
143 tftf_testcase_printf( \
144 "Fine Grained Traps not supported\n"); \
145 return TEST_RESULT_SKIPPED; \
146 } \
147 } while (0)
148
Arvind Ram Prakash2f2c9592024-06-06 16:34:28 -0500149#define SKIP_TEST_IF_DEBUGV8P9_NOT_SUPPORTED() \
150 do { \
151 if (arch_get_debug_version() != \
152 ID_AA64DFR0_V8_9_DEBUG_ARCH_SUPPORTED) { \
153 tftf_testcase_printf( \
154 "Debugv8p9 not supported\n"); \
155 return TEST_RESULT_SKIPPED; \
156 } \
157 } while (0)
158
Arvind Ram Prakash94963d42024-06-13 17:19:56 -0500159#define SKIP_TEST_IF_FGT2_NOT_SUPPORTED() \
160 do { \
161 if (!is_armv8_9_fgt2_present()) { \
162 tftf_testcase_printf( \
163 "Fine Grained Traps 2 not supported\n"); \
164 return TEST_RESULT_SKIPPED; \
165 } \
166 } while (0)
167
Max Shvetsov959be332021-03-16 14:18:13 +0000168#define SKIP_TEST_IF_SVE_NOT_SUPPORTED() \
169 do { \
170 if (!is_armv8_2_sve_present()) { \
171 tftf_testcase_printf("SVE not supported\n"); \
172 return TEST_RESULT_SKIPPED; \
173 } \
174 } while (0)
175
Jimmy Brisson945095a2020-04-16 10:54:59 -0500176#define SKIP_TEST_IF_ECV_NOT_SELF_SYNC() \
177 do { \
178 if (get_armv8_6_ecv_support() != \
179 ID_AA64MMFR0_EL1_ECV_SELF_SYNCH) { \
180 tftf_testcase_printf("ARMv8.6-ECV not supported\n"); \
181 return TEST_RESULT_SKIPPED; \
182 } \
183 } while (0)
184
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200185#define SKIP_TEST_IF_MM_NOT_PRESENT() \
186 do { \
187 smc_args version_smc = { MM_VERSION_AARCH32 }; \
188 smc_ret_values smc_ret = tftf_smc(&version_smc); \
189 uint32_t version = smc_ret.ret0; \
190 \
191 if (version == (uint32_t) SMC_UNKNOWN) { \
192 tftf_testcase_printf("SPM not detected.\n"); \
193 return TEST_RESULT_SKIPPED; \
194 } \
195 } while (0)
196
Sandrine Bailleux277fb762019-10-08 12:10:45 +0200197#define SKIP_TEST_IF_MTE_SUPPORT_LESS_THAN(n) \
198 do { \
199 if (get_armv8_5_mte_support() < (n)) { \
200 tftf_testcase_printf( \
201 "Memory Tagging Extension not supported\n"); \
202 return TEST_RESULT_SKIPPED; \
203 } \
204 } while (0)
205
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200206#define SKIP_TEST_IF_MM_VERSION_LESS_THAN(major, minor) \
207 do { \
208 smc_args version_smc = { MM_VERSION_AARCH32 }; \
209 smc_ret_values smc_ret = tftf_smc(&version_smc); \
210 uint32_t version = smc_ret.ret0; \
211 \
212 if (version == (uint32_t) SMC_UNKNOWN) { \
213 tftf_testcase_printf("SPM not detected.\n"); \
214 return TEST_RESULT_SKIPPED; \
215 } \
216 \
217 if (version < MM_VERSION_FORM(major, minor)) { \
J-Alves8f08a052020-05-26 17:14:40 +0100218 tftf_testcase_printf("MM_VERSION returned %u.%u\n" \
219 "The required version is %u.%u\n", \
220 version >> MM_VERSION_MAJOR_SHIFT, \
221 version & MM_VERSION_MINOR_MASK, \
222 major, minor); \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200223 return TEST_RESULT_SKIPPED; \
224 } \
225 \
J-Alves8f08a052020-05-26 17:14:40 +0100226 VERBOSE("MM_VERSION returned %u.%u\n", \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200227 version >> MM_VERSION_MAJOR_SHIFT, \
228 version & MM_VERSION_MINOR_MASK); \
229 } while (0)
230
Petre-Ionut Tudorf68ebdb2019-09-18 16:13:00 +0100231#define SKIP_TEST_IF_ARCH_DEBUG_VERSION_LESS_THAN(version) \
232 do { \
Petre-Ionut Tudorf1a45f72019-10-08 16:51:45 +0100233 uint32_t debug_ver = arch_get_debug_version(); \
Petre-Ionut Tudorf68ebdb2019-09-18 16:13:00 +0100234 \
Petre-Ionut Tudorf1a45f72019-10-08 16:51:45 +0100235 if (debug_ver < version) { \
Petre-Ionut Tudorf68ebdb2019-09-18 16:13:00 +0100236 tftf_testcase_printf("Debug version returned %d\n" \
237 "The required version is %d\n", \
Petre-Ionut Tudorf1a45f72019-10-08 16:51:45 +0100238 debug_ver, \
Petre-Ionut Tudorf68ebdb2019-09-18 16:13:00 +0100239 version); \
240 return TEST_RESULT_SKIPPED; \
241 } \
242 } while (0)
243
Manish V Badarkhe87c03d12021-07-06 22:57:11 +0100244#define SKIP_TEST_IF_TRBE_NOT_SUPPORTED() \
245 do { \
Boyan Karatotev4e282422024-10-25 14:34:13 +0100246 if (!is_feat_trbe_present()) { \
Manish V Badarkhe87c03d12021-07-06 22:57:11 +0100247 tftf_testcase_printf("ARMv9-TRBE not supported\n"); \
248 return TEST_RESULT_SKIPPED; \
249 } \
250 } while (false)
251
Manish V Badarkhe2c518e52021-07-08 16:36:57 +0100252#define SKIP_TEST_IF_TRF_NOT_SUPPORTED() \
253 do { \
254 if (!get_armv8_4_trf_support()) { \
255 tftf_testcase_printf("ARMv8.4-TRF not supported\n"); \
256 return TEST_RESULT_SKIPPED; \
257 } \
258 } while (false)
259
Manish V Badarkhe6d0e1b62021-07-09 13:58:28 +0100260#define SKIP_TEST_IF_SYS_REG_TRACE_NOT_SUPPORTED() \
261 do { \
262 if (!get_armv8_0_sys_reg_trace_support()) { \
263 tftf_testcase_printf("ARMv8-system register" \
264 "trace not supported\n"); \
265 return TEST_RESULT_SKIPPED; \
266 } \
267 } while (false)
268
Manish V Badarkhe82e1a252022-01-04 13:45:31 +0000269#define SKIP_TEST_IF_AFP_NOT_SUPPORTED() \
270 do { \
271 if (!get_feat_afp_present()) { \
Manish V Badarkheb31bc752021-12-24 08:52:52 +0000272 tftf_testcase_printf("ARMv8.7-afp not supported\n"); \
Manish V Badarkhe82e1a252022-01-04 13:45:31 +0000273 return TEST_RESULT_SKIPPED; \
274 } \
275 } while (false)
276
Arvind Ram Prakash13887ac2024-01-04 15:22:52 -0600277#define SKIP_TEST_IF_MPAM_NOT_SUPPORTED() \
278 do { \
279 if(!is_feat_mpam_supported()){ \
280 tftf_testcase_printf("ARMv8.4-mpam not supported\n"); \
281 return TEST_RESULT_SKIPPED; \
282 } \
283 } while (false)
284
Andre Przywara2230a592025-03-10 17:19:34 +0000285#define SKIP_TEST_IF_RAS_NOT_SUPPORTED() \
286 do { \
287 if(!is_feat_ras_present()){ \
288 tftf_testcase_printf("ARMv8.2-RAS not supported\n"); \
289 return TEST_RESULT_SKIPPED; \
290 } \
291 } while (false)
292
Federico Recanati6328fb02022-01-14 15:48:16 +0100293#ifdef __aarch64__
Federico Recanatid3749b02022-01-14 15:44:45 +0100294#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 Recanati6328fb02022-01-14 15:48:16 +0100305#else
306#define SKIP_TEST_IF_PA_SIZE_LESS_THAN(n) \
307 do { \
308 return TEST_RESULT_SKIPPED; \
309 } while (false)
310#endif
Federico Recanatid3749b02022-01-14 15:44:45 +0100311
johpow018c3da8b2022-01-31 18:14:41 -0600312#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
Manish V Badarkheb31bc752021-12-24 08:52:52 +0000320#define SKIP_TEST_IF_WFXT_NOT_SUPPORTED() \
321 do { \
322 if (!get_feat_wfxt_present()) { \
323 tftf_testcase_printf("ARMv8.7-WFxT not supported\n"); \
324 return TEST_RESULT_SKIPPED; \
325 } \
326 } while (false)
327
Juan Pablo Conde9303f4d2022-07-25 16:38:01 -0400328#define SKIP_TEST_IF_RNG_TRAP_NOT_SUPPORTED() \
329 do { \
330 if (!is_feat_rng_trap_present()) { \
331 tftf_testcase_printf("ARMv8.5-RNG_TRAP not" \
332 "supported\n"); \
333 return TEST_RESULT_SKIPPED; \
334 } \
335 } while (false)
336
Boyan Karatotev35e3ca02022-10-10 16:39:45 +0100337#define SKIP_TEST_IF_PMUV3_NOT_SUPPORTED() \
338 do { \
339 if (!get_feat_pmuv3_supported()) { \
340 tftf_testcase_printf("FEAT_PMUv3 not supported\n"); \
341 return TEST_RESULT_SKIPPED; \
342 } \
343 } while (false)
344
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +0000345#define SKIP_TEST_IF_SME_NOT_SUPPORTED() \
346 do { \
347 if(!is_feat_sme_supported()) { \
348 tftf_testcase_printf("FEAT_SME not supported\n"); \
349 return TEST_RESULT_SKIPPED; \
350 } \
351 } while (false)
352
Jayanth Dodderi Chidanand95d5d272023-01-16 17:58:47 +0000353#define SKIP_TEST_IF_SME2_NOT_SUPPORTED() \
354 do { \
355 if(!is_feat_sme2_supported()) { \
356 tftf_testcase_printf("FEAT_SME2 not supported\n"); \
357 return TEST_RESULT_SKIPPED; \
358 } \
359 } while (false)
360
Arvind Ram Prakash1ab21e52024-11-12 10:52:08 -0600361#define SKIP_TEST_IF_FPMR_NOT_SUPPORTED() \
362 do { \
363 if(!is_feat_fpmr_present()) { \
364 tftf_testcase_printf("FEAT_FPMR not supported\n"); \
365 return TEST_RESULT_SKIPPED; \
366 } \
367 } while (false)
368
Igor Podgainõid1a7f4d2024-11-26 12:50:47 +0100369#define SKIP_TEST_IF_SCTLR2_NOT_SUPPORTED() \
370 do { \
371 if (!is_feat_sctlr2_supported()) { \
372 tftf_testcase_printf("FEAT_SCTLR2 not supported\n"); \
373 return TEST_RESULT_SKIPPED; \
374 } \
375 } while (false)
376
377#define SKIP_TEST_IF_THE_NOT_SUPPORTED() \
378 do { \
379 if (!is_feat_the_supported()) { \
380 tftf_testcase_printf("FEAT_THE not supported\n"); \
381 return TEST_RESULT_SKIPPED; \
382 } \
383 } while (false)
384
385#define SKIP_TEST_IF_D128_NOT_SUPPORTED() \
386 do { \
387 if (!is_feat_d128_supported()) { \
388 tftf_testcase_printf("FEAT_D128 not supported\n"); \
389 return TEST_RESULT_SKIPPED; \
390 } \
391 } while (false)
392
Arunachalam Ganapathy4b221112023-04-05 14:19:03 +0100393#define SKIP_TEST_IF_RME_NOT_SUPPORTED_OR_RMM_IS_TRP() \
394 do { \
Shruti Gupta40de8ec2023-10-12 21:45:12 +0100395 u_register_t retrmm = 0U; \
Arunachalam Ganapathy4b221112023-04-05 14:19:03 +0100396 \
AlexeiFedorov718fd792024-11-08 14:55:20 +0000397 if (get_armv9_2_feat_rme_support() == 0U) { \
Arunachalam Ganapathy4b221112023-04-05 14:19:03 +0100398 tftf_testcase_printf("FEAT_RME not supported\n"); \
399 return TEST_RESULT_SKIPPED; \
400 } \
401 \
402 host_rmi_init_cmp_result(); \
Shruti Gupta40de8ec2023-10-12 21:45:12 +0100403 retrmm = host_rmi_version(RMI_ABI_VERSION_VAL); \
Arunachalam Ganapathy4b221112023-04-05 14:19:03 +0100404 \
405 VERBOSE("RMM version is: %lu.%lu\n", \
406 RMI_ABI_VERSION_GET_MAJOR(retrmm), \
407 RMI_ABI_VERSION_GET_MINOR(retrmm)); \
408 \
409 /* \
410 * TODO: Remove this once SMC_RMM_REALM_CREATE is implemented \
411 * in TRP. For the moment skip the test if RMM is TRP, TRP \
412 * version is always 0. \
413 */ \
414 if (retrmm == 0U) { \
415 tftf_testcase_printf("RMM is TRP\n"); \
416 return TEST_RESULT_SKIPPED; \
417 } \
418 } while (false)
419
Jayanth Dodderi Chidanandcd6c94b2022-02-15 17:19:05 +0000420#define SKIP_TEST_IF_LS64_NOT_SUPPORTED() \
421 do { \
422 if (get_feat_ls64_support() == \
423 ID_AA64ISAR1_LS64_NOT_SUPPORTED) { \
424 tftf_testcase_printf("ARMv8.7-ls64 not supported"); \
425 return TEST_RESULT_SKIPPED; \
426 } \
427 } while (false)
428
Andre Przywara72b7ce12024-11-04 13:44:39 +0000429#define SKIP_TEST_IF_LS64_ACCDATA_NOT_SUPPORTED() \
430 do { \
431 if (get_feat_ls64_support() < \
432 ID_AA64ISAR1_LS64_ACCDATA_SUPPORTED) { \
433 tftf_testcase_printf("ARMv8.7-ls64-accdata not supported"); \
434 return TEST_RESULT_SKIPPED; \
435 } \
436 } while (false)
437
Javier Almansa Sobrino7c78f7b2024-10-25 11:44:32 +0100438#define SKIP_TEST_IF_DOUBLE_FAULT2_NOT_SUPPORTED() \
439 do { \
440 if (is_feat_double_fault2_present() == false) { \
441 return TEST_RESULT_SKIPPED; \
442 } \
443 } while (false)
444
Javier Almansa Sobrino82cd82e2025-01-17 17:37:42 +0000445#define SKIP_TEST_IF_FEAT_MPAM_NOT_SUPPORTED() \
446 do { \
447 if (is_feat_mpam_supported() == false) { \
448 return TEST_RESULT_SKIPPED; \
449 } \
450 } while (false) \
451
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200452/* Helper macro to verify if system suspend API is supported */
453#define is_psci_sys_susp_supported() \
J-Alves8f08a052020-05-26 17:14:40 +0100454 (tftf_get_psci_feature_info(SMC_PSCI_SYSTEM_SUSPEND) \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200455 == PSCI_E_SUCCESS)
456
457/* Helper macro to verify if PSCI_STAT_COUNT API is supported */
458#define is_psci_stat_count_supported() \
J-Alves8f08a052020-05-26 17:14:40 +0100459 (tftf_get_psci_feature_info(SMC_PSCI_STAT_COUNT) \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200460 == PSCI_E_SUCCESS)
461
462/*
463 * Helper function to verify the system state is ready for system
464 * suspend. i.e., a single CPU is running and all other CPUs are powered off.
465 * Returns 1 if the system is ready to suspend, 0 otherwise.
466 */
467int is_sys_suspend_state_ready(void);
468
469/*
470 * Helper function to reset the system. This function shouldn't return.
471 * It is not marked with __dead to help the test to catch some error in
472 * TF
473 */
474void psci_system_reset(void);
475
476/*
477 * Helper function that enables/disables the mem_protect mechanism
478 */
479int psci_mem_protect(int val);
480
481
482/*
483 * Helper function to call PSCI MEM_PROTECT_CHECK
484 */
485int psci_mem_protect_check(uintptr_t addr, size_t size);
486
487
488/*
489 * Helper function to get a sentinel address that can be used to test mem_protect
490 */
491unsigned char *psci_mem_prot_get_sentinel(void);
492
493/*
494 * Helper function to memory map and unmap a region needed by a test.
495 *
496 * Return TEST_RESULT_FAIL if the memory could not be successfully mapped or
497 * unmapped. Otherwise, return the test functions's result.
498 */
499test_result_t map_test_unmap(const map_args_unmap_t *args,
500 test_function_arg_t test);
501
J-Alvesf1126f22020-11-02 17:28:20 +0000502/*
nabkah019ea16642022-03-01 19:39:59 +0000503 * Utility function to wait for all CPUs other than the caller to be
504 * OFF.
505 */
506void wait_for_non_lead_cpus(void);
507
508/*
509 * Utility function to wait for a given CPU other than the caller to be
510 * OFF.
511 */
512void wait_for_core_to_turn_off(unsigned int mpidr);
AlexeiFedorov2f30f102023-03-13 19:37:46 +0000513
514/* Generate 64-bit random number */
515unsigned long long rand64(void);
516
Arvind Ram Prakash81916212024-08-15 15:08:23 -0500517/* TRBE Errata */
518#define CORTEX_A520_MIDR U(0x410FD800)
519#define CORTEX_X4_MIDR U(0x410FD821)
520#define RXPX_RANGE(x, y, z) (((x >= y) && (x <= z)) ? true : false)
521bool is_trbe_errata_affected_core(void);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200522#endif /* __TEST_HELPERS_H__ */