summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--p/riscv_test.h9
-rw-r--r--v/entry.S29
-rw-r--r--v/vm.c17
3 files changed, 23 insertions, 32 deletions
diff --git a/p/riscv_test.h b/p/riscv_test.h
index 903f23f..d3e8027 100644
--- a/p/riscv_test.h
+++ b/p/riscv_test.h
@@ -114,7 +114,7 @@ handle_exception: \
/* some unhandlable exception occurred */ \
1: ori TESTNUM, TESTNUM, 1337; \
write_tohost: \
- csrw mtohost, TESTNUM; \
+ sw TESTNUM, tohost, t5; \
j write_tohost; \
reset_vector: \
RISCV_MULTICORE_DISABLE; \
@@ -175,7 +175,12 @@ reset_vector: \
#define EXTRA_DATA
-#define RVTEST_DATA_BEGIN EXTRA_DATA .align 4; .global begin_signature; begin_signature:
+#define RVTEST_DATA_BEGIN \
+ EXTRA_DATA \
+ .align 6; .global tohost; tohost: .dword 0; \
+ .align 6; .global fromhost; fromhost: .dword 0; \
+ .align 4; .global begin_signature; begin_signature:
+
#define RVTEST_DATA_END .align 4; .global end_signature; end_signature:
#endif
diff --git a/v/entry.S b/v/entry.S
index 64d9606..460428a 100644
--- a/v/entry.S
+++ b/v/entry.S
@@ -22,13 +22,6 @@ nmi_vector:
j wtf
trap_vector:
- # we can safely clobber caller-saved registers here, because we were
- # either invoked via do_tohost or we are about to bail out
- csrr t0, mcause
- li t1, CAUSE_SUPERVISOR_ECALL
- beq t0, t1, handle_tohost
- li t1, CAUSE_MACHINE_ECALL
- beq t0, t1, handle_tohost
j wtf
handle_reset:
@@ -128,25 +121,3 @@ trap_entry:
move a0, sp
j handle_trap
-
- .global do_tohost
-do_tohost:
- ecall
- ret
-
-handle_tohost:
-1:csrrw t0, mtohost, a0
- bnez t0, 1b
-
-1:csrrw t0, mfromhost, x0
- bnez t0, 1b
-
- csrr t0, mepc
- addi t0, t0, 4
- csrw mepc, t0
- mret
-
-wtf:
- li a0, 841
-1:csrw mtohost, a0
- j 1b
diff --git a/v/vm.c b/v/vm.c
index ef1f733..5fd1b11 100644
--- a/v/vm.c
+++ b/v/vm.c
@@ -8,7 +8,17 @@
void trap_entry();
void pop_tf(trapframe_t*);
-void do_tohost(long tohost_value);
+
+volatile uint64_t tohost __attribute__((aligned(64)));
+volatile uint64_t fromhost __attribute__((aligned(64)));
+
+static void do_tohost(uint64_t tohost_value)
+{
+ tohost = tohost_value;
+ while (fromhost == 0)
+ ;
+ fromhost = 0;
+}
#define pa2kva(pa) ((void*)(pa) - DRAM_BASE - MEGAPAGE_SIZE)
#define uva2kva(pa) ((void*)(pa) - MEGAPAGE_SIZE)
@@ -36,6 +46,11 @@ static void terminate(int code)
while (1);
}
+void wtf()
+{
+ terminate(841);
+}
+
#define stringify1(x) #x
#define stringify(x) stringify1(x)
#define assert(x) do { \