1 /* SPDX-License-Identifier: GPL-2.0-only */
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>
12 #define FIRST_CONSOLE (ENV_BOOTBLOCK || (CONFIG(NO_BOOTBLOCK_CONSOLE) && ENV_SEPARATE_ROMSTAGE))
14 static int console_inited
;
15 static int console_loglevel
;
17 int get_log_level(void)
19 if (console_inited
== 0)
22 return console_loglevel
;
25 static void init_log_level(void)
27 console_loglevel
= get_console_loglevel();
30 console_loglevel
= get_uint_option("debug_level", console_loglevel
);
33 int console_log_level(int msg_level
)
35 int log_level
= get_log_level();
38 return CONSOLE_LOG_NONE
;
40 if (msg_level
<= log_level
)
41 return CONSOLE_LOG_ALL
;
43 if (CONFIG(CONSOLE_CBMEM
) && (msg_level
<= BIOS_DEBUG
))
44 return CONSOLE_LOG_FAST
;
49 void console_init(void)
53 if (CONFIG(DEBUG_CONSOLE_INIT
))
56 if (CONFIG(EARLY_PCI_BRIDGE
) && (ENV_BOOTBLOCK
|| ENV_SEPARATE_ROMSTAGE
))
57 pci_early_bridge_init();
63 if (ENV_BOOTBLOCK
&& CONFIG(CONSOLE_CBMEM_PRINT_PRE_BOOTBLOCK_CONTENTS
))
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());