xref: /rk3399_ARM-atf/include/common/debug.h (revision dad25049cec0e30ca9771e435064ebf853d97bba)
14ecca339SDan Handley /*
24ecca339SDan Handley  * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
34ecca339SDan Handley  *
44ecca339SDan Handley  * Redistribution and use in source and binary forms, with or without
54ecca339SDan Handley  * modification, are permitted provided that the following conditions are met:
64ecca339SDan Handley  *
74ecca339SDan Handley  * Redistributions of source code must retain the above copyright notice, this
84ecca339SDan Handley  * list of conditions and the following disclaimer.
94ecca339SDan Handley  *
104ecca339SDan Handley  * Redistributions in binary form must reproduce the above copyright notice,
114ecca339SDan Handley  * this list of conditions and the following disclaimer in the documentation
124ecca339SDan Handley  * and/or other materials provided with the distribution.
134ecca339SDan Handley  *
144ecca339SDan Handley  * Neither the name of ARM nor the names of its contributors may be used
154ecca339SDan Handley  * to endorse or promote products derived from this software without specific
164ecca339SDan Handley  * prior written permission.
174ecca339SDan Handley  *
184ecca339SDan Handley  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
194ecca339SDan Handley  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
204ecca339SDan Handley  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
214ecca339SDan Handley  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
224ecca339SDan Handley  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
234ecca339SDan Handley  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
244ecca339SDan Handley  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
254ecca339SDan Handley  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
264ecca339SDan Handley  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
274ecca339SDan Handley  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
284ecca339SDan Handley  * POSSIBILITY OF SUCH DAMAGE.
294ecca339SDan Handley  */
304ecca339SDan Handley 
314ecca339SDan Handley #ifndef __DEBUG_H__
324ecca339SDan Handley #define __DEBUG_H__
334ecca339SDan Handley 
344ecca339SDan Handley #include <stdio.h>
354ecca339SDan Handley 
36289c28a8SDan Handley /* The log output macros print output to the console. These macros produce
37289c28a8SDan Handley  * compiled log output only if the LOG_LEVEL defined in the makefile (or the
38289c28a8SDan Handley  * make command line) is greater or equal than the level required for that
39289c28a8SDan Handley  * type of log output.
40289c28a8SDan Handley  * The format expected is the same as for printf(). For example:
414ecca339SDan Handley  * INFO("Info %s.\n", "message")    -> INFO:    Info message.
42289c28a8SDan Handley  * WARN("Warning %s.\n", "message") -> WARNING: Warning message.
434ecca339SDan Handley  */
44289c28a8SDan Handley 
45289c28a8SDan Handley #define LOG_LEVEL_NONE			0
46289c28a8SDan Handley #define LOG_LEVEL_ERROR			10
47289c28a8SDan Handley #define LOG_LEVEL_NOTICE		20
48289c28a8SDan Handley #define LOG_LEVEL_WARNING		30
49289c28a8SDan Handley #define LOG_LEVEL_INFO			40
50289c28a8SDan Handley #define LOG_LEVEL_VERBOSE		50
51289c28a8SDan Handley 
52289c28a8SDan Handley 
53289c28a8SDan Handley #if LOG_LEVEL >= LOG_LEVEL_NOTICE
54289c28a8SDan Handley # define NOTICE(...)	tf_printf("NOTICE:  " __VA_ARGS__)
554ecca339SDan Handley #else
56289c28a8SDan Handley # define NOTICE(...)
57289c28a8SDan Handley #endif
58289c28a8SDan Handley 
59289c28a8SDan Handley #if LOG_LEVEL >= LOG_LEVEL_ERROR
60289c28a8SDan Handley # define ERROR(...)	tf_printf("ERROR:   " __VA_ARGS__)
61289c28a8SDan Handley #else
62289c28a8SDan Handley # define ERROR(...)
63289c28a8SDan Handley #endif
64289c28a8SDan Handley 
65289c28a8SDan Handley #if LOG_LEVEL >= LOG_LEVEL_WARNING
66289c28a8SDan Handley # define WARN(...)	tf_printf("WARNING: " __VA_ARGS__)
67289c28a8SDan Handley #else
684ecca339SDan Handley # define WARN(...)
694ecca339SDan Handley #endif
704ecca339SDan Handley 
71289c28a8SDan Handley #if LOG_LEVEL >= LOG_LEVEL_INFO
72289c28a8SDan Handley # define INFO(...)	tf_printf("INFO:    " __VA_ARGS__)
73289c28a8SDan Handley #else
74289c28a8SDan Handley # define INFO(...)
75289c28a8SDan Handley #endif
76289c28a8SDan Handley 
77289c28a8SDan Handley #if LOG_LEVEL >= LOG_LEVEL_VERBOSE
78289c28a8SDan Handley # define VERBOSE(...)	tf_printf("VERBOSE: " __VA_ARGS__)
79289c28a8SDan Handley #else
80289c28a8SDan Handley # define VERBOSE(...)
81289c28a8SDan Handley #endif
82289c28a8SDan Handley 
834ecca339SDan Handley 
84c6bc0710SDan Handley void __dead2 do_panic(void);
85a43d431bSSoby Mathew #define panic()	do_panic()
86a43d431bSSoby Mathew 
87*dad25049SSandrine Bailleux void tf_printf(const char *fmt, ...) __printflike(1, 2);
88b79af934SSoby Mathew 
894ecca339SDan Handley #endif /* __DEBUG_H__ */
90