diff options
author | Wesley W. Terpstra <wesley@sifive.com> | 2017-03-27 12:13:53 -0700 |
---|---|---|
committer | Wesley W. Terpstra <wesley@sifive.com> | 2017-03-27 15:50:22 -0700 |
commit | 9fa7b30887301f149f2497469a442d0887b21149 (patch) | |
tree | 33b67126a0fb86de8603aa8cae2496f2342f45d0 /machine/mtrap.c | |
parent | 3473915b3a3fd925a68fc3260c64824cab2846d2 (diff) | |
download | riscv-pk-9fa7b30887301f149f2497469a442d0887b21149.zip riscv-pk-9fa7b30887301f149f2497469a442d0887b21149.tar.gz riscv-pk-9fa7b30887301f149f2497469a442d0887b21149.tar.bz2 |
uart: add physical device driver
Diffstat (limited to 'machine/mtrap.c')
-rw-r--r-- | machine/mtrap.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/machine/mtrap.c b/machine/mtrap.c index 6e85d26..d7def4c 100644 --- a/machine/mtrap.c +++ b/machine/mtrap.c @@ -4,6 +4,7 @@ #include "atomic.h" #include "bits.h" #include "vm.h" +#include "uart.h" #include "unprivileged_memory.h" #include <errno.h> #include <stdarg.h> @@ -16,7 +17,11 @@ void __attribute__((noreturn)) bad_trap(uintptr_t* regs, uintptr_t dummy, uintpt static uintptr_t mcall_console_putchar(uint8_t ch) { - htif_console_putchar(ch); + if (uart) { + uart_putchar(ch); + } else { + htif_console_putchar(ch); + } return 0; } @@ -52,7 +57,11 @@ static void send_ipi(uintptr_t recipient, int event) static uintptr_t mcall_console_getchar() { - return htif_console_getchar(); + if (uart) { + return uart_getchar(); + } else { + return htif_console_getchar(); + } } static uintptr_t mcall_clear_ipi() |