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 MVec
11.type  MVec, @function
12.align 4
13MVec:
14	PushTrapFrame
15	sd fp, 2*8(sp)
16	csrr t0, mepc
17	sd   t0, 31*8(sp)
18
19	mv a0, sp
20	call MTrap
21
22	ld t0, 31*8(sp)
23	csrw mepc, t0
24	PopTrapFrame
25	mret
26.size	MVec, .-MVec
27
28
29.globl MVecS
30.type  MVecS, @function
31.align 4
32MVecS:
33	csrrw sp, mscratch, sp
34
35	PushTrapFrame
36
37	csrr t0, mscratch
38	sd t0, 2*8(sp) # save supervisor SP
39	csrw mscratch, fp
40
41	csrr t0, mepc
42	sd   t0, 31*8(sp)
43
44	la   t0,    MVec
45	csrw mtvec, t0
46
47	mv a0, sp
48	call MTrap
49
50	la   t0,    MVecS
51	csrw mtvec, t0
52
53	ld t0, 31*8(sp)
54	csrw mepc, t0
55	PopTrapFrame
56	mret
57.size	MVecS, .-MVecS
58