1 /*
2 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
3 * Copyright 2015, 2016 Hesham Almatary <heshamelmatary@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 */
7
8 #include <config.h>
9 #include <machine/io.h>
10 #include <arch/sbi.h>
11
12 #ifdef CONFIG_PRINTING
kernel_putDebugChar(unsigned char c)13 void kernel_putDebugChar(unsigned char c)
14 {
15 /* Don't use any UART driver, but write to the SBI console. It depends on
16 * the SBI implementation if printing a '\r' (CR) before any '\n' (LF) is
17 * required explicitly or if SBI takes care of this. Currently BBL requires
18 * it, while OpenSBI takes care of this internally. Since we dropped BBL
19 * support in favor of OpenSBI, we do not print a '\r' (CR) here.
20 */
21 sbi_console_putchar(c);
22 }
23 #endif /* CONFIG_PRINTING */
24
25 #ifdef CONFIG_DEBUG_BUILD
kernel_getDebugChar(void)26 unsigned char kernel_getDebugChar(void)
27 {
28 /* Don't use UART, but read from the SBI console. */
29 return sbi_console_getchar();
30 }
31 #endif /* CONFIG_DEBUG_BUILD */
32