blob: a36cb96ed1a3c7bd03494cb898b860a0e1774911 [file] [log] [blame]
Eric Biederman8ca8d762003-04-22 19:02:15 +00001/*
Stefan Reinauer2a8ad412010-09-27 18:49:46 +00002 * This file is part of the coreboot project.
3 *
Stefan Reinauer2a8ad412010-09-27 18:49:46 +00004 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
Eric Biederman8ca8d762003-04-22 19:02:15 +000012 */
13
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020014#include <console/cbmem_console.h>
Edward O'Callaghan0ddb8262014-06-17 18:37:08 +100015#include <console/ne2k.h>
16#include <console/qemu_debugcon.h>
17#include <console/spkmodem.h>
18#include <console/streams.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020019#include <console/uart.h>
20#include <console/usb.h>
Martin Roth3a543182015-09-28 15:27:24 -060021#include <console/spi.h>
Youness Alaouic4b4ff32017-05-11 10:36:29 -040022#include <console/flash.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020023
Kyösti Mälkki21333f92014-02-14 10:04:31 +020024void console_hw_init(void)
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000025{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020026 __cbmemc_init();
27 __spkmodem_init();
28 __qemu_debugcon_init();
29
30 __uart_init();
31 __ne2k_init();
32 __usbdebug_init();
Martin Roth3a543182015-09-28 15:27:24 -060033 __spiconsole_init();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040034 __flashconsole_init();
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000035}
Kyösti Mälkkifd956242014-02-03 17:04:22 +020036
Kyösti Mälkkifd956242014-02-03 17:04:22 +020037void console_tx_byte(unsigned char byte)
38{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020039 __cbmemc_tx_byte(byte);
40 __spkmodem_tx_byte(byte);
41 __qemu_debugcon_tx_byte(byte);
42
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030043 /* Some consoles want newline conversion
44 * to keep terminals happy.
45 */
46 if (byte == '\n') {
47 __uart_tx_byte('\r');
48 __usb_tx_byte('\r');
49 }
50
Kyösti Mälkkif3390862014-02-26 15:19:04 +020051 __uart_tx_byte(byte);
52 __ne2k_tx_byte(byte);
53 __usb_tx_byte(byte);
Martin Roth3a543182015-09-28 15:27:24 -060054 __spiconsole_tx_byte(byte);
Youness Alaouic4b4ff32017-05-11 10:36:29 -040055 __flashconsole_tx_byte(byte);
Kyösti Mälkkifd956242014-02-03 17:04:22 +020056}
57
58void console_tx_flush(void)
59{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020060 __uart_tx_flush();
61 __ne2k_tx_flush();
62 __usb_tx_flush();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040063 __flashconsole_tx_flush();
Kyösti Mälkki40760722014-02-27 19:30:18 +020064}
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030065
Lee Leahy219c3322016-08-09 08:59:30 -070066void console_write_line(uint8_t *buffer, size_t number_of_bytes)
67{
68 /* Finish displaying all of the console data if requested */
69 if (number_of_bytes == 0) {
70 console_tx_flush();
71 return;
72 }
73
74 /* Output the console data */
75 while (number_of_bytes--)
76 console_tx_byte(*buffer++);
77}
78
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030079
Julius Wernercd49cce2019-03-05 16:53:33 -080080#if CONFIG(GDB_STUB) && (ENV_ROMSTAGE || ENV_RAMSTAGE)
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030081void gdb_hw_init(void)
82{
83 __gdb_hw_init();
84}
85
86void gdb_tx_byte(unsigned char byte)
87{
88 __gdb_tx_byte(byte);
89}
90
91void gdb_tx_flush(void)
92{
93 __gdb_tx_flush();
94}
95
96unsigned char gdb_rx_byte(void)
97{
98 return __gdb_rx_byte();
99}
100#endif