Stefan Reinauer | bbd2f21 | 2011-04-20 21:11:22 +0000 | [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 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 |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 17 | * Foundation, Inc. |
Stefan Reinauer | bbd2f21 | 2011-04-20 21:11:22 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
Kyösti Mälkki | f9cdb48 | 2014-11-18 13:21:50 +0200 | [diff] [blame] | 20 | #include <build.h> |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 21 | #include <console/streams.h> |
| 22 | #include <console/early_print.h> |
Aaron Durbin | dc9f5cd | 2015-09-08 13:34:43 -0500 | [diff] [blame^] | 23 | #include <commonlib/loglevel.h> |
Stefan Reinauer | bbd2f21 | 2011-04-20 21:11:22 +0000 | [diff] [blame] | 24 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 25 | /* Include the sources. */ |
Kyösti Mälkki | afa7b13 | 2014-02-13 17:16:22 +0200 | [diff] [blame] | 26 | #if CONFIG_CONSOLE_SERIAL && CONFIG_DRIVERS_UART_8250IO |
Kyösti Mälkki | 3ee1668 | 2014-02-17 19:37:52 +0200 | [diff] [blame] | 27 | #include "drivers/uart/util.c" |
Kyösti Mälkki | bea6bf0 | 2014-01-30 15:45:16 +0200 | [diff] [blame] | 28 | #include "drivers/uart/uart8250io.c" |
Stefan Reinauer | bbd2f21 | 2011-04-20 21:11:22 +0000 | [diff] [blame] | 29 | #endif |
| 30 | #if CONFIG_CONSOLE_NE2K |
Kyösti Mälkki | 207379d | 2014-01-31 07:38:21 +0200 | [diff] [blame] | 31 | #include "drivers/net/ne2k.c" |
Stefan Reinauer | bbd2f21 | 2011-04-20 21:11:22 +0000 | [diff] [blame] | 32 | #endif |
| 33 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 34 | void console_hw_init(void) |
| 35 | { |
| 36 | #if CONFIG_CONSOLE_SERIAL |
Kyösti Mälkki | 70342a7 | 2014-03-14 22:28:29 +0200 | [diff] [blame] | 37 | uart_init(CONFIG_UART_FOR_CONSOLE); |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 38 | #endif |
| 39 | #if CONFIG_CONSOLE_NE2K |
| 40 | ne2k_init(CONFIG_CONSOLE_NE2K_IO_PORT); |
| 41 | #endif |
| 42 | } |
| 43 | |
| 44 | void console_tx_byte(unsigned char byte) |
Stefan Reinauer | bbd2f21 | 2011-04-20 21:11:22 +0000 | [diff] [blame] | 45 | { |
Kyösti Mälkki | afa7b13 | 2014-02-13 17:16:22 +0200 | [diff] [blame] | 46 | #if CONFIG_CONSOLE_SERIAL |
Kyösti Mälkki | 70342a7 | 2014-03-14 22:28:29 +0200 | [diff] [blame] | 47 | uart_tx_byte(CONFIG_UART_FOR_CONSOLE, byte); |
Stefan Reinauer | bbd2f21 | 2011-04-20 21:11:22 +0000 | [diff] [blame] | 48 | #endif |
| 49 | #if CONFIG_CONSOLE_NE2K |
| 50 | ne2k_append_data_byte(byte, CONFIG_CONSOLE_NE2K_IO_PORT); |
| 51 | #endif |
Stefan Reinauer | bbd2f21 | 2011-04-20 21:11:22 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 54 | void console_tx_flush(void) |
Kyösti Mälkki | dbc7bd9 | 2014-01-28 11:34:38 +0200 | [diff] [blame] | 55 | { |
| 56 | #if CONFIG_CONSOLE_SERIAL |
Kyösti Mälkki | 70342a7 | 2014-03-14 22:28:29 +0200 | [diff] [blame] | 57 | uart_tx_flush(CONFIG_UART_FOR_CONSOLE); |
Kyösti Mälkki | dbc7bd9 | 2014-01-28 11:34:38 +0200 | [diff] [blame] | 58 | #endif |
| 59 | #if CONFIG_CONSOLE_NE2K |
| 60 | ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT); |
| 61 | #endif |
| 62 | } |
| 63 | |
Kyösti Mälkki | efb0b51 | 2014-04-13 17:57:34 +0300 | [diff] [blame] | 64 | #include <console/early_print.c> |
Stefan Reinauer | bbd2f21 | 2011-04-20 21:11:22 +0000 | [diff] [blame] | 65 | #include <console/post.c> |
| 66 | #include <console/die.c> |
Kyösti Mälkki | f9cdb48 | 2014-11-18 13:21:50 +0200 | [diff] [blame] | 67 | |
| 68 | void console_init(void) |
| 69 | { |
| 70 | static const char console_test[] = |
| 71 | "\n\ncoreboot-" |
| 72 | COREBOOT_VERSION |
| 73 | COREBOOT_EXTRA_VERSION |
| 74 | " " |
| 75 | COREBOOT_BUILD |
Stefan Reinauer | 73307e0 | 2015-03-04 01:11:18 +0100 | [diff] [blame] | 76 | " romstage starting...\n"; |
Kyösti Mälkki | f9cdb48 | 2014-11-18 13:21:50 +0200 | [diff] [blame] | 77 | |
| 78 | console_hw_init(); |
| 79 | |
| 80 | print_info(console_test); |
| 81 | } |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 82 | |
| 83 | void die(const char *msg) |
| 84 | { |
| 85 | print_emerg(msg); |
| 86 | halt(); |
| 87 | } |