-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexception_asm.S
140 lines (110 loc) · 2.08 KB
/
exception_asm.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
mini - a Free Software replacement for the Nintendo/BroadOn IOS.
exception handling
Copyright (C) 2008, 2009 Hector Martin "marcan" <[email protected]>
# This code is licensed to you under the terms of the GNU GPL, version 2;
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
*/
.globl v_undf
.globl v_swi
.globl v_instr_abrt
.globl v_data_abrt
.globl v_reserved
.globl v_fiq
.globl exc_setup_stack
.extern __excstack_addr
.extern exc_handler
exc_setup_stack:
mrs r0, cpsr
@ Switch to FIQ mode
msr cpsr_c, #0xd1
@ Setup exception stack
ldr sp, =__excstack_addr
@ Switch to SVC mode
msr cpsr_c, #0xd3
@ Setup exception stack
ldr sp, =__excstack_addr
@ Switch to ABORT mode
msr cpsr_c, #0xd7
@ Setup exception stack
ldr sp, =__excstack_addr
@ Switch to UNDF mode
msr cpsr_c, #0xdb
@ Setup exception stack
ldr sp, =__excstack_addr
@ Restore mode
msr cpsr_c, r0
bx lr
.pool
v_undf:
stmfd sp!, {lr}
stmfd sp, {r0-lr}^
sub sp, sp, #0x3c
mov r2, sp
mrs r1, spsr
mov r0, #1
blx exc_handler
ldmfd sp!, {r0-r12}
add sp, sp, #8
ldmfd sp!, {lr}
movs pc, lr
v_swi:
stmfd sp!, {lr}
stmfd sp, {r0-lr}^
sub sp, sp, #0x3c
mov r2, sp
mrs r1, spsr
mov r0, #2
blx exc_handler
ldmfd sp!, {r0-r12}
add sp, sp, #8
ldmfd sp!, {lr}
movs pc, lr
v_instr_abrt:
stmfd sp!, {lr}
stmfd sp, {r0-lr}^
sub sp, sp, #0x3c
mov r2, sp
mrs r1, spsr
mov r0, #3
blx exc_handler
ldmfd sp!, {r0-r12}
add sp, sp, #8
ldmfd sp!, {lr}
subs pc, lr, #4
v_data_abrt:
stmfd sp!, {lr}
stmfd sp, {r0-lr}^
sub sp, sp, #0x3c
mov r2, sp
mrs r1, spsr
mov r0, #4
blx exc_handler
ldmfd sp!, {r0-r12}
add sp, sp, #8
ldmfd sp!, {lr}
subs pc, lr, #8
v_reserved:
stmfd sp!, {lr}
stmfd sp, {r0-lr}^
sub sp, sp, #0x3c
mov r2, sp
mrs r1, spsr
mov r0, #5
blx exc_handler
ldmfd sp!, {r0-r12}
add sp, sp, #8
ldmfd sp!, {lr}
movs pc, lr
v_fiq:
stmfd sp!, {lr}
stmfd sp, {r0-lr}^
sub sp, sp, #0x3c
mov r2, sp
mrs r1, spsr
mov r0, #7
blx exc_handler
ldmfd sp!, {r0-r12}
add sp, sp, #8
ldmfd sp!, {lr}
subs pc, lr, #4