diff options
author | Andrew Waterman <aswaterman@gmail.com> | 2018-08-15 02:46:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-15 02:46:11 -0700 |
commit | 706cc77c369fd3e4734b5a6aa813d421347f1814 (patch) | |
tree | a581ae04d9126916a4fd7973a636c807ca02bb24 /machine | |
parent | 41ff94a84c6bc7ada906a38a250f4d175d796d92 (diff) | |
download | riscv-pk-706cc77c369fd3e4734b5a6aa813d421347f1814.zip riscv-pk-706cc77c369fd3e4734b5a6aa813d421347f1814.tar.gz riscv-pk-706cc77c369fd3e4734b5a6aa813d421347f1814.tar.bz2 |
Fix printm on RV32 (#119)
Use a proxy syscall instead of a blocking character write.
Resolves #84
Diffstat (limited to 'machine')
-rw-r--r-- | machine/htif.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/machine/htif.c b/machine/htif.c index d3921a4..aae8c56 100644 --- a/machine/htif.c +++ b/machine/htif.c @@ -4,6 +4,7 @@ #include "atomic.h" #include "mtrap.h" #include "fdt.h" +#include "syscall.h" #include <string.h> extern uint64_t __htif_base; @@ -48,6 +49,11 @@ static void __set_tohost(uintptr_t dev, uintptr_t cmd, uintptr_t data) int htif_console_getchar() { +#if __riscv_xlen == 32 + // HTIF devices are not supported on RV32 + return -1; +#endif + spinlock_lock(&htif_lock); __check_fromhost(); int ch = htif_console_buf; @@ -85,9 +91,19 @@ void htif_syscall(uintptr_t arg) void htif_console_putchar(uint8_t ch) { +#if __riscv_xlen == 32 + // HTIF devices are not supported on RV32, so proxy a write system call + volatile uint64_t magic_mem[8]; + magic_mem[0] = SYS_write; + magic_mem[1] = 1; + magic_mem[2] = (uintptr_t)&ch; + magic_mem[3] = 1; + do_tohost_fromhost(0, 0, (uintptr_t)magic_mem); +#else spinlock_lock(&htif_lock); __set_tohost(1, 1, ch); spinlock_unlock(&htif_lock); +#endif } void htif_poweroff() |