xref: /aosp_15_r20/external/coreboot/util/cbfstool/console/console.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _CBFSTOOL_CONSOLE_H_
4 #define _CBFSTOOL_CONSOLE_H_
5 
6 #include <stdio.h>
7 #include <commonlib/loglevel.h>
8 
9 /* Message output */
10 extern int verbose;
11 #define ERROR(...) fprintf(stderr, "E: " __VA_ARGS__)
12 #define WARN(...) fprintf(stderr, "W: " __VA_ARGS__)
13 #define LOG(...) fprintf(stderr, __VA_ARGS__)
14 #define INFO(...) do { if (verbose > 0) fprintf(stderr, "INFO: " __VA_ARGS__); } while (0)
15 #define DEBUG(...) do { if (verbose > 1) fprintf(stderr, "DEBUG: " __VA_ARGS__); } while (0)
16 
17 
18 #define printk(lvl, ...) \
19 	do {						\
20 		if ((lvl) <= BIOS_ERR) {		\
21 			ERROR(__VA_ARGS__);		\
22 		} else if ((lvl) <= BIOS_NOTICE) {	\
23 			WARN(__VA_ARGS__);		\
24 		} else if ((lvl) <= BIOS_INFO) {	\
25 			INFO(__VA_ARGS__);		\
26 		} else if ((lvl) <= BIOS_DEBUG) {	\
27 			DEBUG(__VA_ARGS__);		\
28 		}					\
29 	} while (0)
30 
31 #endif
32