arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 3 | * |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation; version 2 of |
| 7 | * the License. |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 8 | * |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 13 | * |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 17 | * MA 02110-1301 USA |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 18 | */ |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 19 | |
Stefan Reinauer | 9fe4d79 | 2010-01-16 17:53:38 +0000 | [diff] [blame] | 20 | #include <console/console.h> |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 21 | #include <console/vtxprintf.h> |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 22 | #if CONFIG_CONSOLE_SERIAL8250 || CONFIG_CONSOLE_SERIAL8250MEM |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 23 | #include <uart8250.h> |
Stefan Reinauer | 16ce01b | 2011-01-28 08:05:54 +0000 | [diff] [blame] | 24 | #endif |
| 25 | #if CONFIG_USBDEBUG |
| 26 | #include <usbdebug.h> |
| 27 | #endif |
Rudolf Marek | 4aa93cc | 2010-07-16 20:02:09 +0000 | [diff] [blame] | 28 | #if CONFIG_CONSOLE_NE2K |
| 29 | #include <console/ne2k.h> |
| 30 | #endif |
Vladimir Serbinenko | 45988da | 2013-03-30 02:02:13 +0100 | [diff] [blame] | 31 | #if CONFIG_SPKMODEM |
| 32 | #include <console/spkmodem.h> |
| 33 | #endif |
| 34 | |
Rudolf Marek | 4aa93cc | 2010-07-16 20:02:09 +0000 | [diff] [blame] | 35 | |
Vadim Bendebury | 48a4a7f | 2012-06-07 18:47:13 -0700 | [diff] [blame] | 36 | void console_tx_byte(unsigned char byte) |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 37 | { |
Stefan Reinauer | 16ce01b | 2011-01-28 08:05:54 +0000 | [diff] [blame] | 38 | if (byte == '\n') |
| 39 | console_tx_byte('\r'); |
| 40 | |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 41 | #if CONFIG_CONSOLE_SERIAL8250MEM |
Gabe Black | 4d04a71 | 2011-10-05 01:52:08 -0700 | [diff] [blame] | 42 | if (oxford_oxpcie_present) { |
| 43 | uart8250_mem_tx_byte( |
| 44 | CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x1000, byte); |
| 45 | } |
Stefan Reinauer | 4885daa | 2011-04-26 23:47:04 +0000 | [diff] [blame] | 46 | #endif |
Stefan Reinauer | 16ce01b | 2011-01-28 08:05:54 +0000 | [diff] [blame] | 47 | #if CONFIG_CONSOLE_SERIAL8250 |
| 48 | uart8250_tx_byte(CONFIG_TTYS0_BASE, byte); |
| 49 | #endif |
| 50 | #if CONFIG_USBDEBUG |
Sven Schnelle | 82704c6 | 2012-07-26 14:31:40 +0200 | [diff] [blame] | 51 | usbdebug_tx_byte(0, byte); |
Stefan Reinauer | 16ce01b | 2011-01-28 08:05:54 +0000 | [diff] [blame] | 52 | #endif |
Rudolf Marek | 4aa93cc | 2010-07-16 20:02:09 +0000 | [diff] [blame] | 53 | #if CONFIG_CONSOLE_NE2K |
Rudolf Marek | 4aa93cc | 2010-07-16 20:02:09 +0000 | [diff] [blame] | 54 | ne2k_append_data(&byte, 1, CONFIG_CONSOLE_NE2K_IO_PORT); |
| 55 | #endif |
Vadim Bendebury | 1078c67 | 2011-09-30 11:16:49 -0700 | [diff] [blame] | 56 | #if CONFIG_CONSOLE_CBMEM |
| 57 | cbmemc_tx_byte(byte); |
| 58 | #endif |
Vladimir Serbinenko | 45988da | 2013-03-30 02:02:13 +0100 | [diff] [blame] | 59 | #if CONFIG_SPKMODEM |
| 60 | spkmodem_tx_byte(byte); |
| 61 | #endif |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Aaron Durbin | 1989b4b | 2013-03-22 19:52:42 -0500 | [diff] [blame] | 64 | void console_tx_flush(void) |
Kevin O'Connor | a68555f | 2011-07-09 20:22:21 -0400 | [diff] [blame] | 65 | { |
| 66 | #if CONFIG_CONSOLE_SERIAL8250MEM |
| 67 | uart8250_mem_tx_flush(CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x1000); |
| 68 | #endif |
| 69 | #if CONFIG_CONSOLE_SERIAL8250 |
| 70 | uart8250_tx_flush(CONFIG_TTYS0_BASE); |
| 71 | #endif |
| 72 | #if CONFIG_CONSOLE_NE2K |
| 73 | ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT); |
| 74 | #endif |
Sven Schnelle | 82704c6 | 2012-07-26 14:31:40 +0200 | [diff] [blame] | 75 | #if CONFIG_USBDEBUG |
| 76 | usbdebug_tx_flush(0); |
| 77 | #endif |
Kevin O'Connor | a68555f | 2011-07-09 20:22:21 -0400 | [diff] [blame] | 78 | } |
| 79 | |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 80 | int do_printk(int msg_level, const char *fmt, ...) |
| 81 | { |
| 82 | va_list args; |
| 83 | int i; |
| 84 | |
Myles Watson | 0364618 | 2009-10-16 19:29:45 +0000 | [diff] [blame] | 85 | if (msg_level > console_loglevel) { |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | va_start(args, fmt); |
| 90 | i = vtxprintf(console_tx_byte, fmt, args); |
| 91 | va_end(args); |
Kevin O'Connor | a68555f | 2011-07-09 20:22:21 -0400 | [diff] [blame] | 92 | |
| 93 | console_tx_flush(); |
| 94 | |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 95 | return i; |
| 96 | } |