blob: 814cf8402a19f0019ffa0adf51d1fe35890ef1ad [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__
27#include <stdio.h>
Dan Handleycba2c502014-08-08 14:36:42 +010028
29#if LOG_LEVEL >= LOG_LEVEL_NOTICE
30# define NOTICE(...) tf_printf("NOTICE: " __VA_ARGS__)
31#else
32# define NOTICE(...)
33#endif
34
35#if LOG_LEVEL >= LOG_LEVEL_ERROR
36# define ERROR(...) tf_printf("ERROR: " __VA_ARGS__)
37#else
38# define ERROR(...)
39#endif
40
41#if LOG_LEVEL >= LOG_LEVEL_WARNING
42# define WARN(...) tf_printf("WARNING: " __VA_ARGS__)
43#else
44# define WARN(...)
45#endif
46
47#if LOG_LEVEL >= LOG_LEVEL_INFO
48# define INFO(...) tf_printf("INFO: " __VA_ARGS__)
49#else
50# define INFO(...)
51#endif
52
53#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
54# define VERBOSE(...) tf_printf("VERBOSE: " __VA_ARGS__)
Harry Liebel57bb6582013-12-19 13:30:58 +000055#else
Dan Handleycba2c502014-08-08 14:36:42 +010056# define VERBOSE(...)
Harry Liebel57bb6582013-12-19 13:30:58 +000057#endif
58
Harry Liebel57bb6582013-12-19 13:30:58 +000059
Dan Handleya17fefa2014-05-14 12:38:32 +010060void __dead2 do_panic(void);
Soby Mathew5e5c2072014-04-07 15:28:55 +010061#define panic() do_panic()
62
Douglas Raillard306593d2017-02-24 18:14:15 +000063/* Function called when stack protection check code detects a corrupted stack */
64void __dead2 __stack_chk_fail(void);
65
Sandrine Bailleux8723adf2015-02-05 15:42:31 +000066void tf_printf(const char *fmt, ...) __printflike(1, 2);
Antonio Nino Diaz9c107fa2017-05-17 15:34:22 +010067int tf_snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4);
Soby Mathewafe7e2f2014-06-12 17:23:58 +010068
Soby Mathew6b28c572016-03-21 10:36:47 +000069#endif /* __ASSEMBLY__ */
Harry Liebel57bb6582013-12-19 13:30:58 +000070#endif /* __DEBUG_H__ */