2014-02-14 09:04:31 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; version 2 of
|
|
|
|
* the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2018-02-28 20:38:05 +01:00
|
|
|
#include <arch/early_variables.h>
|
2019-02-12 13:16:21 +01:00
|
|
|
#include <commonlib/helpers.h>
|
2014-02-14 09:04:31 +01:00
|
|
|
#include <console/console.h>
|
|
|
|
#include <console/uart.h>
|
2014-02-27 18:30:18 +01:00
|
|
|
#include <console/streams.h>
|
2014-02-14 09:04:31 +01:00
|
|
|
#include <device/pci.h>
|
2014-11-18 12:21:50 +01:00
|
|
|
#include <option.h>
|
2014-11-18 11:41:16 +01:00
|
|
|
#include <version.h>
|
2014-02-14 09:04:31 +01:00
|
|
|
|
2017-04-24 23:03:57 +02:00
|
|
|
/* Mutable console log level only allowed when RAM comes online. */
|
2019-09-13 09:49:20 +02:00
|
|
|
#define CONSOLE_LEVEL_CONST !ENV_STAGE_HAS_DATA_SECTION
|
2017-04-24 23:03:57 +02:00
|
|
|
|
2018-02-28 20:38:05 +01:00
|
|
|
static int console_inited CAR_GLOBAL;
|
2017-04-24 23:03:57 +02:00
|
|
|
static int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
|
|
|
|
|
|
|
|
static inline int get_log_level(void)
|
|
|
|
{
|
2018-06-03 11:29:50 +02:00
|
|
|
if (car_get_var(console_inited) == 0)
|
2018-02-28 20:38:05 +01:00
|
|
|
return -1;
|
2017-09-24 11:32:24 +02:00
|
|
|
if (CONSOLE_LEVEL_CONST)
|
2018-02-20 15:01:27 +01:00
|
|
|
return get_console_loglevel();
|
2017-04-24 23:03:57 +02:00
|
|
|
|
|
|
|
return console_loglevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_log_level(int new_level)
|
|
|
|
{
|
|
|
|
if (CONSOLE_LEVEL_CONST)
|
|
|
|
return;
|
|
|
|
|
|
|
|
console_loglevel = new_level;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init_log_level(void)
|
|
|
|
{
|
2018-02-20 15:01:27 +01:00
|
|
|
int debug_level = get_console_loglevel();
|
2017-04-24 23:03:57 +02:00
|
|
|
|
2017-09-24 11:32:24 +02:00
|
|
|
if (CONSOLE_LEVEL_CONST)
|
|
|
|
return;
|
|
|
|
|
2017-04-24 23:03:57 +02:00
|
|
|
get_option(&debug_level, "debug_level");
|
|
|
|
|
|
|
|
set_log_level(debug_level);
|
|
|
|
}
|
2014-02-28 13:37:27 +01:00
|
|
|
|
|
|
|
int console_log_level(int msg_level)
|
|
|
|
{
|
2019-02-12 13:16:21 +01:00
|
|
|
int log_level = get_log_level();
|
|
|
|
|
|
|
|
if (log_level < 0)
|
|
|
|
return CONSOLE_LOG_NONE;
|
|
|
|
|
|
|
|
if (msg_level <= log_level)
|
|
|
|
return CONSOLE_LOG_ALL;
|
|
|
|
|
2019-03-06 01:53:33 +01:00
|
|
|
if (CONFIG(CONSOLE_CBMEM) && (msg_level <= BIOS_DEBUG))
|
2019-02-12 13:16:21 +01:00
|
|
|
return CONSOLE_LOG_FAST;
|
|
|
|
|
|
|
|
return 0;
|
2014-02-28 13:37:27 +01:00
|
|
|
}
|
2014-01-27 14:09:13 +01:00
|
|
|
|
2016-07-31 20:53:28 +02:00
|
|
|
asmlinkage void console_init(void)
|
2014-02-14 09:04:31 +01:00
|
|
|
{
|
2017-04-24 23:03:57 +02:00
|
|
|
init_log_level();
|
2014-02-14 09:04:31 +01:00
|
|
|
|
2019-03-06 01:53:33 +01:00
|
|
|
if (CONFIG(DEBUG_CONSOLE_INIT))
|
2018-12-31 14:22:34 +01:00
|
|
|
car_set_var(console_inited, 1);
|
|
|
|
|
2019-03-06 01:53:33 +01:00
|
|
|
if (CONFIG(EARLY_PCI_BRIDGE) && !ENV_SMM && !ENV_RAMSTAGE)
|
2018-12-26 18:33:28 +01:00
|
|
|
pci_early_bridge_init();
|
2014-02-14 09:04:31 +01:00
|
|
|
|
|
|
|
console_hw_init();
|
|
|
|
|
2018-06-03 11:29:50 +02:00
|
|
|
car_set_var(console_inited, 1);
|
2018-02-28 20:38:05 +01:00
|
|
|
|
2019-01-08 00:17:44 +01:00
|
|
|
printk(BIOS_NOTICE, "\n\ncoreboot-%s%s %s " ENV_STRING " starting (log level: %i)...\n",
|
|
|
|
coreboot_version, coreboot_extra_version, coreboot_build,
|
|
|
|
get_log_level());
|
2014-02-14 09:04:31 +01:00
|
|
|
}
|