1 /*
2  * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __TFM_SP_LOG_H__
9 #define __TFM_SP_LOG_H__
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 /* The Secure Partition log levels */
16 #define TFM_PARTITION_LOG_LEVEL_DEBUG     3  /* All log APIs output */
17 #define TFM_PARTITION_LOG_LEVEL_INFO      2  /*
18                                               * All log APIs output except
19                                               * LOG_DBGFMT
20                                               */
21 #define TFM_PARTITION_LOG_LEVEL_ERROR     1  /*
22                                               * Only LOG_ERRFMT APIs output.
23                                               */
24 #define TFM_PARTITION_LOG_LEVEL_SILENCE   0  /* All log APIs are suppressed */
25 
26 #ifndef TFM_PARTITION_LOG_LEVEL
27 #error "TFM_PARTITION_LOG_LEVEL not defined!"
28 #endif
29 
30 #if (TFM_PARTITION_LOG_LEVEL > TFM_PARTITION_LOG_LEVEL_DEBUG)  || \
31     (TFM_PARTITION_LOG_LEVEL < TFM_PARTITION_LOG_LEVEL_SILENCE)
32 #error "Incorrect TFM_PARTITION_LOG_LEVEL value!"
33 #endif
34 
35 #if (TFM_PARTITION_LOG_LEVEL == TFM_PARTITION_LOG_LEVEL_DEBUG)
36 #define LOG_DBGFMT(...) printf(__VA_ARGS__)
37 #else
38 #define LOG_DBGFMT(...)
39 #endif
40 
41 #if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_INFO)
42 #define LOG_INFFMT(...) printf(__VA_ARGS__)
43 #else
44 #define LOG_INFFMT(...)
45 #endif
46 
47 #if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_ERROR)
48 #define LOG_ERRFMT(...) printf(__VA_ARGS__)
49 #else
50 #define LOG_ERRFMT(...)
51 #endif
52 
53 int printf(const char *fmt, ...);
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 #endif /* __TFM_SP_LOG_H__ */
60