summaryrefslogtreecommitdiff
path: root/drivers/serial/serial_sbi.c
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2021-09-12 10:56:09 -0500
committerLeo Yu-Chi Liang <ycliang@andestech.com>2021-10-07 16:08:23 +0800
commit41f7be733444b9221c828ee9c7c22cddfac5a28c (patch)
treec1c7d9166ae8d2ede7fa861d08b56be6ef459951 /drivers/serial/serial_sbi.c
parent425c08faa8a2d6af5d9c1d83a97572f6401137bf (diff)
serial: Add a debug console using the RISC-V SBI interface
The RISC-V SBI interface v0.1 provides a function for printing a character to the console. Even though SBI v0.1 functions are deprecated, the SBI console is quite useful for early debugging, because it works without any dcache, memory, or MMIO access in S mode. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/serial/serial_sbi.c')
-rw-r--r--drivers/serial/serial_sbi.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/serial/serial_sbi.c b/drivers/serial/serial_sbi.c
new file mode 100644
index 00000000000..b9f35ed36e6
--- /dev/null
+++ b/drivers/serial/serial_sbi.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <debug_uart.h>
+#include <asm/sbi.h>
+
+static inline void _debug_uart_init(void)
+{
+}
+
+static inline void _debug_uart_putc(int c)
+{
+ if (CONFIG_IS_ENABLED(RISCV_SMODE))
+ sbi_console_putchar(c);
+}
+
+DEBUG_UART_FUNCS