From 66fda264c796e7bcfe63282ae46c398d4a25c4d9 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 20 Feb 2017 18:49:19 -0800 Subject: minor HTIF cleanup + use WFI --- machine/htif.c | 11 +++++------ 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 -- cgit v1.1