diff options
Diffstat (limited to 'v')
-rw-r--r-- | v/entry.S | 29 | ||||
-rw-r--r-- | v/vm.c | 17 |
2 files changed, 16 insertions, 30 deletions
@@ -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 @@ -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 { \ |