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>
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)
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
)
32 console_loglevel
= new_level
;
35 static void init_log_level(void)
37 int debug_level
= get_console_loglevel();
39 if (CONSOLE_LEVEL_CONST
)
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();
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
;
63 asmlinkage
void console_init(void)
67 if (CONFIG(DEBUG_CONSOLE_INIT
))
70 if (CONFIG(EARLY_PCI_BRIDGE
) && (ENV_BOOTBLOCK
|| ENV_ROMSTAGE
))
71 pci_early_bridge_init();
77 printk(BIOS_NOTICE
, "\n\ncoreboot-%s%s %s " ENV_STRING
" starting (log level: %i)...\n",
78 coreboot_version
, coreboot_extra_version
, coreboot_build
,