summaryrefslogtreecommitdiffstats
path: root/arch/riscv
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-01-08 18:15:18 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-01-12 11:21:49 +0100
commit3ab3ca1317974b53a488072d5212d2cdf589ae60 (patch)
tree84e76df68dd5a307b4fcbdfa2979371d155b5a47 /arch/riscv
parent1f66cbe01759930c27497eec24d28adca6d6bc94 (diff)
downloadbarebox-3ab3ca1317974b53a488072d5212d2cdf589ae60.tar.gz
barebox-3ab3ca1317974b53a488072d5212d2cdf589ae60.tar.xz
RISC-V: virt: riscvemu: add HTIF DEBUG_LL support
Default console of riscvemu is available Virt I/O console and as a HTIF blocking character device. We already support Virt I/O console, but the HTIF is easier to support for very early low level debugging. Add DEBUG_LL support to facilitate using it. Note: when using a framebuffer, riscvemu doesn't allocate a default console, so barebox calling into HTIF will segfault the emulator. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220108171524.587144-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/riscv')
-rw-r--r--arch/riscv/include/asm/debug_ll.h11
-rw-r--r--arch/riscv/include/asm/htif.h9
2 files changed, 20 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/debug_ll.h b/arch/riscv/include/asm/debug_ll.h
index 867c96d797..de9bc5f5fd 100644
--- a/arch/riscv/include/asm/debug_ll.h
+++ b/arch/riscv/include/asm/debug_ll.h
@@ -53,6 +53,17 @@ static inline void PUTC_LL(char ch)
#include <asm/debug_ll_litex.h>
+#elif defined CONFIG_DEBUG_RISCVEMU_HTIF
+
+#include <asm/htif.h>
+
+#ifndef __ASSEMBLY__
+static inline void PUTC_LL(char ch)
+{
+ htif_putc(IOMEM(HTIF_DEFAULT_BASE_ADDR), ch);
+}
+#endif
+
#endif
#ifndef debug_ll_init
diff --git a/arch/riscv/include/asm/htif.h b/arch/riscv/include/asm/htif.h
index 7312f09d2e..b35afdd98e 100644
--- a/arch/riscv/include/asm/htif.h
+++ b/arch/riscv/include/asm/htif.h
@@ -11,6 +11,10 @@
#define HTIF_DEV_SYSCALL 0
#define HTIF_CMD_SYSCALL 0
+#define HTIF_DEV_CONSOLE 1 /* blocking character device */
+#define HTIF_CMD_GETCHAR 0
+#define HTIF_CMD_PUTCHAR 1
+
#ifndef __ASSEMBLY__
#include <linux/types.h>
@@ -26,6 +30,11 @@ static inline void htif_tohost(u8 device, u8 command, u64 arg)
__htif_tohost(IOMEM(HTIF_DEFAULT_BASE_ADDR), device, command, arg);
}
+static inline void htif_putc(void __iomem *base, int c)
+{
+ __htif_tohost(base, HTIF_DEV_CONSOLE, HTIF_CMD_PUTCHAR, c);
+}
+
#endif
#endif