X-Git-Url: https://git.libre-soc.org/?p=riscv-tests.git;a=blobdiff_plain;f=benchmarks%2Fcommon%2Fsyscalls.c;h=316f2fee67d870bf4cfad394023b2d4c93e2feac;hp=46206310c6aefd6066d5d44b228b7c07c34be5b5;hb=aff36b0963e6eee63906b3d8622be5a98ba27a43;hpb=22742246287feda0be2666ba14ca6f4a6bc73bb2 diff --git a/benchmarks/common/syscalls.c b/benchmarks/common/syscalls.c index 4620631..316f2fe 100644 --- a/benchmarks/common/syscalls.c +++ b/benchmarks/common/syscalls.c @@ -11,8 +11,8 @@ #define SYS_exit 93 #define SYS_stats 1234 -// initialized in crt.S -int have_vec; +extern volatile uint64_t tohost; +extern volatile uint64_t fromhost; static long handle_frontend_syscall(long which, long arg0, long arg1, long arg2) { @@ -22,8 +22,13 @@ static long handle_frontend_syscall(long which, long arg0, long arg1, long arg2) magic_mem[2] = arg1; magic_mem[3] = arg2; __sync_synchronize(); - write_csr(mtohost, (long)magic_mem); - while (swap_csr(mfromhost, 0) == 0); + + tohost = (uintptr_t)magic_mem; + while (fromhost == 0) + ; + fromhost = 0; + + __sync_synchronize(); return magic_mem[0]; } @@ -57,7 +62,7 @@ static int handle_stats(int enable) void tohost_exit(long code) { - write_csr(mtohost, (code << 1) | 1); + tohost = (code << 1) | 1; while (1); }