intexc.asm
6.71 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
;
; Copyright (c) 2021, Shenzhen Academy of Aerospace Technology
;
; SPDX-License-Identifier: Apache-2.0
;
; Change Logs:
; Date Author Notes
; 2021-11-16 Dystopia the first version
;
;-----------------------------------------------------------
; interrupt and execption handler for C6000 DSP
;-----------------------------------------------------------
;-----------------------------------------------------------
; macro definition
;-----------------------------------------------------------
DP .set B14
SP .set B15
;
;-----------------------------------------------------------
;
.include "contextinc.asm"
;-----------------------------------------------------------
; global function
;-----------------------------------------------------------
.global _nmi_handler
.global _bad_handler
.global _int4_handler
.global _int5_handler
.global _int6_handler
.global _int7_handler
.global _int8_handler
.global _int9_handler
.global _int10_handler
.global _int11_handler
.global _int12_handler
.global _int13_handler
.global _int14_handler
.global _int15_handler
;
;-----------------------------------------------------------
;
;-----------------------------------------------------------
; extern function
;-----------------------------------------------------------
.ref hw_nmi_handler
.ref hw_bad_handler
.ref hw_int4_handler
.ref hw_int5_handler
.ref hw_int6_handler
.ref hw_int7_handler
.ref hw_int8_handler
.ref hw_int9_handler
.ref hw_int10_handler
.ref hw_int11_handler
.ref hw_int12_handler
.ref hw_int13_handler
.ref hw_int14_handler
.ref hw_int15_handler
.ref rt_hw_process_exception
.ref rt_interrupt_context_restore
;
;-----------------------------------------------------------
;
;-----------------------------------------------------------
; interrupt macro definition
;-----------------------------------------------------------
RT_INTERRUPT_ENTRY .macro
SAVE_ALL IRP,ITSR
.endm
RT_CALL_INT .macro __isr
B __isr
ADDKPC $1 ,B3,4
$1:
B .S1 rt_interrupt_context_restore
NOP 5
.endm
;-----------------------------------------------------------
; execption macro definition
;-----------------------------------------------------------
RT_EXECPTION_ENTRY .macro
SAVE_ALL NRP,NTSR
.endm
RT_EXECPTION_EXIT .macro
RESTORE_ALL NRP,NTSR
B .S2 NRP ; return from execption
NOP 5
.endm
;
;-----------------------------------------------------------
;
.sect ".text"
;
;-----------------------------------------------------------
;
;-----------------------------------------------------------
; handler NMI interrupt
;-----------------------------------------------------------
_nmi_handler:
;{
RT_EXECPTION_ENTRY
MVC .S2 EFR,B2
CMPEQ .L2 1,B2,B2
|| MVC .S2 TSR,B1
MV .D1X B2,A2
|| CLR .S2 B1,10,10,B1
MVC .S2 B1,TSR
[!A2] MVKL .S1 rt_hw_process_exception,A0
||[B2] MVKL .S2 rt_hw_software_exception,B1
[!A2] MVKH .S1 rt_hw_process_exception,A0
||[B2] MVKH .S2 rt_hw_software_exception,B1
[!B2] B .S2X A0
[B2] B .S2 B1
[!B2] ADDAW .D2 SP,2,B1
[!B2] MV .D1X B1,A4
ADDKPC .S2 ret_from_trap,B3,2
;
; return from trap
;
ret_from_trap:
MV .D2X A4,B0
[!B0] MVKL .S2 ret_from_exception,B3
[!B0] MVKH .S2 ret_from_exception,B3
[!B0] BNOP .S2 B3,5
;
; return from trap restore exception context
;
ret_from_exception:
RT_EXECPTION_EXIT
;
rt_hw_software_exception:
MVKL .S1 rt_hw_process_exception,A0
MVKH .S1 rt_hw_process_exception,A0
B .S2X A0
ADDAW .D2 SP,2,B1
MV .D1X B1,A4
ADDKPC .S2 ret_from_trap,B3,2
NOP 2
;}
;-----------------------------------------------------------
; handler bad interrupt
;-----------------------------------------------------------
_bad_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_bad_handler
;}
;-----------------------------------------------------------
; handler INT4 interrupt
;-----------------------------------------------------------
_int4_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int4_handler
;}
;-----------------------------------------------------------
; handler INT5 interrupt
;-----------------------------------------------------------
_int5_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int5_handler
;}
;-----------------------------------------------------------
; handler INT6 interrupt
;-----------------------------------------------------------
_int6_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int6_handler
;}
;-----------------------------------------------------------
; handler INT7 interrupt
;-----------------------------------------------------------
_int7_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int7_handler
;}
;-----------------------------------------------------------
; handler INT8 interrupt
;-----------------------------------------------------------
_int8_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int8_handler
;}
;-----------------------------------------------------------
; handler INT9 interrupt
;-----------------------------------------------------------
_int9_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int9_handler
;}
;-----------------------------------------------------------
; handler INT10 interrupt
;-----------------------------------------------------------
_int10_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int10_handler
;}
;-----------------------------------------------------------
; handler INT11 interrupt
;-----------------------------------------------------------
_int11_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int11_handler
;}
;-----------------------------------------------------------
; handler INT12 interrupt
;-----------------------------------------------------------
_int12_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int12_handler
;}
;-----------------------------------------------------------
; handler INT13 interrupt
;-----------------------------------------------------------
_int13_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int13_handler
;}
;-----------------------------------------------------------
; handler INT14 interrupt
;-----------------------------------------------------------
_int14_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int14_handler
;}
;-----------------------------------------------------------
; handler INT15 interrupt
;-----------------------------------------------------------
_int15_handler:
;{
RT_INTERRUPT_ENTRY
RT_CALL_INT hw_int15_handler
;}
.end