Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2003 Eric Biederman |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 17 | #include <console/console.h> |
| 18 | #include <console/uart.h> |
Kyösti Mälkki | 4076072 | 2014-02-27 19:30:18 +0200 | [diff] [blame] | 19 | #include <console/streams.h> |
Kyösti Mälkki | f9cdb48 | 2014-11-18 13:21:50 +0200 | [diff] [blame] | 20 | #include <device/pci.h> |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 21 | #include <option.h> |
Aaron Durbin | aab1326 | 2015-05-13 13:32:11 -0500 | [diff] [blame] | 22 | #include <rules.h> |
Kyösti Mälkki | c36af7b | 2014-11-18 12:41:16 +0200 | [diff] [blame] | 23 | #include <version.h> |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 24 | |
Aaron Durbin | 4003950 | 2017-04-24 16:03:57 -0500 | [diff] [blame] | 25 | /* Mutable console log level only allowed when RAM comes online. */ |
| 26 | #if defined(__PRE_RAM__) |
| 27 | #define CONSOLE_LEVEL_CONST 1 |
| 28 | #else |
| 29 | #define CONSOLE_LEVEL_CONST 0 |
| 30 | #endif |
| 31 | |
| 32 | static int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL; |
| 33 | |
| 34 | static inline int get_log_level(void) |
| 35 | { |
Martin Roth | 53de6cd | 2017-06-09 09:27:08 -0600 | [diff] [blame] | 36 | if (IS_ENABLED(CONSOLE_LEVEL_CONST)) |
Aaron Durbin | 4003950 | 2017-04-24 16:03:57 -0500 | [diff] [blame] | 37 | return CONFIG_DEFAULT_CONSOLE_LOGLEVEL; |
| 38 | |
| 39 | return console_loglevel; |
| 40 | } |
| 41 | |
| 42 | static inline void set_log_level(int new_level) |
| 43 | { |
| 44 | if (CONSOLE_LEVEL_CONST) |
| 45 | return; |
| 46 | |
| 47 | console_loglevel = new_level; |
| 48 | } |
| 49 | |
| 50 | static void init_log_level(void) |
| 51 | { |
| 52 | int debug_level = CONFIG_DEFAULT_CONSOLE_LOGLEVEL; |
| 53 | |
| 54 | get_option(&debug_level, "debug_level"); |
| 55 | |
| 56 | set_log_level(debug_level); |
| 57 | } |
Kyösti Mälkki | 56ae139 | 2014-02-28 14:37:27 +0200 | [diff] [blame] | 58 | |
| 59 | int console_log_level(int msg_level) |
| 60 | { |
Aaron Durbin | 4003950 | 2017-04-24 16:03:57 -0500 | [diff] [blame] | 61 | return (get_log_level() >= msg_level); |
Kyösti Mälkki | 56ae139 | 2014-02-28 14:37:27 +0200 | [diff] [blame] | 62 | } |
Kyösti Mälkki | b2d2596 | 2014-01-27 15:09:13 +0200 | [diff] [blame] | 63 | |
Lee Leahy | 049b462 | 2016-07-31 11:53:28 -0700 | [diff] [blame] | 64 | asmlinkage void console_init(void) |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 65 | { |
Aaron Durbin | 4003950 | 2017-04-24 16:03:57 -0500 | [diff] [blame] | 66 | init_log_level(); |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 67 | |
Martin Roth | 53de6cd | 2017-06-09 09:27:08 -0600 | [diff] [blame] | 68 | #if IS_ENABLED(CONFIG_EARLY_PCI_BRIDGE) && !defined(__SMM__) |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 69 | pci_early_bridge_init(); |
| 70 | #endif |
| 71 | |
| 72 | console_hw_init(); |
| 73 | |
Julius Werner | d906bb6 | 2017-05-16 13:54:18 -0700 | [diff] [blame] | 74 | printk(BIOS_NOTICE, "\n\ncoreboot-%s%s %s " ENV_STRING " starting...\n", |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 75 | coreboot_version, coreboot_extra_version, coreboot_build); |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 76 | } |