blob: 2013bb7685fea3a1a94754849fe17ced3ff268f5 [file] [log] [blame]
arch import user (historical)6ca76362005-07-06 17:17:25 +00001/*
Stefan Reinauer52fc6b12009-10-24 13:06:04 +00002 * This file is part of the coreboot project.
Stefan Reinauer14e22772010-04-27 06:56:47 +00003 *
Stefan Reinauer52fc6b12009-10-24 13:06:04 +00004 * 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)6ca76362005-07-06 17:17:25 +00008 *
Stefan Reinauer52fc6b12009-10-24 13:06:04 +00009 * 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)6ca76362005-07-06 17:17:25 +000013 *
Stefan Reinauer52fc6b12009-10-24 13:06:04 +000014 * 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)6ca76362005-07-06 17:17:25 +000018 */
Stefan Reinauer52fc6b12009-10-24 13:06:04 +000019
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000020#include <console/console.h>
Stefan Reinauer52fc6b12009-10-24 13:06:04 +000021#include <console/vtxprintf.h>
Stefan Reinauer4885daa2011-04-26 23:47:04 +000022#if CONFIG_CONSOLE_SERIAL8250 || CONFIG_CONSOLE_SERIAL8250MEM
Stefan Reinauer52fc6b12009-10-24 13:06:04 +000023#include <uart8250.h>
Stefan Reinauer16ce01b2011-01-28 08:05:54 +000024#endif
25#if CONFIG_USBDEBUG
26#include <usbdebug.h>
27#endif
Rudolf Marek4aa93cc2010-07-16 20:02:09 +000028#if CONFIG_CONSOLE_NE2K
29#include <console/ne2k.h>
30#endif
Vladimir Serbinenko45988da2013-03-30 02:02:13 +010031#if CONFIG_SPKMODEM
32#include <console/spkmodem.h>
33#endif
34
Rudolf Marek4aa93cc2010-07-16 20:02:09 +000035
Vadim Bendebury48a4a7f2012-06-07 18:47:13 -070036void console_tx_byte(unsigned char byte)
arch import user (historical)6ca76362005-07-06 17:17:25 +000037{
Stefan Reinauer16ce01b2011-01-28 08:05:54 +000038 if (byte == '\n')
39 console_tx_byte('\r');
40
Stefan Reinauer4885daa2011-04-26 23:47:04 +000041#if CONFIG_CONSOLE_SERIAL8250MEM
Gabe Black4d04a712011-10-05 01:52:08 -070042 if (oxford_oxpcie_present) {
43 uart8250_mem_tx_byte(
44 CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x1000, byte);
45 }
Stefan Reinauer4885daa2011-04-26 23:47:04 +000046#endif
Stefan Reinauer16ce01b2011-01-28 08:05:54 +000047#if CONFIG_CONSOLE_SERIAL8250
48 uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
49#endif
50#if CONFIG_USBDEBUG
Sven Schnelle82704c62012-07-26 14:31:40 +020051 usbdebug_tx_byte(0, byte);
Stefan Reinauer16ce01b2011-01-28 08:05:54 +000052#endif
Rudolf Marek4aa93cc2010-07-16 20:02:09 +000053#if CONFIG_CONSOLE_NE2K
Rudolf Marek4aa93cc2010-07-16 20:02:09 +000054 ne2k_append_data(&byte, 1, CONFIG_CONSOLE_NE2K_IO_PORT);
55#endif
Vadim Bendebury1078c672011-09-30 11:16:49 -070056#if CONFIG_CONSOLE_CBMEM
57 cbmemc_tx_byte(byte);
58#endif
Vladimir Serbinenko45988da2013-03-30 02:02:13 +010059#if CONFIG_SPKMODEM
60 spkmodem_tx_byte(byte);
61#endif
arch import user (historical)6ca76362005-07-06 17:17:25 +000062}
63
Aaron Durbin1989b4b2013-03-22 19:52:42 -050064void console_tx_flush(void)
Kevin O'Connora68555f2011-07-09 20:22:21 -040065{
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 Schnelle82704c62012-07-26 14:31:40 +020075#if CONFIG_USBDEBUG
76 usbdebug_tx_flush(0);
77#endif
Kevin O'Connora68555f2011-07-09 20:22:21 -040078}
79
arch import user (historical)6ca76362005-07-06 17:17:25 +000080int do_printk(int msg_level, const char *fmt, ...)
81{
82 va_list args;
83 int i;
84
Myles Watson03646182009-10-16 19:29:45 +000085 if (msg_level > console_loglevel) {
arch import user (historical)6ca76362005-07-06 17:17:25 +000086 return 0;
87 }
88
89 va_start(args, fmt);
90 i = vtxprintf(console_tx_byte, fmt, args);
91 va_end(args);
Kevin O'Connora68555f2011-07-09 20:22:21 -040092
93 console_tx_flush();
94
arch import user (historical)6ca76362005-07-06 17:17:25 +000095 return i;
96}