From 857e33e27f1feeec328ae8be5ad61ee51b75e4ec Mon Sep 17 00:00:00 2001 From: Jonathan Neuschäfer Date: Mon, 22 Aug 2016 19:37:16 +0200 Subject: arch/riscv: Implement the SBI again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not all SBI calls are implemented, but it's enough to see a couple dozen lines of Linux boot output. It should also be noted that the SBI is still in flux: https://groups.google.com/a/groups.riscv.org/forum/#!topic/sw-dev/6oNhlW0OFKM Change-Id: I80e4fe508336d6428ca7136bc388fbc3cda4f1e4 Signed-off-by: Jonathan Neuschäfer Reviewed-on: https://review.coreboot.org/16119 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich --- src/arch/riscv/trap_handler.c | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'src/arch/riscv/trap_handler.c') diff --git a/src/arch/riscv/trap_handler.c b/src/arch/riscv/trap_handler.c index d8ac784c27..29d5a0b28c 100644 --- a/src/arch/riscv/trap_handler.c +++ b/src/arch/riscv/trap_handler.c @@ -15,63 +15,56 @@ */ #include +#include #include #include #include #include -#define HART_ID 0 -#define CONSOLE_PUT 1 -#define SEND_DEVICE_REQUEST 2 -#define RECEIVE_DEVICE_RESPONSE 3 -#define SEND_IPI 4 -#define CLEAR_IPI 5 -#define SHUTDOWN 6 -#define SET_TIMER 7 -#define QUERY_MEMORY 8 - -int loopBreak2 = 1; - void handle_supervisor_call(trapframe *tf) { - uintptr_t call = tf->gpr[17]; - uintptr_t arg0 = tf->gpr[10]; - uintptr_t arg1 = tf->gpr[11]; + uintptr_t call = tf->gpr[17]; /* a7 */ + uintptr_t arg0 = tf->gpr[10]; /* a0 */ + uintptr_t arg1 = tf->gpr[11]; /* a1 */ uintptr_t returnValue; switch(call) { - case HART_ID: + case SBI_ECALL_HART_ID: printk(BIOS_DEBUG, "Getting hart id...\n"); - returnValue = mcall_hart_id(); + returnValue = read_csr(mhartid); break; - case CONSOLE_PUT: + case SBI_ECALL_NUM_HARTS: + /* TODO: parse the hardware-supplied config string and + return the correct value */ + returnValue = 1; + case SBI_ECALL_CONSOLE_PUT: returnValue = mcall_console_putchar(arg0); break; - case SEND_DEVICE_REQUEST: + case SBI_ECALL_SEND_DEVICE_REQUEST: printk(BIOS_DEBUG, "Sending device request...\n"); returnValue = mcall_dev_req((sbi_device_message*) arg0); break; - case RECEIVE_DEVICE_RESPONSE: + case SBI_ECALL_RECEIVE_DEVICE_RESPONSE: printk(BIOS_DEBUG, "Getting device response...\n"); returnValue = mcall_dev_resp(); break; - case SEND_IPI: + case SBI_ECALL_SEND_IPI: printk(BIOS_DEBUG, "Sending IPI...\n"); returnValue = mcall_send_ipi(arg0); break; - case CLEAR_IPI: + case SBI_ECALL_CLEAR_IPI: printk(BIOS_DEBUG, "Clearing IPI...\n"); returnValue = mcall_clear_ipi(); break; - case SHUTDOWN: + case SBI_ECALL_SHUTDOWN: printk(BIOS_DEBUG, "Shutting down...\n"); returnValue = mcall_shutdown(); break; - case SET_TIMER: + case SBI_ECALL_SET_TIMER: printk(BIOS_DEBUG, "Setting timer to %p (current time is %p)...\n", (void *)arg0, (void *)rdtime()); returnValue = mcall_set_timer(arg0); break; - case QUERY_MEMORY: + case SBI_ECALL_QUERY_MEMORY: printk(BIOS_DEBUG, "Querying memory, CPU #%lld...\n", arg0); returnValue = mcall_query_memory(arg0, (memory_block_info*) arg1); break; -- cgit v1.2.3