SPRTL: Override toolchain 'printf'
There were unnecessary toolchain symbols got involved when overriding
'printf' in the old code base, it was caused by the code referencing
other stdio symbols. As these references are now cleaned, overriding
'printf' can proceed.
Background:
This is the first patch for upcoming log udpates. For isolation
consideration, the SPM log system was separated from the partition
log system. But as TF-M reference chooses no isolating code between
components, and the separation costs extra code size which makes less
significance. To enhance this, the log output would base on 'printf'
family shared between SPM and partitions.
The LOG API/preprocessor name for SPM are different to those partition
LOG API/preprocessor. This leaves the chance for forwarding the LOG API
to other implementations for them when there are potential isolation
requriements (again).
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
Change-Id: I240c87aae668ae244d7d2ae3a505a9155b10dac6
diff --git a/secure_fw/partitions/crypto/crypto_init.c b/secure_fw/partitions/crypto/crypto_init.c
index 9bc9ead..6fe8c83 100644
--- a/secure_fw/partitions/crypto/crypto_init.c
+++ b/secure_fw/partitions/crypto/crypto_init.c
@@ -303,7 +303,7 @@
/* mbedtls_printf is used to print messages including error information. */
#if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_ERROR)
- mbedtls_platform_set_printf(tfm_sp_log_printf);
+ mbedtls_platform_set_printf(printf);
#endif
/* Initialise the crypto accelerator if one is enabled. If the driver API is
diff --git a/secure_fw/partitions/lib/runtime/include/tfm_sp_log.h b/secure_fw/partitions/lib/runtime/include/tfm_sp_log.h
index bf2f67d..5c3b9b9 100644
--- a/secure_fw/partitions/lib/runtime/include/tfm_sp_log.h
+++ b/secure_fw/partitions/lib/runtime/include/tfm_sp_log.h
@@ -33,48 +33,24 @@
#endif
#if (TFM_PARTITION_LOG_LEVEL == TFM_PARTITION_LOG_LEVEL_DEBUG)
-#define LOG_DBGFMT(...) tfm_sp_log_printf(__VA_ARGS__)
+#define LOG_DBGFMT(...) printf(__VA_ARGS__)
#else
#define LOG_DBGFMT(...)
#endif
#if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_INFO)
-#define LOG_INFFMT(...) tfm_sp_log_printf(__VA_ARGS__)
+#define LOG_INFFMT(...) printf(__VA_ARGS__)
#else
#define LOG_INFFMT(...)
#endif
#if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_ERROR)
-#define LOG_ERRFMT(...) tfm_sp_log_printf(__VA_ARGS__)
+#define LOG_ERRFMT(...) printf(__VA_ARGS__)
#else
#define LOG_ERRFMT(...)
#endif
-/**
- * \brief Print log messages
- *
- * \param[in] fmt Formatted string
- * \param[in] ... Variable length argument
- *
- * \retval >= 0 Number of chars printed
- * \retval < 0 TF-M HAL error code
- *
- * \note This function has the similar input argument format as
- * the 'printf' function. But it supports only some basic
- * formats like 'sdicpuxX' and '%'. It will output
- * "[Unsupported Tag]" when none of the above formats match
- *
- * \details The following output formats are supported.
- * %s - string
- * %d - decimal signed integer (same for %i)
- * %u - decimal unsigned integer
- * %x - hex in lowercase
- * %X - hex in uppercase
- * %p - hex address of a pointer in lowercase
- * %c - character
- * %% - the '%' symbol
- */
-int tfm_sp_log_printf(const char *fmt, ...);
+int printf(const char *fmt, ...);
#ifdef __cplusplus
}
diff --git a/secure_fw/partitions/lib/runtime/tfm_sp_log_raw.c b/secure_fw/partitions/lib/runtime/tfm_sp_log_raw.c
index 8a8d462..6129c9c 100644
--- a/secure_fw/partitions/lib/runtime/tfm_sp_log_raw.c
+++ b/secure_fw/partitions/lib/runtime/tfm_sp_log_raw.c
@@ -162,7 +162,7 @@
return count;
}
-int tfm_sp_log_printf(const char *fmt, ...)
+int printf(const char *fmt, ...)
{
int count = 0;
va_list ap;