xref: /rk3399_ARM-atf/include/common/debug.h (revision a43d431b80541ea436b71f967c5749babf978c7a)
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 
364ecca339SDan Handley /* If building the project with DEBUG disabled the INFO and WARN macros
374ecca339SDan Handley  * won't produce any output. The ERROR macro is always enabled.
384ecca339SDan Handley  * The format expected is the same as for printf().
394ecca339SDan Handley  * INFO("Info %s.\n", "message")    -> INFO: Info message.
404ecca339SDan Handley  * WARN("Warning %s.\n", "message") -> WARN: Warning message.
414ecca339SDan Handley  * ERROR("Error %s.\n", "message")  -> ERROR: Error message.
424ecca339SDan Handley  *
434ecca339SDan Handley  * TODO : add debug levels.
444ecca339SDan Handley  */
454ecca339SDan Handley #if DEBUG
464ecca339SDan Handley  #define INFO(...)	printf("INFO: " __VA_ARGS__)
474ecca339SDan Handley  #define WARN(...)	printf("WARN: " __VA_ARGS__)
484ecca339SDan Handley #else
494ecca339SDan Handley  #define INFO(...)
504ecca339SDan Handley  #define WARN(...)
514ecca339SDan Handley #endif
524ecca339SDan Handley 
534ecca339SDan Handley #define ERROR(...)	printf("ERROR: " __VA_ARGS__)
544ecca339SDan Handley 
554ecca339SDan Handley 
564ecca339SDan Handley /* For the moment this Panic function is very basic, Report an error and
574ecca339SDan Handley  * spin. This can be expanded in the future to provide more information.
584ecca339SDan Handley  */
59*a43d431bSSoby Mathew #if DEBUG
60*a43d431bSSoby Mathew extern void __dead2 do_panic(const char *file, int line);
61*a43d431bSSoby Mathew #define panic()	do_panic(__FILE__, __LINE__)
62*a43d431bSSoby Mathew 
63*a43d431bSSoby Mathew #else
64*a43d431bSSoby Mathew extern void __dead2 do_panic(void);
65*a43d431bSSoby Mathew #define panic()	do_panic()
66*a43d431bSSoby Mathew 
67*a43d431bSSoby Mathew #endif
68*a43d431bSSoby Mathew 
69*a43d431bSSoby Mathew extern void print_string_value(char *s, unsigned long *mem);
704ecca339SDan Handley 
714ecca339SDan Handley #endif /* __DEBUG_H__ */
72