blob: b8582419a334419b12dd2f788201f0c3e6c08cd0 [file] [log] [blame]
Harry Liebel57bb6582013-12-19 13:30:58 +00001/*
Douglas Raillard306593d2017-02-24 18:14:15 +00002 * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
Harry Liebel57bb6582013-12-19 13:30:58 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Harry Liebel57bb6582013-12-19 13:30:58 +00005 */
6
7#ifndef __DEBUG_H__
8#define __DEBUG_H__
9
Dan Handleycba2c502014-08-08 14:36:42 +010010/* 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.
Harry Liebel57bb6582013-12-19 13:30:58 +000017 */
Dan Handleycba2c502014-08-08 14:36:42 +010018
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
Soby Mathew6b28c572016-03-21 10:36:47 +000026#ifndef __ASSEMBLY__
Soby Mathewf583a062017-09-04 11:45:52 +010027#include <stdarg.h>
Soby Mathew6b28c572016-03-21 10:36:47 +000028#include <stdio.h>
Dan Handleycba2c502014-08-08 14:36:42 +010029
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__)
Harry Liebel57bb6582013-12-19 13:30:58 +000056#else
Dan Handleycba2c502014-08-08 14:36:42 +010057# define VERBOSE(...)
Harry Liebel57bb6582013-12-19 13:30:58 +000058#endif
59
Harry Liebel57bb6582013-12-19 13:30:58 +000060
Dan Handleya17fefa2014-05-14 12:38:32 +010061void __dead2 do_panic(void);
Soby Mathew5e5c2072014-04-07 15:28:55 +010062#define panic() do_panic()
63
Douglas Raillard306593d2017-02-24 18:14:15 +000064/* Function called when stack protection check code detects a corrupted stack */
65void __dead2 __stack_chk_fail(void);
66
Sandrine Bailleux8723adf2015-02-05 15:42:31 +000067void tf_printf(const char *fmt, ...) __printflike(1, 2);
Antonio Nino Diaz9c107fa2017-05-17 15:34:22 +010068int tf_snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4);
Soby Mathewf583a062017-09-04 11:45:52 +010069void tf_vprintf(const char *fmt, va_list args);
70void tf_string_print(const char *str);
Soby Mathewafe7e2f2014-06-12 17:23:58 +010071
Soby Mathew6b28c572016-03-21 10:36:47 +000072#endif /* __ASSEMBLY__ */
Harry Liebel57bb6582013-12-19 13:30:58 +000073#endif /* __DEBUG_H__ */