Documentation: Fix sphinx configuration
[coreboot.git] / src / console / init.c
blob1dba9ad6642e901f00199c9a3001e72aa2aecadd
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <commonlib/helpers.h>
4 #include <console/console.h>
5 #include <console/uart.h>
6 #include <console/streams.h>
7 #include <device/pci.h>
8 #include <option.h>
9 #include <version.h>
11 /* Mutable console log level only allowed when RAM comes online. */
12 #define CONSOLE_LEVEL_CONST !ENV_STAGE_HAS_DATA_SECTION
14 static int console_inited;
15 static int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
17 static inline int get_log_level(void)
19 if (console_inited == 0)
20 return -1;
21 if (CONSOLE_LEVEL_CONST)
22 return get_console_loglevel();
24 return console_loglevel;
27 static inline void set_log_level(int new_level)
29 if (CONSOLE_LEVEL_CONST)
30 return;
32 console_loglevel = new_level;
35 static void init_log_level(void)
37 int debug_level = get_console_loglevel();
39 if (CONSOLE_LEVEL_CONST)
40 return;
42 get_option(&debug_level, "debug_level");
44 set_log_level(debug_level);
47 int console_log_level(int msg_level)
49 int log_level = get_log_level();
51 if (log_level < 0)
52 return CONSOLE_LOG_NONE;
54 if (msg_level <= log_level)
55 return CONSOLE_LOG_ALL;
57 if (CONFIG(CONSOLE_CBMEM) && (msg_level <= BIOS_DEBUG))
58 return CONSOLE_LOG_FAST;
60 return 0;
63 asmlinkage void console_init(void)
65 init_log_level();
67 if (CONFIG(DEBUG_CONSOLE_INIT))
68 console_inited = 1;
70 if (CONFIG(EARLY_PCI_BRIDGE) && (ENV_BOOTBLOCK || ENV_ROMSTAGE))
71 pci_early_bridge_init();
73 console_hw_init();
75 console_inited = 1;
77 printk(BIOS_NOTICE, "\n\ncoreboot-%s%s %s " ENV_STRING " starting (log level: %i)...\n",
78 coreboot_version, coreboot_extra_version, coreboot_build,
79 get_log_level());