Harry Liebel | 57bb658 | 2013-12-19 13:30:58 +0000 | [diff] [blame] | 1 | /* |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. |
Harry Liebel | 57bb658 | 2013-12-19 13:30:58 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Harry Liebel | 57bb658 | 2013-12-19 13:30:58 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __DEBUG_H__ |
| 8 | #define __DEBUG_H__ |
| 9 | |
Dan Handley | cba2c50 | 2014-08-08 14:36:42 +0100 | [diff] [blame] | 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. |
Harry Liebel | 57bb658 | 2013-12-19 13:30:58 +0000 | [diff] [blame] | 17 | */ |
Dan Handley | cba2c50 | 2014-08-08 14:36:42 +0100 | [diff] [blame] | 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 | |
Soby Mathew | 6b28c57 | 2016-03-21 10:36:47 +0000 | [diff] [blame] | 26 | #ifndef __ASSEMBLY__ |
| 27 | #include <stdio.h> |
Dan Handley | cba2c50 | 2014-08-08 14:36:42 +0100 | [diff] [blame] | 28 | |
| 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 Liebel | 57bb658 | 2013-12-19 13:30:58 +0000 | [diff] [blame] | 55 | #else |
Dan Handley | cba2c50 | 2014-08-08 14:36:42 +0100 | [diff] [blame] | 56 | # define VERBOSE(...) |
Harry Liebel | 57bb658 | 2013-12-19 13:30:58 +0000 | [diff] [blame] | 57 | #endif |
| 58 | |
Harry Liebel | 57bb658 | 2013-12-19 13:30:58 +0000 | [diff] [blame] | 59 | |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 60 | void __dead2 do_panic(void); |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 61 | #define panic() do_panic() |
| 62 | |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 63 | /* Function called when stack protection check code detects a corrupted stack */ |
| 64 | void __dead2 __stack_chk_fail(void); |
| 65 | |
Sandrine Bailleux | 8723adf | 2015-02-05 15:42:31 +0000 | [diff] [blame] | 66 | void tf_printf(const char *fmt, ...) __printflike(1, 2); |
Antonio Nino Diaz | 9c107fa | 2017-05-17 15:34:22 +0100 | [diff] [blame] | 67 | int tf_snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4); |
Soby Mathew | afe7e2f | 2014-06-12 17:23:58 +0100 | [diff] [blame] | 68 | |
Soby Mathew | 6b28c57 | 2016-03-21 10:36:47 +0000 | [diff] [blame] | 69 | #endif /* __ASSEMBLY__ */ |
Harry Liebel | 57bb658 | 2013-12-19 13:30:58 +0000 | [diff] [blame] | 70 | #endif /* __DEBUG_H__ */ |