projects
/
riscv-tests.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix RV32 handling of syscall arguments
[riscv-tests.git]
/
benchmarks
/
common
/
syscalls.c
diff --git
a/benchmarks/common/syscalls.c
b/benchmarks/common/syscalls.c
index 1e4efab1e3f28ff6cf70b4463f5d7e1e48aaa8cd..ce6d6535176ca80f62900ddd865244c2a5b22252 100644
(file)
--- a/
benchmarks/common/syscalls.c
+++ b/
benchmarks/common/syscalls.c
@@
-1,11
+1,14
@@
+// See LICENSE for license details.
+
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <limits.h>
-#include <machine/syscall.h>
#include "util.h"
#include "util.h"
+#define SYS_write 64
+#define SYS_exit 93
#define SYS_stats 1234
// initialized in crt.S
#define SYS_stats 1234
// initialized in crt.S
@@
-19,8
+22,8
@@
static long handle_frontend_syscall(long which, long arg0, long arg1, long arg2)
magic_mem[2] = arg1;
magic_mem[3] = arg2;
__sync_synchronize();
magic_mem[2] = arg1;
magic_mem[3] = arg2;
__sync_synchronize();
- write_csr(tohost, (long)magic_mem);
- while (swap_csr(fromhost, 0) == 0);
+ write_csr(
m
tohost, (long)magic_mem);
+ while (swap_csr(
m
fromhost, 0) == 0);
return magic_mem[0];
}
return magic_mem[0];
}
@@
-57,9
+60,9
@@
static int handle_stats(int enable)
return 0;
}
return 0;
}
-
static void tohost_exit(int
code)
+
void tohost_exit(long
code)
{
{
- write_csr(tohost, (code << 1) | 1);
+ write_csr(
m
tohost, (code << 1) | 1);
while (1);
}
while (1);
}
@@
-72,7
+75,7
@@
long handle_trap(long cause, long epc, long regs[32])
if (cause == CAUSE_ILLEGAL_INSTRUCTION &&
(*(int*)epc & *csr_insn) == *csr_insn)
;
if (cause == CAUSE_ILLEGAL_INSTRUCTION &&
(*(int*)epc & *csr_insn) == *csr_insn)
;
- else if (cause != CAUSE_
SYS
CALL)
+ else if (cause != CAUSE_
USER_E
CALL)
tohost_exit(1337);
else if (regs[17] == SYS_exit)
tohost_exit(regs[10]);
tohost_exit(1337);
else if (regs[17] == SYS_exit)
tohost_exit(regs[10]);