Angel Pons | b706ab3 | 2020-04-02 23:48:09 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 2 | |
Kyösti Mälkki | 1d7541f | 2014-02-17 21:34:42 +0200 | [diff] [blame] | 3 | #include <console/cbmem_console.h> |
Edward O'Callaghan | 0ddb826 | 2014-06-17 18:37:08 +1000 | [diff] [blame] | 4 | #include <console/ne2k.h> |
| 5 | #include <console/qemu_debugcon.h> |
| 6 | #include <console/spkmodem.h> |
| 7 | #include <console/streams.h> |
Kyösti Mälkki | 1d7541f | 2014-02-17 21:34:42 +0200 | [diff] [blame] | 8 | #include <console/uart.h> |
| 9 | #include <console/usb.h> |
Martin Roth | 3a54318 | 2015-09-28 15:27:24 -0600 | [diff] [blame] | 10 | #include <console/spi.h> |
Youness Alaoui | c4b4ff3 | 2017-05-11 10:36:29 -0400 | [diff] [blame] | 11 | #include <console/flash.h> |
Kyösti Mälkki | 1d7541f | 2014-02-17 21:34:42 +0200 | [diff] [blame] | 12 | |
Kyösti Mälkki | 21333f9 | 2014-02-14 10:04:31 +0200 | [diff] [blame] | 13 | void console_hw_init(void) |
Stefan Reinauer | 5a1f597 | 2010-03-31 14:34:40 +0000 | [diff] [blame] | 14 | { |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 15 | __cbmemc_init(); |
| 16 | __spkmodem_init(); |
| 17 | __qemu_debugcon_init(); |
| 18 | |
| 19 | __uart_init(); |
| 20 | __ne2k_init(); |
| 21 | __usbdebug_init(); |
Martin Roth | 3a54318 | 2015-09-28 15:27:24 -0600 | [diff] [blame] | 22 | __spiconsole_init(); |
Youness Alaoui | c4b4ff3 | 2017-05-11 10:36:29 -0400 | [diff] [blame] | 23 | __flashconsole_init(); |
Stefan Reinauer | 5a1f597 | 2010-03-31 14:34:40 +0000 | [diff] [blame] | 24 | } |
Kyösti Mälkki | fd95624 | 2014-02-03 17:04:22 +0200 | [diff] [blame] | 25 | |
Kyösti Mälkki | fd95624 | 2014-02-03 17:04:22 +0200 | [diff] [blame] | 26 | void console_tx_byte(unsigned char byte) |
| 27 | { |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 28 | __cbmemc_tx_byte(byte); |
| 29 | __spkmodem_tx_byte(byte); |
| 30 | __qemu_debugcon_tx_byte(byte); |
| 31 | |
Kyösti Mälkki | d4a72f7 | 2015-05-13 20:20:00 +0300 | [diff] [blame] | 32 | /* 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älkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 40 | __uart_tx_byte(byte); |
| 41 | __ne2k_tx_byte(byte); |
| 42 | __usb_tx_byte(byte); |
Martin Roth | 3a54318 | 2015-09-28 15:27:24 -0600 | [diff] [blame] | 43 | __spiconsole_tx_byte(byte); |
Youness Alaoui | c4b4ff3 | 2017-05-11 10:36:29 -0400 | [diff] [blame] | 44 | __flashconsole_tx_byte(byte); |
Kyösti Mälkki | fd95624 | 2014-02-03 17:04:22 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void console_tx_flush(void) |
| 48 | { |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 49 | __uart_tx_flush(); |
| 50 | __ne2k_tx_flush(); |
| 51 | __usb_tx_flush(); |
Youness Alaoui | c4b4ff3 | 2017-05-11 10:36:29 -0400 | [diff] [blame] | 52 | __flashconsole_tx_flush(); |
Kyösti Mälkki | 4076072 | 2014-02-27 19:30:18 +0200 | [diff] [blame] | 53 | } |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 54 | |
Lee Leahy | 219c332 | 2016-08-09 08:59:30 -0700 | [diff] [blame] | 55 | void 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älkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 68 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 69 | #if CONFIG(GDB_STUB) && (ENV_ROMSTAGE || ENV_RAMSTAGE) |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 70 | void gdb_hw_init(void) |
| 71 | { |
| 72 | __gdb_hw_init(); |
| 73 | } |
| 74 | |
| 75 | void gdb_tx_byte(unsigned char byte) |
| 76 | { |
| 77 | __gdb_tx_byte(byte); |
| 78 | } |
| 79 | |
| 80 | void gdb_tx_flush(void) |
| 81 | { |
| 82 | __gdb_tx_flush(); |
| 83 | } |
| 84 | |
| 85 | unsigned char gdb_rx_byte(void) |
| 86 | { |
| 87 | return __gdb_rx_byte(); |
| 88 | } |
| 89 | #endif |