SPM: Change to new SPM log APIs
Change the LOG_MSG to new log APIs in SPM part.
Change-Id: Ief970fdcff6dfa80b272d29234014ead1ffb18ff
Signed-off-by: Shawn Shan <Shawn.Shan@arm.com>
diff --git a/secure_fw/spm/cmsis_func/main.c b/secure_fw/spm/cmsis_func/main.c
index 169f146..bfc11cd 100644
--- a/secure_fw/spm/cmsis_func/main.c
+++ b/secure_fw/spm/cmsis_func/main.c
@@ -7,13 +7,13 @@
#include "arch.h"
#include "common/tfm_boot_data.h"
-#include "log/tfm_log.h"
#include "region.h"
#include "spm_func.h"
#include "tfm_hal_platform.h"
#include "tfm_irq_list.h"
#include "tfm_nspm.h"
#include "tfm_spm_hal.h"
+#include "tfm_spm_log.h"
#include "tfm_version.h"
/*
@@ -30,6 +30,12 @@
#error Only TFM_LVL 1 is supported for library model!
#endif
+#define PRINT_TFM_VERSION SPMLOG_INFMSGVAL("Booting TFM v", VERSION_MAJOR); \
+ SPMLOG_INFMSGVAL(".", VERSION_MINOR); \
+ SPMLOG_INFMSG(" "); \
+ SPMLOG_INFMSG(VERSION_STRING); \
+ SPMLOG_INFMSG("\r\n")
+
REGION_DECLARE(Image$$, ARM_LIB_STACK_MSP, $$ZI$$Base);
static int32_t tfm_core_init(void)
@@ -75,10 +81,11 @@
/* Configures architecture-specific coprocessors */
tfm_arch_configure_coprocessors();
- LOG_MSG("\033[1;34m[Sec Thread] Secure image initializing!\033[0m\r\n");
+ SPMLOG_INFMSG("\033[1;34m[Sec Thread] Secure image initializing!\033[0m\r\n");
#ifdef TFM_CORE_DEBUG
- LOG_MSG("TF-M isolation level is: %d\r\n", TFM_LVL);
+ SPMLOG_DBGMSGVAL("TF-M isolation level is: ", TFM_LVL);
+ SPMLOG_DBGMSG("\r\n");
#endif
tfm_core_validate_boot_data();
@@ -131,8 +138,7 @@
tfm_core_panic();
}
/* Print the TF-M version */
- LOG_MSG("\033[1;34mBooting TFM v%d.%d %s\033[0m\r\n",
- VERSION_MAJOR, VERSION_MINOR, VERSION_STRING);
+ PRINT_TFM_VERSION;
if (tfm_spm_db_init() != SPM_ERR_OK) {
tfm_core_panic();
@@ -173,7 +179,7 @@
#ifdef TFM_CORE_DEBUG
/* Jumps to non-secure code */
- LOG_MSG("\033[1;34mJumping to non-secure code...\033[0m\r\n");
+ SPMLOG_DBGMSG("\033[1;34mJumping to non-secure code...\033[0m\r\n");
#endif
jump_to_ns_code();
diff --git a/secure_fw/spm/cmsis_psa/main.c b/secure_fw/spm/cmsis_psa/main.c
index 6ddec00..e539de6 100644
--- a/secure_fw/spm/cmsis_psa/main.c
+++ b/secure_fw/spm/cmsis_psa/main.c
@@ -6,13 +6,13 @@
*/
#include "common/tfm_boot_data.h"
-#include "log/tfm_log.h"
#include "region.h"
#include "spm_ipc.h"
#include "tfm_hal_platform.h"
#include "tfm_irq_list.h"
#include "tfm_nspm.h"
#include "tfm_spm_hal.h"
+#include "tfm_spm_log.h"
#include "tfm_version.h"
/*
@@ -29,6 +29,12 @@
#error Only TFM_LVL 1 and 2 are supported for IPC model!
#endif
+#define PRINT_TFM_VERSION SPMLOG_INFMSGVAL("Booting TFM v", VERSION_MAJOR); \
+ SPMLOG_INFMSGVAL(".", VERSION_MINOR); \
+ SPMLOG_INFMSG(" "); \
+ SPMLOG_INFMSG(VERSION_STRING); \
+ SPMLOG_INFMSG("\r\n")
+
REGION_DECLARE(Image$$, ARM_LIB_STACK_MSP, $$ZI$$Base);
static int32_t tfm_core_init(void)
@@ -74,10 +80,11 @@
/* Configures architecture-specific coprocessors */
tfm_arch_configure_coprocessors();
- LOG_MSG("\033[1;34m[Sec Thread] Secure image initializing!\033[0m\r\n");
+ SPMLOG_INFMSG("\033[1;34m[Sec Thread] Secure image initializing!\033[0m\r\n");
#ifdef TFM_CORE_DEBUG
- LOG_MSG("TF-M isolation level is: %d\r\n", TFM_LVL);
+ SPMLOG_DBGMSGVAL("TF-M isolation level is: ", TFM_LVL);
+ SPMLOG_DBGMSG("\r\n");
#endif
tfm_core_validate_boot_data();
@@ -126,8 +133,7 @@
tfm_core_panic();
}
/* Print the TF-M version */
- LOG_MSG("\033[1;34mBooting TFM v%d.%d %s\033[0m\r\n",
- VERSION_MAJOR, VERSION_MINOR, VERSION_STRING);
+ PRINT_TFM_VERSION;
if (tfm_spm_db_init() != SPM_ERR_OK) {
tfm_core_panic();
diff --git a/secure_fw/spm/cmsis_psa/tfm_multi_core.c b/secure_fw/spm/cmsis_psa/tfm_multi_core.c
index c40b415..c985e90 100644
--- a/secure_fw/spm/cmsis_psa/tfm_multi_core.c
+++ b/secure_fw/spm/cmsis_psa/tfm_multi_core.c
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include "tfm_spm_hal.h"
#include "psa/client.h"
+#include "tfm_assert.h"
#include "tfm_nspm.h"
#include "tfm_spe_mailbox.h"
+#include "tfm_spm_hal.h"
+#include "tfm_spm_log.h"
#include "utilities.h"
-#include "log/tfm_assert.h"
-#include "log/tfm_log.h"
-#include "log/tfm_assert.h"
#define DEFAULT_NS_CLIENT_ID (-1)
@@ -24,7 +23,7 @@
{
#ifdef TFM_CORE_DEBUG
/* Boot up non-secure core */
- LOG_MSG("Enabling non-secure core...");
+ SPMLOG_DBGMSG("Enabling non-secure core...");
#endif
tfm_spm_hal_boot_ns_cpu(tfm_spm_hal_get_ns_VTOR());
diff --git a/secure_fw/spm/cmsis_psa/tfm_nspm_ipc.c b/secure_fw/spm/cmsis_psa/tfm_nspm_ipc.c
index 32c2a9c..00e2d92 100644
--- a/secure_fw/spm/cmsis_psa/tfm_nspm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/tfm_nspm_ipc.c
@@ -11,8 +11,6 @@
#include "tfm_nspm.h"
#include "utilities.h"
#include "ext/tz_context.h"
-#include "log/tfm_assert.h"
-#include "log/tfm_log.h"
#define DEFAULT_NS_CLIENT_ID ((int32_t)-1)
diff --git a/secure_fw/spm/include/tfm_assert.h b/secure_fw/spm/include/tfm_assert.h
new file mode 100644
index 0000000..803a70d
--- /dev/null
+++ b/secure_fw/spm/include/tfm_assert.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_ASSERT_H__
+#define __TFM_ASSERT_H__
+
+#include "tfm_spm_log.h"
+
+/* Functions and macros in this file is for 'thread mode' usage. */
+
+#define TFM_ASSERT(cond) \
+ do { \
+ if (!(cond)) { \
+ SPMLOG_INFMSG("Assert:"); \
+ SPMLOG_INFMSG(__FUNCTION__); \
+ SPMLOG_INFMSGVAL(",", __LINE__); \
+ while (1) \
+ ; \
+ } \
+ } while (0)
+
+#endif /* __TFM_ASSERT_H__ */