aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/common/util.h
diff options
context:
space:
mode:
authorChristopher Celio <celio@eecs.berkeley.edu>2013-10-10 15:00:57 -0700
committerChristopher Celio <celio@eecs.berkeley.edu>2013-10-10 15:00:57 -0700
commit26015d8c21fe1e8e34e36ffd1c83de7b08ad4902 (patch)
treedf503e45fd71a95501b2c32019aa419260789007 /benchmarks/common/util.h
parent8dd97c2e7af399bc04b9d132bd1f1a4bdbbfec57 (diff)
downloadriscv-tests-26015d8c21fe1e8e34e36ffd1c83de7b08ad4902.zip
riscv-tests-26015d8c21fe1e8e34e36ffd1c83de7b08ad4902.tar.gz
riscv-tests-26015d8c21fe1e8e34e36ffd1c83de7b08ad4902.tar.bz2
Benchmarks now run in user-mode.
- Jump to main performed by eret. - Nano trap handler added. - FinishTest refactored to perform SYS_exit, placed in util.h. - Only SYS_exit with test_result=1 results in a passed test. - Any other exceptions/syscalls/test_results end program with FAILED test. - PCR status set to S64/U64 if compiled in 64b.
Diffstat (limited to 'benchmarks/common/util.h')
-rw-r--r--benchmarks/common/util.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/benchmarks/common/util.h b/benchmarks/common/util.h
index 83b2b6c..79d9256 100644
--- a/benchmarks/common/util.h
+++ b/benchmarks/common/util.h
@@ -5,6 +5,8 @@
#ifndef __UTIL_H
#define __UTIL_H
+#include <machine/syscall.h>
+
#define rdcycle() ({ unsigned long _c; asm volatile ("rdcycle %0" : "=r"(_c) :: "memory"); _c; })
#define rdinstret() ({ unsigned long _c; asm volatile ("rdinstret %0" : "=r"(_c) :: "memory"); _c; })
@@ -27,6 +29,32 @@ void __attribute__((noinline)) barrier()
__sync_synchronize();
}
-
+
+
+
+
+
+void finishTest(int test_result)
+{
+#if HOST_DEBUG
+ if ( test_result == 1 )
+ printf( "*** PASSED ***\n" );
+ else
+ printf( "*** FAILED *** (tohost = %d)\n", test_result);
+ exit(0);
+#else
+ {
+ // perform exit syscall
+ asm volatile(
+ "move a0,%0 ;"
+ "li a1,0 ;"
+ "li a2,0 ;"
+ "li a3,0 ;"
+ "li v0,%1 ;"
+ "syscall" : : "r"(test_result) , "i"(SYS_exit));
+ }
+#endif
+}
+
#endif //__UTIL_H