2018-09-25 18:31:29 +02:00
|
|
|
// See LICENSE for license details
|
|
|
|
|
|
|
|
#ifndef ENTRY_S
|
|
|
|
#define ENTRY_S
|
|
|
|
|
|
|
|
#include "encoding.h"
|
2024-01-14 20:35:05 +01:00
|
|
|
#include "bits.h"
|
2018-09-25 18:31:29 +02:00
|
|
|
|
|
|
|
.section .text.entry
|
|
|
|
.align 2
|
|
|
|
.global trap_entry
|
|
|
|
trap_entry:
|
2024-09-26 12:18:50 +02:00
|
|
|
addi sp, sp, -32*REGBYTES
|
|
|
|
|
|
|
|
sw x1, 1*REGBYTES(sp)
|
|
|
|
sw x2, 2*REGBYTES(sp)
|
|
|
|
sw x3, 3*REGBYTES(sp)
|
|
|
|
sw x4, 4*REGBYTES(sp)
|
|
|
|
sw x5, 5*REGBYTES(sp)
|
|
|
|
sw x6, 6*REGBYTES(sp)
|
|
|
|
sw x7, 7*REGBYTES(sp)
|
|
|
|
sw x8, 8*REGBYTES(sp)
|
|
|
|
sw x9, 9*REGBYTES(sp)
|
|
|
|
sw x10, 10*REGBYTES(sp)
|
|
|
|
sw x11, 11*REGBYTES(sp)
|
|
|
|
sw x12, 12*REGBYTES(sp)
|
|
|
|
sw x13, 13*REGBYTES(sp)
|
|
|
|
sw x14, 14*REGBYTES(sp)
|
|
|
|
sw x15, 15*REGBYTES(sp)
|
2023-08-20 15:00:51 +02:00
|
|
|
#ifndef __riscv_abi_rve
|
2024-09-26 12:18:50 +02:00
|
|
|
sw x16, 16*REGBYTES(sp)
|
|
|
|
sw x17, 17*REGBYTES(sp)
|
|
|
|
sw x18, 18*REGBYTES(sp)
|
|
|
|
sw x19, 19*REGBYTES(sp)
|
|
|
|
sw x20, 20*REGBYTES(sp)
|
|
|
|
sw x21, 21*REGBYTES(sp)
|
|
|
|
sw x22, 22*REGBYTES(sp)
|
|
|
|
sw x23, 23*REGBYTES(sp)
|
|
|
|
sw x24, 24*REGBYTES(sp)
|
|
|
|
sw x25, 25*REGBYTES(sp)
|
|
|
|
sw x26, 26*REGBYTES(sp)
|
|
|
|
sw x27, 27*REGBYTES(sp)
|
|
|
|
sw x28, 28*REGBYTES(sp)
|
|
|
|
sw x29, 29*REGBYTES(sp)
|
|
|
|
sw x30, 30*REGBYTES(sp)
|
|
|
|
sw x31, 31*REGBYTES(sp)
|
2023-08-20 15:00:51 +02:00
|
|
|
#endif
|
2018-09-25 18:31:29 +02:00
|
|
|
csrr a0, mcause
|
|
|
|
csrr a1, mepc
|
|
|
|
mv a2, sp
|
2024-05-31 09:21:57 +02:00
|
|
|
call handle_trap
|
2018-09-25 18:31:29 +02:00
|
|
|
csrw mepc, a0
|
2024-09-26 12:18:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
lw x1, 1*REGBYTES(sp)
|
|
|
|
lw x2, 2*REGBYTES(sp)
|
|
|
|
lw x3, 3*REGBYTES(sp)
|
|
|
|
lw x4, 4*REGBYTES(sp)
|
|
|
|
lw x5, 5*REGBYTES(sp)
|
|
|
|
lw x6, 6*REGBYTES(sp)
|
|
|
|
lw x7, 7*REGBYTES(sp)
|
|
|
|
lw x8, 8*REGBYTES(sp)
|
|
|
|
lw x9, 9*REGBYTES(sp)
|
|
|
|
lw x10, 10*REGBYTES(sp)
|
|
|
|
lw x11, 11*REGBYTES(sp)
|
|
|
|
lw x12, 12*REGBYTES(sp)
|
|
|
|
lw x13, 13*REGBYTES(sp)
|
|
|
|
lw x14, 14*REGBYTES(sp)
|
|
|
|
lw x15, 15*REGBYTES(sp)
|
2023-08-20 15:00:51 +02:00
|
|
|
#ifndef __riscv_abi_rve
|
2024-09-26 12:18:50 +02:00
|
|
|
lw x16, 16*REGBYTES(sp)
|
|
|
|
lw x17, 17*REGBYTES(sp)
|
|
|
|
lw x18, 18*REGBYTES(sp)
|
|
|
|
lw x19, 19*REGBYTES(sp)
|
|
|
|
lw x20, 20*REGBYTES(sp)
|
|
|
|
lw x21, 21*REGBYTES(sp)
|
|
|
|
lw x22, 22*REGBYTES(sp)
|
|
|
|
lw x23, 23*REGBYTES(sp)
|
|
|
|
lw x24, 24*REGBYTES(sp)
|
|
|
|
lw x25, 25*REGBYTES(sp)
|
|
|
|
lw x26, 26*REGBYTES(sp)
|
|
|
|
lw x27, 27*REGBYTES(sp)
|
|
|
|
lw x28, 28*REGBYTES(sp)
|
|
|
|
lw x29, 29*REGBYTES(sp)
|
|
|
|
lw x30, 30*REGBYTES(sp)
|
|
|
|
lw x31, 31*REGBYTES(sp)
|
2023-08-20 15:00:51 +02:00
|
|
|
#endif
|
2018-09-25 18:31:29 +02:00
|
|
|
mret
|
|
|
|
|
|
|
|
.weak handle_trap
|
|
|
|
handle_trap:
|
|
|
|
1:
|
|
|
|
j 1b
|
|
|
|
|
|
|
|
#endif
|