1 /* 2 * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef __DEBUG_H__ 8 #define __DEBUG_H__ 9 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. 17 */ 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 26 #ifndef __ASSEMBLY__ 27 #include <stdio.h> 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__) 55 #else 56 # define VERBOSE(...) 57 #endif 58 59 60 void __dead2 do_panic(void); 61 #define panic() do_panic() 62 63 /* Function called when stack protection check code detects a corrupted stack */ 64 void __dead2 __stack_chk_fail(void); 65 66 void tf_printf(const char *fmt, ...) __printflike(1, 2); 67 68 #endif /* __ASSEMBLY__ */ 69 #endif /* __DEBUG_H__ */ 70