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