Debian Codegraph @

src/console/init.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <commonlib/helpers.h>
4 #include <console/cbmem_console.h>
5 #include <console/console.h>
6 #include <console/uart.h>
7 #include <console/streams.h>
8 #include <device/pci.h>
9 #include <option.h>
10 #include <version.h>
11
12 #define FIRST_CONSOLE (ENV_BOOTBLOCK || (CONFIG(NO_BOOTBLOCK_CONSOLE) && ENV_SEPARATE_ROMSTAGE))
13
14 static int console_inited;
15 static int console_loglevel;
16
17 int get_log_level(void)
18 {
19 if (console_inited == 0)
20 return -1;
21
22 return console_loglevel;
23 }
24
25 static void init_log_level(void)
26 {
27 console_loglevel = get_console_loglevel();
28
29 if (!FIRST_CONSOLE)
30 console_loglevel = get_uint_option("debug_level", console_loglevel);
31 }
32
33 int console_log_level(int msg_level)
34 {
35 int log_level = get_log_level();
36
37 if (log_level < 0)
38 return CONSOLE_LOG_NONE;
39
40 if (msg_level <= log_level)
41 return CONSOLE_LOG_ALL;
42
43 if (CONFIG(CONSOLE_CBMEM) && (msg_level <= BIOS_DEBUG))
44 return CONSOLE_LOG_FAST;
45
46 return 0;
47 }
48
49 void console_init(void)
50 {
51 init_log_level();
52
53 if (CONFIG(DEBUG_CONSOLE_INIT))
54 console_inited = 1;
55
56 if (CONFIG(EARLY_PCI_BRIDGE) && (ENV_BOOTBLOCK || ENV_SEPARATE_ROMSTAGE))
57 pci_early_bridge_init();
58
59 console_hw_init();
60
61 console_inited = 1;
62
63 if (ENV_BOOTBLOCK && CONFIG(CONSOLE_CBMEM_PRINT_PRE_BOOTBLOCK_CONTENTS))
64 cbmem_dump_console();
65
66 printk(BIOS_NOTICE, "\n\ncoreboot-%s%s %s " ENV_ARCH " " ENV_STRING " starting (log level: %i)...\n",
67 coreboot_version, coreboot_extra_version, coreboot_build, get_log_level());
68 }