blob: fa60a0391657044807ff8062fe514a75335e455a [file] [log] [blame]
Jackson Cooper-Drivered984c92024-08-14 16:12:40 +01001/*
Jackson Cooper-Driver5188b1e2025-03-03 13:55:45 +00002 * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
Jackson Cooper-Drivered984c92024-08-14 16:12:40 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7/*
8 * Based on TF-A include/common/debug.h
9 */
10
11#ifndef __TF_M_VPRINTF_H__
12#define __TF_M_VPRINTF_H__
13
14#include <stdbool.h>
15#include <stdint.h>
16#include <stdarg.h>
17
18/*
19 * The log output macros print output to the console. These macros produce
20 * compiled log output only if the LOG_LEVEL defined in the CMake (or the
21 * make command line) is greater or equal than the level required for that
22 * type of log output.
23 *
24 * The format expected is the same as for printf(). For example:
25 * INFO("Info %s.\n", "message") -> '[INF]: Info message.'
26 * WARN("Warning %s.\n", "message") ->'[WAR]: Warning message.'
27 */
28#define LOG_LEVEL_NONE UINT8_C(0)
29#define LOG_LEVEL_ERROR UINT8_C(10)
30#define LOG_LEVEL_NOTICE UINT8_C(20)
31#define LOG_LEVEL_WARNING UINT8_C(30)
32#define LOG_LEVEL_INFO UINT8_C(40)
33#define LOG_LEVEL_VERBOSE UINT8_C(50)
34
35/*
36 * Define Log Markers corresponding to each log level which will
37 * be embedded in the format string and is expected by tfm_vprintf() to determine
38 * the log level.
39 */
40#define LOG_MARKER_ERROR "\xa" /* 10 */
41#define LOG_MARKER_NOTICE "\x14" /* 20 */
42#define LOG_MARKER_WARNING "\x1e" /* 30 */
43#define LOG_MARKER_INFO "\x28" /* 40 */
44#define LOG_MARKER_VERBOSE "\x32" /* 50 */
Jackson Cooper-Driver5188b1e2025-03-03 13:55:45 +000045#define LOG_MARKER_RAW "\x3c" /* 60 */
Jackson Cooper-Drivered984c92024-08-14 16:12:40 +010046
47/* Function called to output a string to the terminal */
Antonio de Angelis4f021312024-11-09 21:02:33 +000048typedef void (*tfm_log_output_str)(void *priv, const char *str, uint32_t len);
Jackson Cooper-Drivered984c92024-08-14 16:12:40 +010049
50/* Function to generate formatted string and pass to output_func */
51void tfm_vprintf(tfm_log_output_str output_func, void *priv, const char *fmt, va_list args);
52
53#endif /* __TF_M_VPRINTF_H__ */