diff options
author | Andrew Waterman <andrew@sifive.com> | 2017-02-20 18:49:19 -0800 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2017-02-20 18:52:47 -0800 |
commit | 66fda264c796e7bcfe63282ae46c398d4a25c4d9 (patch) | |
tree | de88d8945f2ef8c439f1f196f7fa29e8782727d6 /machine | |
parent | 7c4765029820580c0c01b3321fe4310c8416dcb6 (diff) | |
download | riscv-pk-66fda264c796e7bcfe63282ae46c398d4a25c4d9.zip riscv-pk-66fda264c796e7bcfe63282ae46c398d4a25c4d9.tar.gz riscv-pk-66fda264c796e7bcfe63282ae46c398d4a25c4d9.tar.bz2 |
minor HTIF cleanup + use WFI
Diffstat (limited to 'machine')
-rw-r--r-- | machine/htif.c | 11 | ||||
-rw-r--r-- | machine/htif.h | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/machine/htif.c b/machine/htif.c index a513305..8b8d69b 100644 --- a/machine/htif.c +++ b/machine/htif.c @@ -2,8 +2,8 @@ #include "atomic.h" #include "mtrap.h" -volatile uint64_t tohost __attribute__((aligned(64))) __attribute__((section("htif"))); -volatile uint64_t fromhost __attribute__((aligned(64))) __attribute__((section("htif"))); +volatile uint64_t tohost __attribute__((section("htif"))); +volatile uint64_t fromhost __attribute__((section("htif"))); volatile int htif_console_buf; static spinlock_t htif_lock = SPINLOCK_INIT; @@ -19,8 +19,7 @@ static void __check_fromhost() uint64_t fh = fromhost; if (!fh) return; - if (!(FROMHOST_DEV(fh) == 1 && FROMHOST_CMD(fh) == 0)) - die("unexpected htif interrupt"); + assert(FROMHOST_DEV(fh) == 1 && FROMHOST_CMD(fh) == 0); htif_console_buf = 1 + (uint8_t)FROMHOST_DATA(fh); fromhost = 0; } @@ -54,14 +53,14 @@ static void do_tohost_fromhost(uintptr_t dev, uintptr_t cmd, uintptr_t data) } __check_fromhost(); } + wfi(); } spinlock_unlock(&htif_lock); } -uintptr_t htif_syscall(uintptr_t arg) +void htif_syscall(uintptr_t arg) { do_tohost_fromhost(0, 0, arg); - return 0; } void htif_console_putchar(uint8_t ch) diff --git a/machine/htif.h b/machine/htif.h index f47e965..fa768d8 100644 --- a/machine/htif.h +++ b/machine/htif.h @@ -18,6 +18,6 @@ void htif_console_putchar(uint8_t); int htif_console_getchar(); void htif_poweroff() __attribute__((noreturn)); -uintptr_t htif_syscall(uintptr_t); +void htif_syscall(uintptr_t); #endif |