coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
console.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef CONSOLE_CONSOLE_H_
4 #define CONSOLE_CONSOLE_H_
5 
7 #include <console/vtxprintf.h>
8 #include <stdint.h>
9 
10 /* console.h is supposed to provide the log levels defined in here: */
11 #include <commonlib/loglevel.h>
12 
13 #define RAM_DEBUG (CONFIG(DEBUG_RAM_SETUP) ? BIOS_DEBUG : BIOS_NEVER)
14 #define RAM_SPEW (CONFIG(DEBUG_RAM_SETUP) ? BIOS_SPEW : BIOS_NEVER)
15 
16 void post_code(u8 value);
17 void mainboard_post(u8 value);
18 void arch_post_code(u8 value);
19 
20 void __noreturn die(const char *fmt, ...);
21 #define die_with_post_code(value, fmt, ...) \
22  do { post_code(value); die(fmt, ##__VA_ARGS__); } while (0)
23 
24 /*
25  * This function is weak and can be overridden to provide additional
26  * feedback to the user. Possible use case: Play a beep.
27  */
28 void die_notify(void);
29 
30 #if CONFIG(CONSOLE_OVERRIDE_LOGLEVEL)
31 /*
32  * This function should be implemented at mainboard level.
33  * The returned value will _replace_ the loglevel value;
34  */
35 int get_console_loglevel(void);
36 #else
37 static inline int get_console_loglevel(void)
38 {
39  return CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
40 }
41 #endif
42 
43 #define __CONSOLE_ENABLE__ \
44  ((ENV_BOOTBLOCK && CONFIG(BOOTBLOCK_CONSOLE)) || \
45  (ENV_POSTCAR && CONFIG(POSTCAR_CONSOLE)) || \
46  ENV_SEPARATE_VERSTAGE || ENV_ROMSTAGE || ENV_RAMSTAGE || \
47  ENV_LIBAGESA || (ENV_SMM && CONFIG(DEBUG_SMI)))
48 
49 #if __CONSOLE_ENABLE__
50 int get_log_level(void);
51 void console_init(void);
52 int console_log_level(int msg_level);
53 
54 int printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
55 int vprintk(int msg_level, const char *fmt, va_list args);
56 
57 void do_putchar(unsigned char byte);
58 
59 /* Return number of microseconds elapsed from start of stage or the previous
60  get_and_reset() call. */
62 void console_time_report(void);
63 
64 /*
65  * "Fast" basically means only the CBMEM console right now. This is used to still
66  * print debug messages there when loglevel disables the other consoles. It is also
67  * used to compile-time eliminate code paths that only affect "interactive" consoles
68  * (which are all "slow") when none of those are enabled.
69  */
70 enum { CONSOLE_LOG_NONE = 0, CONSOLE_LOG_FAST, CONSOLE_LOG_ALL };
71 #define HAS_ONLY_FAST_CONSOLES !(CONFIG(SPKMODEM) || CONFIG(CONSOLE_QEMU_DEBUGCON) || \
72  CONFIG(CONSOLE_SERIAL) || CONFIG(CONSOLE_NE2K) || CONFIG(CONSOLE_USB) || \
73  CONFIG(EM100PRO_SPI_CONSOLE) || CONFIG(CONSOLE_SPI_FLASH) || \
74  CONFIG(CONSOLE_SYSTEM76_EC))
75 
76 #else
77 static inline int get_log_level(void) { return -1; }
78 static inline void console_init(void) {}
79 static inline int console_log_level(int msg_level) { return 0; }
80 static inline int
81  __attribute__((format(printf, 2, 3)))
82  printk(int LEVEL, const char *fmt, ...) { return 0; }
83 static inline int vprintk(int LEVEL, const char *fmt, va_list args) { return 0; }
84 static inline void do_putchar(unsigned char byte) {}
85 static inline long console_time_get_and_reset(void) { return 0; }
86 static inline void console_time_report(void) {}
87 #endif
88 
89 #endif /* CONSOLE_CONSOLE_H_ */
pte_t value
Definition: mmu.c:91
struct @413::@414 args
#define __noreturn
Definition: compiler.h:31
static void do_putchar(unsigned char byte)
Definition: console.h:84
void arch_post_code(u8 value)
Definition: post.c:8
void die_notify(void)
Definition: die.c:12
static int get_console_loglevel(void)
Definition: console.h:37
static int console_log_level(int msg_level)
Definition: console.h:79
static int vprintk(int LEVEL, const char *fmt, va_list args)
Definition: console.h:83
void mainboard_post(u8 value)
Definition: post.c:12
static int printk(int LEVEL, const char *fmt,...)
Definition: console.h:82
void __noreturn die(const char *fmt,...)
Definition: die.c:17
void post_code(u8 value)
Definition: post.c:14
static void console_time_report(void)
Definition: console.h:86
static int get_log_level(void)
Definition: console.h:77
static long console_time_get_and_reset(void)
Definition: console.h:85
static void console_init(void)
Definition: console.h:78
#define printf(x...)
Definition: debug.h:47
Definitions of the log levels to be used in printk calls.
__builtin_va_list va_list
Definition: stdarg.h:16
uint8_t u8
Definition: stdint.h:45