blob: bc9d9183a0edf8932516c1822bc796c1da994b2f [file] [log] [blame]
Angel Ponsb706ab32020-04-02 23:48:09 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Eric Biederman8ca8d762003-04-22 19:02:15 +00002
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +02003#include <console/cbmem_console.h>
Edward O'Callaghan0ddb8262014-06-17 18:37:08 +10004#include <console/ne2k.h>
5#include <console/qemu_debugcon.h>
6#include <console/spkmodem.h>
7#include <console/streams.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +02008#include <console/uart.h>
9#include <console/usb.h>
Martin Roth3a543182015-09-28 15:27:24 -060010#include <console/spi.h>
Youness Alaouic4b4ff32017-05-11 10:36:29 -040011#include <console/flash.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020012
Kyösti Mälkki21333f92014-02-14 10:04:31 +020013void console_hw_init(void)
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000014{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020015 __cbmemc_init();
16 __spkmodem_init();
17 __qemu_debugcon_init();
18
19 __uart_init();
20 __ne2k_init();
21 __usbdebug_init();
Martin Roth3a543182015-09-28 15:27:24 -060022 __spiconsole_init();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040023 __flashconsole_init();
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000024}
Kyösti Mälkkifd956242014-02-03 17:04:22 +020025
Kyösti Mälkkifd956242014-02-03 17:04:22 +020026void console_tx_byte(unsigned char byte)
27{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020028 __cbmemc_tx_byte(byte);
29 __spkmodem_tx_byte(byte);
30 __qemu_debugcon_tx_byte(byte);
31
Kyösti Mälkkid4a72f72015-05-13 20:20:00 +030032 /* Some consoles want newline conversion
33 * to keep terminals happy.
34 */
35 if (byte == '\n') {
36 __uart_tx_byte('\r');
37 __usb_tx_byte('\r');
38 }
39
Kyösti Mälkkif3390862014-02-26 15:19:04 +020040 __uart_tx_byte(byte);
41 __ne2k_tx_byte(byte);
42 __usb_tx_byte(byte);
Martin Roth3a543182015-09-28 15:27:24 -060043 __spiconsole_tx_byte(byte);
Youness Alaouic4b4ff32017-05-11 10:36:29 -040044 __flashconsole_tx_byte(byte);
Kyösti Mälkkifd956242014-02-03 17:04:22 +020045}
46
47void console_tx_flush(void)
48{
Kyösti Mälkkif3390862014-02-26 15:19:04 +020049 __uart_tx_flush();
50 __ne2k_tx_flush();
51 __usb_tx_flush();
Youness Alaouic4b4ff32017-05-11 10:36:29 -040052 __flashconsole_tx_flush();
Kyösti Mälkki40760722014-02-27 19:30:18 +020053}
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030054
Lee Leahy219c3322016-08-09 08:59:30 -070055void console_write_line(uint8_t *buffer, size_t number_of_bytes)
56{
57 /* Finish displaying all of the console data if requested */
58 if (number_of_bytes == 0) {
59 console_tx_flush();
60 return;
61 }
62
63 /* Output the console data */
64 while (number_of_bytes--)
65 console_tx_byte(*buffer++);
66}
67
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030068
Julius Wernercd49cce2019-03-05 16:53:33 -080069#if CONFIG(GDB_STUB) && (ENV_ROMSTAGE || ENV_RAMSTAGE)
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030070void gdb_hw_init(void)
71{
72 __gdb_hw_init();
73}
74
75void gdb_tx_byte(unsigned char byte)
76{
77 __gdb_tx_byte(byte);
78}
79
80void gdb_tx_flush(void)
81{
82 __gdb_tx_flush();
83}
84
85unsigned char gdb_rx_byte(void)
86{
87 return __gdb_rx_byte();
88}
89#endif