xref: /rk3399_ARM-atf/include/common/debug.h (revision 2d7e82823dc28ccfa776dc0ecdaeeda8c465bf62)
1 /*
2  * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef __DEBUG_H__
8 #define __DEBUG_H__
9 
10 /* The log output macros print output to the console. These macros produce
11  * compiled log output only if the LOG_LEVEL defined in the makefile (or the
12  * make command line) is greater or equal than the level required for that
13  * type of log output.
14  * The format expected is the same as for printf(). For example:
15  * INFO("Info %s.\n", "message")    -> INFO:    Info message.
16  * WARN("Warning %s.\n", "message") -> WARNING: Warning message.
17  */
18 
19 #define LOG_LEVEL_NONE			0
20 #define LOG_LEVEL_ERROR			10
21 #define LOG_LEVEL_NOTICE		20
22 #define LOG_LEVEL_WARNING		30
23 #define LOG_LEVEL_INFO			40
24 #define LOG_LEVEL_VERBOSE		50
25 
26 #ifndef __ASSEMBLY__
27 #include <stdarg.h>
28 #include <stdio.h>
29 
30 #if LOG_LEVEL >= LOG_LEVEL_NOTICE
31 # define NOTICE(...)	tf_printf("NOTICE:  " __VA_ARGS__)
32 #else
33 # define NOTICE(...)
34 #endif
35 
36 #if LOG_LEVEL >= LOG_LEVEL_ERROR
37 # define ERROR(...)	tf_printf("ERROR:   " __VA_ARGS__)
38 #else
39 # define ERROR(...)
40 #endif
41 
42 #if LOG_LEVEL >= LOG_LEVEL_WARNING
43 # define WARN(...)	tf_printf("WARNING: " __VA_ARGS__)
44 #else
45 # define WARN(...)
46 #endif
47 
48 #if LOG_LEVEL >= LOG_LEVEL_INFO
49 # define INFO(...)	tf_printf("INFO:    " __VA_ARGS__)
50 #else
51 # define INFO(...)
52 #endif
53 
54 #if LOG_LEVEL >= LOG_LEVEL_VERBOSE
55 # define VERBOSE(...)	tf_printf("VERBOSE: " __VA_ARGS__)
56 #else
57 # define VERBOSE(...)
58 #endif
59 
60 
61 void __dead2 do_panic(void);
62 #define panic()	do_panic()
63 
64 /* Function called when stack protection check code detects a corrupted stack */
65 void __dead2 __stack_chk_fail(void);
66 
67 void tf_printf(const char *fmt, ...) __printflike(1, 2);
68 int tf_snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4);
69 void tf_vprintf(const char *fmt, va_list args);
70 void tf_string_print(const char *str);
71 
72 #endif /* __ASSEMBLY__ */
73 #endif /* __DEBUG_H__ */
74