SPM: Extract common debug code used for SPs

In later patches we will want to use the debug code defined in
cactus_debug.c for the Ivy partition, so create a common sp_debug
file for code re-use.

Signed-off-by: Ruari Phipps <ruari.phipps@arm.com>
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: Ifc9cf0043f3f7549b1668623b44d10cae64ddab0
diff --git a/spm/cactus/cactus.h b/spm/cactus/cactus.h
index cbf2dcb..c7176c2 100644
--- a/spm/cactus/cactus.h
+++ b/spm/cactus/cactus.h
@@ -26,11 +26,4 @@
 #define CACTUS_BSS_START	((uintptr_t)&__BSS_START__)
 #define CACTUS_BSS_END		((uintptr_t)&__BSS_END__)
 
-enum stdout_route {
-	PL011_AS_STDOUT = 0,
-	HVC_CALL_AS_STDOUT,
-};
-
-void set_putc_impl(enum stdout_route);
-
 #endif /* __CACTUS_H__ */
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index ae66c1d..5247fde 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -33,14 +33,14 @@
 	$(addprefix spm/cactus/,			\
 		aarch64/cactus_entrypoint.S		\
 		aarch64/cactus_exceptions.S		\
-		cactus_debug.c				\
 		cactus_interrupt.c			\
 		cactus_main.c				\
 	)						\
 	$(addprefix spm/common/,			\
 		aarch64/sp_arch_helpers.S		\
+		sp_debug.c				\
 		sp_helpers.c				\
-		spm_helpers.c					\
+		spm_helpers.c				\
 	)						\
 	$(addprefix spm/cactus/cactus_tests/,		\
 		cactus_message_loop.c			\
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index 73606bd..59cd7e7 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -16,9 +16,11 @@
 #include <lib/tftf_lib.h>
 #include <lib/xlat_tables/xlat_mmu_helpers.h>
 #include <lib/xlat_tables/xlat_tables_v2.h>
+
 #include <plat_arm.h>
 #include <plat/common/platform.h>
 #include <platform_def.h>
+#include <sp_debug.h>
 #include <sp_helpers.h>
 #include <spm_helpers.h>
 #include <std_svc.h>
diff --git a/spm/cactus/cactus_debug.c b/spm/common/sp_debug.c
similarity index 87%
rename from spm/cactus/cactus_debug.c
rename to spm/common/sp_debug.c
index 30a2527..64ea9c5 100644
--- a/spm/cactus/cactus_debug.c
+++ b/spm/common/sp_debug.c
@@ -1,15 +1,14 @@
 /*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
 #include <drivers/arm/pl011.h>
 #include <drivers/console.h>
+#include <sp_debug.h>
 #include <spm_helpers.h>
 
-#include "cactus.h"
-
 static int (*putc_impl)(int);
 
 static int putc_hypcall(int c)
diff --git a/spm/common/sp_debug.h b/spm/common/sp_debug.h
new file mode 100644
index 0000000..8b0bec7
--- /dev/null
+++ b/spm/common/sp_debug.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+enum stdout_route {
+	PL011_AS_STDOUT = 0,
+	HVC_CALL_AS_STDOUT,
+};
+
+void set_putc_impl(enum stdout_route);
diff --git a/spm/common/sp_helpers.h b/spm/common/sp_helpers.h
index 399200a..9f5400c 100644
--- a/spm/common/sp_helpers.h
+++ b/spm/common/sp_helpers.h
@@ -9,7 +9,7 @@
 
 #include <stdint.h>
 #include <tftf_lib.h>
-#include <ffa_helpers.h>
+#include <spm_common.h>
 
 typedef struct {
 	u_register_t fid;
diff --git a/spm/ivy/ivy.mk b/spm/ivy/ivy.mk
index 87eea43..3d81fe1 100644
--- a/spm/ivy/ivy.mk
+++ b/spm/ivy/ivy.mk
@@ -33,7 +33,9 @@
 	)						\
 	$(addprefix spm/common/,			\
 		aarch64/sp_arch_helpers.S		\
+		sp_debug.c				\
 		sp_helpers.c				\
+		spm_helpers.c				\
 	)						\
 
 # TODO: Remove dependency on TFTF files.
@@ -43,9 +45,11 @@
 	tftf/tests/runtime_services/secure_service/ffa_helpers.c
 
 IVY_SOURCES	+= 	drivers/arm/pl011/${ARCH}/pl011_console.S	\
-			drivers/console/console.c			\
 			lib/${ARCH}/cache_helpers.S			\
 			lib/${ARCH}/misc_helpers.S			\
+			lib/smc/${ARCH}/asm_smc.S			\
+			lib/smc/${ARCH}/smc.c				\
+			lib/smc/${ARCH}/hvc.c				\
 			lib/locks/${ARCH}/spinlock.S			\
 			lib/utils/mp_printf.c				\
 			${SPRT_LIB_SOURCES}				\