blob: fa706d00c687fb26d10d480ede7c4863fa951c6e [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.
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000014 */
15
Kyösti Mälkkif9cdb482014-11-18 13:21:50 +020016#include <build.h>
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030017#include <console/streams.h>
18#include <console/early_print.h>
Aaron Durbindc9f5cd2015-09-08 13:34:43 -050019#include <commonlib/loglevel.h>
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000020
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030021/* Include the sources. */
Kyösti Mälkkiafa7b132014-02-13 17:16:22 +020022#if CONFIG_CONSOLE_SERIAL && CONFIG_DRIVERS_UART_8250IO
Kyösti Mälkki3ee16682014-02-17 19:37:52 +020023#include "drivers/uart/util.c"
Kyösti Mälkkibea6bf02014-01-30 15:45:16 +020024#include "drivers/uart/uart8250io.c"
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000025#endif
26#if CONFIG_CONSOLE_NE2K
Kyösti Mälkki207379d2014-01-31 07:38:21 +020027#include "drivers/net/ne2k.c"
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000028#endif
29
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030030void console_hw_init(void)
31{
32#if CONFIG_CONSOLE_SERIAL
Kyösti Mälkki70342a72014-03-14 22:28:29 +020033 uart_init(CONFIG_UART_FOR_CONSOLE);
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030034#endif
35#if CONFIG_CONSOLE_NE2K
36 ne2k_init(CONFIG_CONSOLE_NE2K_IO_PORT);
37#endif
38}
39
40void console_tx_byte(unsigned char byte)
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000041{
Kyösti Mälkkiafa7b132014-02-13 17:16:22 +020042#if CONFIG_CONSOLE_SERIAL
Kyösti Mälkki70342a72014-03-14 22:28:29 +020043 uart_tx_byte(CONFIG_UART_FOR_CONSOLE, byte);
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000044#endif
45#if CONFIG_CONSOLE_NE2K
46 ne2k_append_data_byte(byte, CONFIG_CONSOLE_NE2K_IO_PORT);
47#endif
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000048}
49
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030050void console_tx_flush(void)
Kyösti Mälkkidbc7bd92014-01-28 11:34:38 +020051{
52#if CONFIG_CONSOLE_SERIAL
Kyösti Mälkki70342a72014-03-14 22:28:29 +020053 uart_tx_flush(CONFIG_UART_FOR_CONSOLE);
Kyösti Mälkkidbc7bd92014-01-28 11:34:38 +020054#endif
55#if CONFIG_CONSOLE_NE2K
56 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
57#endif
58}
59
Kyösti Mälkkiefb0b512014-04-13 17:57:34 +030060#include <console/early_print.c>
Stefan Reinauerbbd2f212011-04-20 21:11:22 +000061#include <console/post.c>
62#include <console/die.c>
Kyösti Mälkkif9cdb482014-11-18 13:21:50 +020063
64void console_init(void)
65{
66 static const char console_test[] =
67 "\n\ncoreboot-"
68 COREBOOT_VERSION
69 COREBOOT_EXTRA_VERSION
70 " "
71 COREBOOT_BUILD
Stefan Reinauer73307e02015-03-04 01:11:18 +010072 " romstage starting...\n";
Kyösti Mälkkif9cdb482014-11-18 13:21:50 +020073
74 console_hw_init();
75
76 print_info(console_test);
77}
Stefan Reinauerd6865222015-01-05 13:12:38 -080078
79void die(const char *msg)
80{
81 print_emerg(msg);
82 halt();
83}