spmc: hypervisor calls moved to a separate module
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I285ffc684aa780246468355add9d03c1b5b8fefb
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index 08b824c..9d47b90 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -38,6 +38,7 @@
$(addprefix spm/common/, \
aarch64/sp_arch_helpers.S \
sp_helpers.c \
+ spm_helpers.c \
) \
$(addprefix spm/cactus/cactus_tests/, \
cactus_message_loop.c \
diff --git a/spm/cactus/cactus_debug.c b/spm/cactus/cactus_debug.c
index 43093a6..30a2527 100644
--- a/spm/cactus/cactus_debug.c
+++ b/spm/cactus/cactus_debug.c
@@ -6,7 +6,7 @@
#include <drivers/arm/pl011.h>
#include <drivers/console.h>
-#include <sp_helpers.h>
+#include <spm_helpers.h>
#include "cactus.h"
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index e54f3b0..ed48fe4 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -20,6 +20,7 @@
#include <plat/common/platform.h>
#include <platform_def.h>
#include <sp_helpers.h>
+#include <spm_helpers.h>
#include <std_svc.h>
#include "cactus_def.h"
diff --git a/spm/cactus/cactus_tests/cactus_test_ffa.c b/spm/cactus/cactus_tests/cactus_test_ffa.c
index c1ba783..2ade7bd 100644
--- a/spm/cactus/cactus_tests/cactus_test_ffa.c
+++ b/spm/cactus/cactus_tests/cactus_test_ffa.c
@@ -11,6 +11,7 @@
#include <cactus_platform_def.h>
#include <ffa_endpoints.h>
#include <sp_helpers.h>
+#include <spm_helpers.h>
#include <spm_common.h>
#include <lib/libc/string.h>
diff --git a/spm/common/sp_helpers.c b/spm/common/sp_helpers.c
index 5d76dc8..a6b6bc5 100644
--- a/spm/common/sp_helpers.c
+++ b/spm/common/sp_helpers.c
@@ -71,28 +71,3 @@
time2 = read_cntvct_el0();
}
}
-
-/*******************************************************************************
- * Hypervisor Calls Wrappers
- ******************************************************************************/
-
-ffa_int_id_t spm_interrupt_get(void)
-{
- hvc_args args = {
- .fid = SPM_INTERRUPT_GET
- };
-
- hvc_ret_values ret = tftf_hvc(&args);
-
- return ret.ret0;
-}
-
-void spm_debug_log(char c)
-{
- hvc_args args = {
- .fid = SPM_DEBUG_LOG,
- .arg1 = c
- };
-
- (void)tftf_hvc(&args);
-}
diff --git a/spm/common/sp_helpers.h b/spm/common/sp_helpers.h
index ec92227..399200a 100644
--- a/spm/common/sp_helpers.h
+++ b/spm/common/sp_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -11,12 +11,6 @@
#include <tftf_lib.h>
#include <ffa_helpers.h>
-#define SPM_VM_ID_FIRST SP_ID(1)
-
-/* Should match with IDs defined in SPM/Hafnium */
-#define SPM_INTERRUPT_GET (0xFF04)
-#define SPM_DEBUG_LOG (0xBD000000)
-
typedef struct {
u_register_t fid;
u_register_t arg1;
@@ -65,12 +59,4 @@
/* Sleep for at least 'ms' milliseconds. */
void sp_sleep(uint32_t ms);
-/*
- * Hypervisor Calls Wrappers
- */
-
-ffa_int_id_t spm_interrupt_get(void);
-
-void spm_debug_log(char c);
-
#endif /* SP_HELPERS_H */
diff --git a/spm/common/spm_helpers.c b/spm/common/spm_helpers.c
new file mode 100644
index 0000000..823f9f6
--- /dev/null
+++ b/spm/common/spm_helpers.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <spm_helpers.h>
+
+/*******************************************************************************
+ * Hypervisor Calls Wrappers
+ ******************************************************************************/
+
+uint32_t spm_interrupt_get(void)
+{
+ hvc_args args = {
+ .fid = SPM_INTERRUPT_GET
+ };
+
+ hvc_ret_values ret = tftf_hvc(&args);
+
+ return ret.ret0;
+}
+
+void spm_debug_log(char c)
+{
+ hvc_args args = {
+ .fid = SPM_DEBUG_LOG,
+ .arg1 = c
+ };
+
+ (void)tftf_hvc(&args);
+}
diff --git a/spm/common/spm_helpers.h b/spm/common/spm_helpers.h
new file mode 100644
index 0000000..f241e42
--- /dev/null
+++ b/spm/common/spm_helpers.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SPMC_H
+#define SPMC_H
+
+#include <ffa_helpers.h>
+
+/* Should match with IDs defined in SPM/Hafnium */
+#define SPM_INTERRUPT_GET (0xFF04)
+#define SPM_DEBUG_LOG (0xBD000000)
+
+/*
+ * Hypervisor Calls Wrappers
+ */
+
+uint32_t spm_interrupt_get(void);
+void spm_debug_log(char c);
+
+#endif /* SPMC_H */