LIB: Replace SPM log with tfm_log
Replace the existing SPM log library with the new tfm_log library. This
patch aims to maintain existing behaviour by using a format specifier
which matches the existing implementation.
Change-Id: I5871b5429e4f051fdede87063bfe3ebbe49847f9
Signed-off-by: Jackson Cooper-Driver <jackson.cooper-driver@arm.com>
diff --git a/secure_fw/spm/include/private/assert.h b/secure_fw/spm/include/private/assert.h
index 5f5174c..2a82da6 100644
--- a/secure_fw/spm/include/private/assert.h
+++ b/secure_fw/spm/include/private/assert.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2024, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -8,19 +8,17 @@
#define __TFM_PRIV_ASSERT_H__
#include <string.h>
-#include "tfm_spm_log.h"
+#include "tfm_log.h"
#ifndef NDEBUG
-#define SPM_ASSERT(cond) \
- do { \
- if (!(cond)) { \
- SPMLOG_INFMSG("Assert:"); \
- SPMLOG_INFMSG(__func__); \
- SPMLOG_INFMSGVAL(",", __LINE__); \
- while (1) { \
- ; \
- } \
- } \
+#define SPM_ASSERT(cond) \
+ do { \
+ if (!(cond)) { \
+ INFO_RAW("Assert: %s, %d\n", __func__, __LINE__); \
+ while (1) { \
+ ; \
+ } \
+ } \
} while (0)
#else
#define SPM_ASSERT(cond)
diff --git a/secure_fw/spm/include/tfm_spm_log.h b/secure_fw/spm/include/tfm_spm_log.h
deleted file mode 100644
index 2062cbc..0000000
--- a/secure_fw/spm/include/tfm_spm_log.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __TFM_SPM_LOG_H__
-#define __TFM_SPM_LOG_H__
-
-#include <stddef.h>
-#include <stdint.h>
-#include "tfm_hal_defs.h"
-#include "tfm_hal_spm_logdev.h"
-
-/* The SPM log levels */
-#define TFM_SPM_LOG_LEVEL_DEBUG 3 /* All log APIs output */
-#define TFM_SPM_LOG_LEVEL_INFO 2 /*
- * All log APIs output except SPMLOG_DBG
- * and SPMLOG_DBGMSGVAL
- */
-#define TFM_SPM_LOG_LEVEL_ERROR 1 /*
- * Only SPMLOG_ERRMSG and SPMLOG_ERRMSGVAL
- * APIs output.
- */
-#define TFM_SPM_LOG_LEVEL_SILENCE 0 /* All log APIs are suppressed */
-
-#ifndef TFM_SPM_LOG_LEVEL
-#error "TFM_SPM_LOG_LEVEL not defined!"
-#endif
-
-#if ((TFM_SPM_LOG_LEVEL > TFM_SPM_LOG_LEVEL_DEBUG) || \
- (TFM_SPM_LOG_LEVEL < TFM_SPM_LOG_LEVEL_SILENCE))
-#error "Incorrect TFM_SPM_LOG_LEVEL value!"
-#endif
-
-#if (TFM_SPM_LOG_LEVEL == TFM_SPM_LOG_LEVEL_DEBUG)
-#define SPMLOG_DBGMSGVAL(msg, val) spm_log_msgval(msg, sizeof(msg), val)
-#define SPMLOG_DBGMSG(msg) tfm_hal_output_spm_log(msg, sizeof(msg))
-#else
-#define SPMLOG_DBGMSGVAL(msg, val) (void)(val)
-#define SPMLOG_DBGMSG(msg)
-#endif
-
-#if (TFM_SPM_LOG_LEVEL >= TFM_SPM_LOG_LEVEL_INFO)
-#define SPMLOG_INFMSGVAL(msg, val) spm_log_msgval(msg, sizeof(msg), val)
-#define SPMLOG_INFMSG(msg) tfm_hal_output_spm_log(msg, sizeof(msg))
-#else
-#define SPMLOG_INFMSGVAL(msg, val) (void)(val)
-#define SPMLOG_INFMSG(msg)
-#endif
-
-#if (TFM_SPM_LOG_LEVEL >= TFM_SPM_LOG_LEVEL_ERROR)
-#define SPMLOG_ERRMSGVAL(msg, val) spm_log_msgval(msg, sizeof(msg), val)
-#define SPMLOG_ERRMSG(msg) tfm_hal_output_spm_log(msg, sizeof(msg))
-#else
-#define SPMLOG_ERRMSGVAL(msg, val) (void)(val)
-#define SPMLOG_ERRMSG(msg)
-#endif
-
-/**
- * \brief SPM output API to convert digit number into HEX string and call the
- * HAL API tfm_hal_output_spm_log.
- *
- * \param[in] msg A string message
- * \param[in] len The length of the message
- * \param[in] value A value need to be output
- *
- * \retval >=0 Number of chars output.
- * \retval <0 TFM HAL error code.
- */
-int32_t spm_log_msgval(const char *msg, size_t len, uint32_t value);
-
-#endif /* __TFM_SPM_LOG_H__ */
diff --git a/secure_fw/spm/include/utilities.h b/secure_fw/spm/include/utilities.h
index 4f76081..36f9588 100644
--- a/secure_fw/spm/include/utilities.h
+++ b/secure_fw/spm/include/utilities.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2022, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -8,7 +8,7 @@
#define __TFM_UTILS_H__
#include <string.h>
-#include "tfm_spm_log.h"
+#include "tfm_log.h"
/*
* CPU spin here.
@@ -20,8 +20,7 @@
#define TO_CONTAINER(ptr, type, member) \
((type *)((unsigned long)(ptr) - offsetof(type, member)))
-/* FixMe: Replace ERROR_MSG() in platform code with a suitable API */
-#define ERROR_MSG(msg) SPMLOG_ERRMSG(msg "\r\n")
+#define ERROR_MSG(msg) ERROR_RAW(msg "\n")
/* Stringify preprocessors, no leading underscore. ('STRINGIFY') */
#define STRINGIFY_EXPAND(x) #x