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/include/common/test_helpers.h b/include/common/test_helpers.h
index 8220244..0881f00 100644
--- a/include/common/test_helpers.h
+++ b/include/common/test_helpers.h
@@ -353,6 +353,12 @@
event_t *cpu_booted);
/**
+ * Call FFA_RUN in the designated SP to make it reach the message loop.
+ * Used within CPU_ON handlers, to bring up the SP in the current core.
+ */
+bool spm_core_sp_init(ffa_id_t sp_id);
+
+/**
* Enable/Disable managed exit interrupt for the provided SP.
*/
bool spm_set_managed_exit_int(ffa_id_t sp_id, bool enable);
diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h
index f3536ba..c8b785c 100644
--- a/include/plat/common/platform.h
+++ b/include/plat/common/platform.h
@@ -8,6 +8,7 @@
#define __PLATFORM_H__
#include <stdint.h>
+#include <arch_helpers.h>
#include <timer.h>
#include <xlat_tables_v2.h>
@@ -184,4 +185,12 @@
void plat_fwu_io_setup(void);
+/**
+ * Returns current executing core.
+ */
+static inline uint32_t get_current_core_id(void)
+{
+ return platform_get_core_pos(read_mpidr_el1() & MPID_MASK);
+}
+
#endif /* __PLATFORM_H__ */
diff --git a/include/runtime_services/spm_common.h b/include/runtime_services/spm_common.h
index 2393dc6..f4b5a75 100644
--- a/include/runtime_services/spm_common.h
+++ b/include/runtime_services/spm_common.h
@@ -7,10 +7,13 @@
#ifndef SPM_COMMON_H
#define SPM_COMMON_H
-#include <ffa_helpers.h>
+#include <plat/common/platform.h>
+
#include <stdint.h>
#include <string.h>
+#include <ffa_helpers.h>
+
/* Hypervisor ID at physical FFA instance */
#define HYP_ID (0)
/* SPMC ID */