diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-03-12 17:38:04 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-03-12 17:38:04 -0700 |
commit | 6517fe26a2a0c89c3112f4a383c601572c71d64a (patch) | |
tree | d37eea7ae6f3e15eee94afb5c9c749a4cd800577 /pk/frontend.c | |
parent | a4ae7da6ef0c09c2616a0b82f7f569e4e134f75c (diff) | |
download | pk-6517fe26a2a0c89c3112f4a383c601572c71d64a.zip pk-6517fe26a2a0c89c3112f4a383c601572c71d64a.tar.gz pk-6517fe26a2a0c89c3112f4a383c601572c71d64a.tar.bz2 |
Update to new privileged spec
Diffstat (limited to 'pk/frontend.c')
-rw-r--r-- | pk/frontend.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/pk/frontend.c b/pk/frontend.c index 3771bca..0929d54 100644 --- a/pk/frontend.c +++ b/pk/frontend.c @@ -3,14 +3,30 @@ #include "pk.h" #include "atomic.h" #include "frontend.h" +#include "sbi.h" +#include "mcall.h" #include <stdint.h> +uint64_t tohost_sync(unsigned dev, unsigned cmd, uint64_t payload) +{ + uint64_t fromhost; + __sync_synchronize(); + + sbi_device_message m = {dev, cmd, payload}, *p; + do_mcall(MCALL_SEND_DEVICE_REQUEST, &m); + while ((p = (void*)do_mcall(MCALL_RECEIVE_DEVICE_RESPONSE)) == 0); + kassert(p == &m); + + __sync_synchronize(); + return m.data; +} + long frontend_syscall(long n, long a0, long a1, long a2, long a3, long a4, long a5, long a6) { static volatile uint64_t magic_mem[8]; static spinlock_t lock = SPINLOCK_INIT; - long irq = spinlock_lock_irqsave(&lock); + spinlock_lock(&lock); magic_mem[0] = n; magic_mem[1] = a0; @@ -21,15 +37,10 @@ long frontend_syscall(long n, long a0, long a1, long a2, long a3, long a4, long magic_mem[6] = a5; magic_mem[7] = a6; - mb(); - - write_csr(tohost, magic_mem); - while (swap_csr(fromhost, 0) == 0); - - mb(); + tohost_sync(0, 0, (uintptr_t)magic_mem); long ret = magic_mem[0]; - spinlock_unlock_irqrestore(&lock, irq); + spinlock_unlock(&lock); return ret; } |