mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
UPSTREAM: console: rework log level to not be reliant on ROMSTAGE_CONST
The console log level variable doesn't really rely on ROMSTAGE_CONST
proper. Instead, the mutability of the variable is based on the current
implementation of ROMSTAGE_CONST (__PRE_RAM__). As such directly
use that logic for the code. In addition, refactor the code to let
the compiler and linker optimize out accesses instead of using
the pre-processor.
BUG=none
BRANCH=none
TEST=none
Change-Id: Ie38d062b92b9bcd7bf7faf88a9495c52c0d5488d
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 4003950881
Original-Change-Id: I44bcc409266ef52b9be29f75efde73a6707a53f4
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/19438
Original-Tested-by: build bot (Jenkins)
Original-Reviewed-by: Furquan Shaikh <furquan@google.com>
Original-Reviewed-by: Philippe Mathieu-Daud <philippe.mathieu.daude@gmail.com>
Original-Reviewed-by: Kysti Mlkki <kyosti.malkki@gmail.com>
Reviewed-on: https://chromium-review.googlesource.com/488046
This commit is contained in:
parent
5f4dc25899
commit
cf446f8a18
1 changed files with 35 additions and 7 deletions
|
@ -22,20 +22,48 @@
|
|||
#include <rules.h>
|
||||
#include <version.h>
|
||||
|
||||
/* While in romstage, console loglevel is built-time constant. */
|
||||
static ROMSTAGE_CONST int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
|
||||
/* 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
|
||||
|
||||
static int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
|
||||
|
||||
static inline int get_log_level(void)
|
||||
{
|
||||
if (CONSOLE_LEVEL_CONST)
|
||||
return CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
|
||||
|
||||
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)
|
||||
{
|
||||
int debug_level = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
|
||||
|
||||
get_option(&debug_level, "debug_level");
|
||||
|
||||
set_log_level(debug_level);
|
||||
}
|
||||
|
||||
int console_log_level(int msg_level)
|
||||
{
|
||||
return (console_loglevel >= msg_level);
|
||||
return (get_log_level() >= msg_level);
|
||||
}
|
||||
|
||||
asmlinkage void console_init(void)
|
||||
{
|
||||
#if !defined(__PRE_RAM__)
|
||||
console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
|
||||
get_option(&console_loglevel, "debug_level");
|
||||
#endif
|
||||
init_log_level();
|
||||
|
||||
#if CONFIG_EARLY_PCI_BRIDGE && !defined(__SMM__)
|
||||
pci_early_bridge_init();
|
||||
|
|
Loading…
Add table
Reference in a new issue