diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-05-14 02:14:14 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-05-14 02:14:14 -0700 |
commit | c5f18f61c07228f6606d2217230751d8ec6e091a (patch) | |
tree | 217e34eb6a476e199a14a69ee38d05fc635a2b21 /pk | |
parent | 3f9b5d7ab80d11eb11739d9a02b4d0b66ace058b (diff) | |
download | pk-c5f18f61c07228f6606d2217230751d8ec6e091a.zip pk-c5f18f61c07228f6606d2217230751d8ec6e091a.tar.gz pk-c5f18f61c07228f6606d2217230751d8ec6e091a.tar.bz2 |
Add sbi_shutdown call
Diffstat (limited to 'pk')
-rw-r--r-- | pk/mcall.h | 1 | ||||
-rw-r--r-- | pk/mtrap.c | 12 | ||||
-rw-r--r-- | pk/sbi.S | 1 | ||||
-rw-r--r-- | pk/sbi.h | 1 | ||||
-rw-r--r-- | pk/sbi_entry.S | 22 |
5 files changed, 27 insertions, 10 deletions
@@ -6,6 +6,7 @@ #define MCALL_SEND_DEVICE_REQUEST 2 #define MCALL_RECEIVE_DEVICE_RESPONSE 3 #define MCALL_SEND_IPI 4 +#define MCALL_SHUTDOWN 5 #ifndef __ASSEMBLER__ @@ -172,9 +172,16 @@ static uintptr_t mcall_send_ipi(uintptr_t recipient) return 0; } +static uintptr_t mcall_shutdown() +{ + while (1) + write_csr(mtohost, 1); + return 0; +} + uintptr_t mcall_trap(uintptr_t mcause, uintptr_t* regs) { - uintptr_t n = regs[10], arg0 = regs[11], retval; + uintptr_t n = regs[17], arg0 = regs[10], retval; switch (n) { case MCALL_HART_ID: @@ -192,6 +199,9 @@ uintptr_t mcall_trap(uintptr_t mcause, uintptr_t* regs) case MCALL_SEND_IPI: retval = mcall_send_ipi(arg0); break; + case MCALL_SHUTDOWN: + retval = mcall_shutdown(); + break; default: retval = -ENOSYS; break; @@ -6,3 +6,4 @@ .globl sbi_receive_device_response; sbi_receive_device_response = -1968 .globl sbi_send_ipi; sbi_send_ipi = -1952 .globl sbi_timebase; sbi_timebase = -1936 +.globl sbi_shutdown; sbi_shutdown = -1920 @@ -14,6 +14,7 @@ unsigned long sbi_num_harts(void); unsigned long sbi_timebase(void); void sbi_send_ipi(uintptr_t hart_id); void sbi_console_putchar(unsigned char ch); +void sbi_shutdown(void); typedef struct { unsigned long dev; diff --git a/pk/sbi_entry.S b/pk/sbi_entry.S index 918ea70..05d66ad 100644 --- a/pk/sbi_entry.S +++ b/pk/sbi_entry.S @@ -12,7 +12,7 @@ sbi_base: # hart_id .align 4 - li a0, MCALL_HART_ID + li a7, MCALL_HART_ID ecall ret @@ -27,29 +27,25 @@ sbi_base: # console_putchar .align 4 - mv a1, a0 - li a0, MCALL_CONSOLE_PUTCHAR + li a7, MCALL_CONSOLE_PUTCHAR ecall ret # send_device_request .align 4 - mv a1, a0 - li a0, MCALL_SEND_DEVICE_REQUEST + li a7, MCALL_SEND_DEVICE_REQUEST ecall ret # receive_device_response .align 4 - mv a1, a0 - li a0, MCALL_RECEIVE_DEVICE_RESPONSE + li a7, MCALL_RECEIVE_DEVICE_RESPONSE ecall ret # send ipi .align 4 - mv a1, a0 - li a0, MCALL_SEND_IPI + li a7, MCALL_SEND_IPI ecall ret @@ -58,10 +54,18 @@ sbi_base: li a0, 1000000000 # or, you know, we could provide the correct answer ret + # shutdown + .align 4 + li a7, MCALL_SHUTDOWN + ecall + # end of SBI trampolines .globl do_mcall do_mcall: + mv a7, a0 + mv a0, a1 + mv a1, a2 ecall ret |