feat: spm helper functions for MP tests
Added two helper functions to help with SPM tests in a MP setup.
- spm_core_sp_init: to initialize an SP in a given core.
- get_current_core_id: to get the current core ID.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: Iad10d43f258f5ed05ce52b87c94a9333c228f26d
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c
index 73d59bd..b7eeb15 100644
--- a/tftf/tests/common/test_helpers.c
+++ b/tftf/tests/common/test_helpers.c
@@ -221,6 +221,26 @@
return TEST_RESULT_SUCCESS;
}
+bool spm_core_sp_init(ffa_id_t sp_id)
+{
+ /*
+ * Secure Partitions secondary ECs need one round of ffa_run to reach
+ * the message loop.
+ */
+ if (sp_id != SP_ID(1)) {
+ uint32_t core_pos = get_current_core_id();
+ smc_ret_values ret = ffa_run(sp_id, core_pos);
+
+ if (ffa_func_id(ret) != FFA_MSG_WAIT) {
+ ERROR("Failed to run SP%x on core %u\n",
+ sp_id, core_pos);
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool spm_set_managed_exit_int(ffa_id_t sp_id, bool enable)
{
smc_ret_values ret;