blob: 98a9d430b334eaf6693861068cc9687183e32527 [file] [log] [blame]
Kyösti Mälkki21333f92014-02-14 10:04:31 +02001/*
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010018 * Foundation, Inc.
Kyösti Mälkki21333f92014-02-14 10:04:31 +020019 */
20
Kyösti Mälkki21333f92014-02-14 10:04:31 +020021#include <console/console.h>
22#include <console/uart.h>
Kyösti Mälkki40760722014-02-27 19:30:18 +020023#include <console/streams.h>
Kyösti Mälkkif9cdb482014-11-18 13:21:50 +020024#include <device/pci.h>
Kyösti Mälkki21333f92014-02-14 10:04:31 +020025#include <option.h>
Aaron Durbinaab13262015-05-13 13:32:11 -050026#include <rules.h>
Kyösti Mälkkic36af7b2014-11-18 12:41:16 +020027#include <version.h>
Kyösti Mälkki21333f92014-02-14 10:04:31 +020028
Kyösti Mälkki56ae1392014-02-28 14:37:27 +020029/* While in romstage, console loglevel is built-time constant. */
30static ROMSTAGE_CONST int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
31
32int console_log_level(int msg_level)
33{
34 return (console_loglevel >= msg_level);
35}
Kyösti Mälkkib2d25962014-01-27 15:09:13 +020036
Kyösti Mälkki21333f92014-02-14 10:04:31 +020037void console_init(void)
38{
39#if !defined(__PRE_RAM__)
Varad Gautam06ef0462015-03-11 09:54:41 +053040 console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
41 get_option(&console_loglevel, "debug_level");
Kyösti Mälkki21333f92014-02-14 10:04:31 +020042#endif
43
Kyösti Mälkki40760722014-02-27 19:30:18 +020044#if CONFIG_EARLY_PCI_BRIDGE && !defined(__SMM__)
Kyösti Mälkki21333f92014-02-14 10:04:31 +020045 pci_early_bridge_init();
46#endif
47
48 console_hw_init();
49
Stefan Reinauer73307e02015-03-04 01:11:18 +010050 printk(BIOS_INFO, "\n\ncoreboot-%s%s %s %s starting...\n",
51 coreboot_version, coreboot_extra_version, coreboot_build,
Aaron Durbinaab13262015-05-13 13:32:11 -050052#if ENV_BOOTBLOCK
Stefan Reinauer73307e02015-03-04 01:11:18 +010053 "bootblock"
Aaron Durbinaab13262015-05-13 13:32:11 -050054#elif ENV_ROMSTAGE
Stefan Reinauer73307e02015-03-04 01:11:18 +010055 "romstage"
Aaron Durbinaab13262015-05-13 13:32:11 -050056#elif ENV_RAMSTAGE
Stefan Reinauer73307e02015-03-04 01:11:18 +010057 "ramstage"
Aaron Durbinaab13262015-05-13 13:32:11 -050058#elif ENV_VERSTAGE
59 "verstage"
60#elif ENV_SECMON
61 "secmon"
62#else
63 "UNKNOWN"
Kyösti Mälkki21333f92014-02-14 10:04:31 +020064#endif
Stefan Reinauer73307e02015-03-04 01:11:18 +010065 );
Kyösti Mälkki21333f92014-02-14 10:04:31 +020066}