diff options
Diffstat (limited to 'tftf/tests/common/test_helpers.c')
-rw-r--r-- | tftf/tests/common/test_helpers.c | 62 |
1 files changed, 23 insertions, 39 deletions
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c index d794bebc7..6a0b08bd0 100644 --- a/tftf/tests/common/test_helpers.c +++ b/tftf/tests/common/test_helpers.c @@ -1,18 +1,17 @@ /* - * Copyright (c) 2020-2021, Arm Limited. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ +#include <stdlib.h> + #include <arch_helpers.h> #include <plat_topology.h> #include <platform.h> -#include <power_management.h> #include <test_helpers.h> #include <tftf_lib.h> -static struct mailbox_buffers test_mb = {.send = NULL, .recv = NULL}; - int is_sys_suspend_state_ready(void) { int aff_info; @@ -131,48 +130,33 @@ test_result_t map_test_unmap(const map_args_unmap_t *args, return test_ret; } -void set_tftf_mailbox(const struct mailbox_buffers *mb) +/* + * Utility function to wait for all CPUs other than the caller to be + * OFF. + */ +void wait_for_non_lead_cpus(void) { - if (mb != NULL) { - test_mb = *mb; - } -} + unsigned int target_mpid, target_node; -bool get_tftf_mailbox(struct mailbox_buffers *mb) -{ - if ((test_mb.recv != NULL) && (test_mb.send != NULL)) { - *mb = test_mb; - return true; + for_each_cpu(target_node) { + target_mpid = tftf_get_mpidr_from_node(target_node); + wait_for_core_to_turn_off(target_mpid); } - return false; } -test_result_t check_spmc_testing_set_up( - uint32_t ffa_version_major, uint32_t ffa_version_minor, - const struct ffa_uuid *ffa_uuids, size_t ffa_uuids_size) +void wait_for_core_to_turn_off(unsigned int mpidr) { - struct mailbox_buffers mb; + /* Skip lead CPU, as it is powered on */ + if (mpidr == (read_mpidr_el1() & MPID_MASK)) + return; - if (ffa_uuids == NULL) { - ERROR("Invalid parameter ffa_uuids!\n"); - return TEST_RESULT_FAIL; - } - - SKIP_TEST_IF_FFA_VERSION_LESS_THAN(ffa_version_major, - ffa_version_minor); - - /********************************************************************** - * If OP-TEE is SPMC skip the current test. - **********************************************************************/ - if (check_spmc_execution_level()) { - VERBOSE("OPTEE as SPMC at S-EL1. Skipping test!\n"); - return TEST_RESULT_SKIPPED; + while (tftf_psci_affinity_info(mpidr, MPIDR_AFFLVL0) != PSCI_STATE_OFF) { + continue; } +} - GET_TFTF_MAILBOX(mb); - - for (unsigned int i = 0U; i < ffa_uuids_size; i++) - SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(*mb, ffa_uuids[i].uuid); - - return TEST_RESULT_SUCCESS; +/* Generate 64-bit random number */ +unsigned long long rand64(void) +{ + return ((unsigned long long)rand() << 32) | rand(); } |