blob: a6424ddeee5878d8e088e10fe6c926640f016a2b [file] [log] [blame]
Stefan Reinauerbbd2f212011-04-20 21:11:22 +00001/*
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 modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
Kyösti Mälkkif9cdb482014-11-18 13:21:50 +020020#include <build.h>
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030021#include <console/streams.h>
22#include <console/early_print.h>
Stefan Reinauerd6865222015-01-05 13:12:38 -080023#include <console/loglevel.h>
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000024
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030025/* Include the sources. */
Kyösti Mälkkiafa7b132014-02-13 17:16:22 +020026#if CONFIG_CONSOLE_SERIAL && CONFIG_DRIVERS_UART_8250IO
Kyösti Mälkki3ee16682014-02-17 19:37:52 +020027#include "drivers/uart/util.c"
Kyösti Mälkkibea6bf02014-01-30 15:45:16 +020028#include "drivers/uart/uart8250io.c"
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000029#endif
30#if CONFIG_CONSOLE_NE2K
Kyösti Mälkki207379d2014-01-31 07:38:21 +020031#include "drivers/net/ne2k.c"
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000032#endif
33
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030034void console_hw_init(void)
35{
36#if CONFIG_CONSOLE_SERIAL
Kyösti Mälkki70342a72014-03-14 22:28:29 +020037 uart_init(CONFIG_UART_FOR_CONSOLE);
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030038#endif
39#if CONFIG_CONSOLE_NE2K
40 ne2k_init(CONFIG_CONSOLE_NE2K_IO_PORT);
41#endif
42}
43
44void console_tx_byte(unsigned char byte)
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000045{
Kyösti Mälkkiafa7b132014-02-13 17:16:22 +020046#if CONFIG_CONSOLE_SERIAL
Kyösti Mälkki70342a72014-03-14 22:28:29 +020047 uart_tx_byte(CONFIG_UART_FOR_CONSOLE, byte);
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000048#endif
49#if CONFIG_CONSOLE_NE2K
50 ne2k_append_data_byte(byte, CONFIG_CONSOLE_NE2K_IO_PORT);
51#endif
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000052}
53
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030054void console_tx_flush(void)
Kyösti Mälkkidbc7bd92014-01-28 11:34:38 +020055{
56#if CONFIG_CONSOLE_SERIAL
Kyösti Mälkki70342a72014-03-14 22:28:29 +020057 uart_tx_flush(CONFIG_UART_FOR_CONSOLE);
Kyösti Mälkkidbc7bd92014-01-28 11:34:38 +020058#endif
59#if CONFIG_CONSOLE_NE2K
60 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
61#endif
62}
63
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030064#include <console/early_print.c>
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000065#include <console/post.c>
66#include <console/die.c>
Kyösti Mälkkif9cdb482014-11-18 13:21:50 +020067
68void console_init(void)
69{
70 static const char console_test[] =
71 "\n\ncoreboot-"
72 COREBOOT_VERSION
73 COREBOOT_EXTRA_VERSION
74 " "
75 COREBOOT_BUILD
76 " starting...\n";
77
78 console_hw_init();
79
80 print_info(console_test);
81}
Stefan Reinauerd6865222015-01-05 13:12:38 -080082
83void die(const char *msg)
84{
85 print_emerg(msg);
86 halt();
87}