Stop using tohost/fromhost registers
authorAndrew Waterman <waterman@cs.berkeley.edu>
Mon, 2 May 2016 21:29:41 +0000 (14:29 -0700)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Mon, 2 May 2016 21:29:41 +0000 (14:29 -0700)
benchmarks/common/syscalls.c
env
isa/rv64mi/dirty.S
isa/rv64mi/mcsr.S

index 46206310c6aefd6066d5d44b228b7c07c34be5b5..9c72e3681fd41261596ab9c105de47a5fdc76372 100644 (file)
@@ -14,6 +14,9 @@
 // initialized in crt.S
 int have_vec;
 
+volatile uint64_t tohost __attribute__((aligned(64)));
+volatile uint64_t fromhost __attribute__((aligned(64)));
+
 static long handle_frontend_syscall(long which, long arg0, long arg1, long arg2)
 {
   volatile uint64_t magic_mem[8] __attribute__((aligned(64)));
@@ -22,8 +25,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 +65,7 @@ static int handle_stats(int enable)
 
 void tohost_exit(long code)
 {
-  write_csr(mtohost, (code << 1) | 1);
+  tohost = (code << 1) | 1;
   while (1);
 }
 
diff --git a/env b/env
index 3d45ca302dbf5ac22cfac8fb025c05c735c35e26..b54a6f8e11f43ac6df310016723ef6eb2f7d3a33 160000 (submodule)
--- a/env
+++ b/env
@@ -1 +1 @@
-Subproject commit 3d45ca302dbf5ac22cfac8fb025c05c735c35e26
+Subproject commit b54a6f8e11f43ac6df310016723ef6eb2f7d3a33
index 522812977a8fe5496f3e2bd7213fd45c59d8d163..9de358b81dd9842e5f8d924fbe44044ba03ab869 100644 (file)
@@ -76,11 +76,17 @@ stvec_handler:
 die:
   RVTEST_FAIL
 
-.data
+RVTEST_CODE_END
+
+  .data
+RVTEST_DATA_BEGIN
+
+  TEST_DATA
+
 .align 12
 page_table_1: .dword (DRAM_BASE/RISCV_PGSIZE << PTE_PPN_SHIFT) | PTE_V | PTE_TYPE_URX_SRX
 dummy: .dword 0
 .align 12
 page_table_2: .dword (DRAM_BASE/RISCV_PGSIZE << PTE_PPN_SHIFT) | PTE_V | PTE_TYPE_URWX_SRWX
 
-RVTEST_CODE_END
+RVTEST_DATA_END
index f7048275dcc215469ea31367bcfecaa76f2cac18..b66611c86594d2108e7e7f94e674ba6a5ecfd758 100644 (file)
@@ -36,3 +36,10 @@ RVTEST_CODE_BEGIN
   TEST_PASSFAIL
 
 RVTEST_CODE_END
+
+  .data
+RVTEST_DATA_BEGIN
+
+  TEST_DATA
+
+RVTEST_DATA_END