diff options
author | Xiang Wang <wxjstz@126.com> | 2018-08-15 16:27:05 +0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2018-11-05 09:04:01 +0000 |
commit | 22e0c560bb565642d52e4e0f8bab000c8d06f0b8 (patch) | |
tree | a960e9bc01d3d4d9ddb65ba828b64d39a64baade /src/arch/riscv/trap_handler.c | |
parent | 26f725efc235b282e20aa678f8e683a014920b71 (diff) | |
download | coreboot-22e0c560bb565642d52e4e0f8bab000c8d06f0b8.tar.xz |
riscv: add support for supervisor binary interface (SBI)
SBI is runtime service for OS. For an introduction, please refer to
https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.md
Change-Id: Ib6c1f21d2f085f02208305dc4e3a0f970d400c27
Signed-off-by: Xiang Wang <wxjstz@126.com>
Reviewed-on: https://review.coreboot.org/28096
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/arch/riscv/trap_handler.c')
-rw-r--r-- | src/arch/riscv/trap_handler.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/arch/riscv/trap_handler.c b/src/arch/riscv/trap_handler.c index 8029218fb2..73c52787ae 100644 --- a/src/arch/riscv/trap_handler.c +++ b/src/arch/riscv/trap_handler.c @@ -19,6 +19,8 @@ #include <console/console.h> #include <string.h> #include <vm.h> +#include <mcall.h> +#include <sbi.h> static const char *const exception_names[] = { "Instruction address misaligned", @@ -92,6 +94,20 @@ static void interrupt_handler(trapframe *tf) set_csr(mip, MIP_STIP); break; + case IRQ_M_SOFT: + if (HLS()->ipi_pending & IPI_SOFT) { + set_csr(mip, MIP_SSIP); + } else if (HLS()->ipi_pending & IPI_FENCE_I) { + asm volatile("fence.i"); + } else if (HLS()->ipi_pending & IPI_SFENCE_VMA) { + asm volatile("sfence.vma"); + } else if (HLS()->ipi_pending & IPI_SFENCE_VMA_ASID) { + asm volatile("sfence.vma"); + } else if (HLS()->ipi_pending & IPI_SHUTDOWN) { + while (HLS()->ipi_pending & IPI_SHUTDOWN) + asm volatile("wfi"); + } + break; default: printk(BIOS_EMERG, "======================================\n"); printk(BIOS_EMERG, "coreboot: Unknown machine interrupt: 0x%llx\n", @@ -117,11 +133,13 @@ void trap_handler(trapframe *tf) case CAUSE_LOAD_ACCESS: case CAUSE_STORE_ACCESS: case CAUSE_USER_ECALL: - case CAUSE_SUPERVISOR_ECALL: case CAUSE_HYPERVISOR_ECALL: case CAUSE_MACHINE_ECALL: print_trap_information(tf); break; + case CAUSE_SUPERVISOR_ECALL: + handle_sbi(tf); + return; case CAUSE_MISALIGNED_LOAD: case CAUSE_MISALIGNED_STORE: print_trap_information(tf); |