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_debug.c b/spm/cactus/cactus_debug.c
deleted file mode 100644
index 30a2527..0000000
--- a/spm/cactus/cactus_debug.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <drivers/arm/pl011.h>
-#include <drivers/console.h>
-#include <spm_helpers.h>
-
-#include "cactus.h"
-
-static int (*putc_impl)(int);
-
-static int putc_hypcall(int c)
-{
- spm_debug_log((char)c);
-
- return c;
-}
-
-static int putc_uart(int c)
-{
- console_pl011_putc(c);
-
- return c;
-}
-
-void set_putc_impl(enum stdout_route route)
-{
- switch (route) {
-
- case HVC_CALL_AS_STDOUT:
- putc_impl = putc_hypcall;
- return;
-
- case PL011_AS_STDOUT:
- default:
- break;
- }
-
- putc_impl = putc_uart;
-}
-
-int console_putc(int c)
-{
- if (!putc_impl) {
- return -1;
- }
-
- return putc_impl(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>