LIB: Add _RAW macros
These macros allow for printing raw strings without any prefix (such as
[DGB] etc.). They are useful for porting existing logging library usage
to the new logging API.
Change-Id: I90acbfb3fb0c9bbe8fc3938b7ac79a82d2151138
Signed-off-by: Jackson Cooper-Driver <jackson.cooper-driver@arm.com>
diff --git a/lib/tfm_vprintf/inc/tfm_vprintf.h b/lib/tfm_vprintf/inc/tfm_vprintf.h
index ed0cc25..fa60a03 100644
--- a/lib/tfm_vprintf/inc/tfm_vprintf.h
+++ b/lib/tfm_vprintf/inc/tfm_vprintf.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2024, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -42,6 +42,7 @@
#define LOG_MARKER_WARNING "\x1e" /* 30 */
#define LOG_MARKER_INFO "\x28" /* 40 */
#define LOG_MARKER_VERBOSE "\x32" /* 50 */
+#define LOG_MARKER_RAW "\x3c" /* 60 */
/* Function called to output a string to the terminal */
typedef void (*tfm_log_output_str)(void *priv, const char *str, uint32_t len);
diff --git a/lib/tfm_vprintf/src/tfm_vprintf.c b/lib/tfm_vprintf/src/tfm_vprintf.c
index 02164ee..7878fb8 100644
--- a/lib/tfm_vprintf/src/tfm_vprintf.c
+++ b/lib/tfm_vprintf/src/tfm_vprintf.c
@@ -15,6 +15,8 @@
#include "tfm_vprintf.h"
+#define LOG_RAW_VALUE UINT8_C(60)
+
static inline const char *get_log_prefix(uint8_t log_level)
{
switch(log_level) {
@@ -213,15 +215,17 @@
void tfm_vprintf(tfm_log_output_str output_func, void *priv, const char *fmt, va_list args)
{
- uint8_t log_level;
+ uint8_t log_marker;
const char spacer = ' ';
/* We expect the LOG_MARKER_* macro as the first character */
- log_level = fmt[0];
+ log_marker = fmt[0];
fmt++;
- output_str_not_formatted(output_func, priv, get_log_prefix(log_level));
- output_char(output_func, priv, spacer);
+ if (log_marker != LOG_RAW_VALUE) {
+ output_str_not_formatted(output_func, priv, get_log_prefix(log_marker));
+ output_char(output_func, priv, spacer);
+ }
tfm_vprintf_internal(output_func, priv, fmt, args);
}