summaryrefslogtreecommitdiff
path: root/v
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2016-05-02 14:29:14 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2016-05-02 14:29:14 -0700
commitb54a6f8e11f43ac6df310016723ef6eb2f7d3a33 (patch)
tree21edb00b64ec0c356d0055036f77885eeecab4e8 /v
parent3d45ca302dbf5ac22cfac8fb025c05c735c35e26 (diff)
downloadenv-b54a6f8e11f43ac6df310016723ef6eb2f7d3a33.zip
env-b54a6f8e11f43ac6df310016723ef6eb2f7d3a33.tar.gz
env-b54a6f8e11f43ac6df310016723ef6eb2f7d3a33.tar.bz2
Stop using mtohost/mfromhost registers
Diffstat (limited to 'v')
-rw-r--r--v/entry.S29
-rw-r--r--v/vm.c17
2 files changed, 16 insertions, 30 deletions
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 { \