1/* 2 * Copyright 2021, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include "arch_traps.h" 8 9 10.globl SVec 11.type SVec, @function 12.align 4 13SVec: 14 PushTrapFrame 15 sd fp, 2*8(sp) 16 csrr t0, sepc 17 sd t0, 31*8(sp) 18 19 mv a0, sp 20 call STrap 21 22 ld t0, 31*8(sp) 23 csrw sepc, t0 24 PopTrapFrame 25 sret 26.size SVec, .-SVec 27 28 29.globl SVecU 30.type SVecU, @function 31.align 4 32SVecU: 33 csrrw t0, sscratch, t0 # t0: &arch_thread 34 ld tp, 0*8(t0) # tp = arch_thread.thread 35 ld t0, (1 + 13)*8(t0) # t0 = arch_thread.context.sp 36 sd sp, 2*8 - 256(t0) # save user SP 37 mv sp, t0 # switch to kernel stack 38 csrr t0, sscratch 39 40 PushTrapFrame 41 42 csrr t0, sepc 43 sd t0, 31*8(sp) 44 45 la t0, SVec 46 csrw stvec, t0 47 48 mv a0, sp 49 call STrap 50 51.globl SVecURet 52.type SVecURet, @function 53SVecURet: 54 call RestoreUserRegs 55 56 csrr t0, sscratch 57 sd fp, (1 + 13)*8(t0) # arch_thread.context.sp = fp 58 59 la t0, SVecU 60 csrw stvec, t0 61 62 ld t0, 31*8(sp) 63 csrw sepc, t0 64 PopTrapFrame 65 sret 66.size SVecU, .-SVecU 67