2014-02-14 09:04:31 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Eric Biederman
|
|
|
|
*
|
|
|
|
* 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>
|
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>
|
2015-05-13 20:32:11 +02:00
|
|
|
#include <rules.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. */
|
|
|
|
#if defined(__PRE_RAM__)
|
|
|
|
#define CONSOLE_LEVEL_CONST 1
|
|
|
|
#else
|
|
|
|
#define CONSOLE_LEVEL_CONST 0
|
|
|
|
#endif
|
|
|
|
|
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-05-31 06:03:29 +02:00
|
|
|
if (!IS_ENABLED(CONFIG_LATE_CBMEM_INIT) &&
|
|
|
|
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)
|
|
|
|
{
|
2017-04-24 23:03:57 +02:00
|
|
|
return (get_log_level() >= msg_level);
|
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
|
|
|
|
2017-06-09 17:27:08 +02:00
|
|
|
#if IS_ENABLED(CONFIG_EARLY_PCI_BRIDGE) && !defined(__SMM__)
|
2014-02-14 09:04:31 +01:00
|
|
|
pci_early_bridge_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
console_hw_init();
|
|
|
|
|
2018-05-31 06:03:29 +02:00
|
|
|
if (!IS_ENABLED(CONFIG_LATE_CBMEM_INIT))
|
|
|
|
car_set_var(console_inited, 1);
|
2018-02-28 20:38:05 +01:00
|
|
|
|
2017-05-16 22:54:18 +02:00
|
|
|
printk(BIOS_NOTICE, "\n\ncoreboot-%s%s %s " ENV_STRING " starting...\n",
|
2015-11-19 17:48:47 +01:00
|
|
|
coreboot_version, coreboot_extra_version, coreboot_build);
|
2014-02-14 09:04:31 +01:00
|
|
|
}
|