exceptasm.s
2.18 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
#include "regdef.h"
#include "asm.h"
#include "exceptasm.h"
#include <R4300.h>
#define BRK_KERNELBP 1
.set noat
LEAF(exception)
/*
* Read the cause register; we're only interested in interrupts.
* (We are also interested in some exceptions, like CpU...)
*/
.set noreorder
mfc0 k0,C0_CAUSE
.set reorder
andi k0,CAUSE_EXCMASK
#ifdef _SYMMON
li k1,EXC_BREAK
beq k0,k1,handle_break
#endif
bne k0,k1,_Panic
/*
* Not an interrupt, or an interrupt without a interrupt thread:
* print all of the registers and spin.
*/
EXPORT(_Panic)
la k0,_ExceptionFrame
sw AT,EF_AT(k0);
sw v0,EF_V0(k0);
sw v0,EF_V1(k0);
sw a0,EF_A0(k0);
sw a1,EF_A1(k0);
sw a2,EF_A2(k0);
sw a3,EF_A3(k0);
sw t0,EF_T0(k0);
sw t1,EF_T1(k0);
sw t2,EF_T2(k0);
sw t3,EF_T3(k0);
sw t4,EF_T4(k0);
sw t5,EF_T5(k0);
sw t6,EF_T6(k0);
sw t7,EF_T7(k0);
sw s0,EF_S0(k0);
sw s1,EF_S1(k0);
sw s2,EF_S2(k0);
sw s3,EF_S3(k0);
sw s4,EF_S4(k0);
sw s5,EF_S5(k0);
sw s6,EF_S6(k0);
sw s7,EF_S7(k0);
sw t8,EF_T8(k0);
sw t9,EF_T9(k0);
sw gp,EF_GP(k0);
sw sp,EF_SP(k0);
sw s8,EF_S8(k0);
sw ra,EF_RA(k0);
.set noreorder
mfc0 k1,C0_PAGEMASK
nop
sw k1,EF_PAGEMASK(k0)
mfc0 k1,C0_WIRED
nop
sw k1,EF_WIRED(k0)
mfc0 k1,C0_ENTRYLO0
nop
sw k1,EF_ENTRYLO0(k0)
mfc0 k1,C0_ENTRYLO1
nop
sw k1,EF_ENTRYLO1(k0)
mfc0 k1,C0_CONTEXT
nop
sw k1,EF_CONTEXT(k0)
mfc0 k1,C0_BADVADDR
nop
sw k1,EF_BADVADDR(k0)
mfc0 k1,C0_ENTRYHI
nop
sw k1,EF_ENTRYHI(k0)
mfc0 k1,C0_COMPARE
nop
sw k1,EF_COMPARE(k0)
mfc0 k1,C0_SR
nop
sw k1,EF_SR(k0)
mfc0 k1,C0_CAUSE
nop
sw k1,EF_CAUSE(k0)
mfc0 k1,C0_EPC
nop
sw k1,EF_EPC(k0)
mfc0 k1,C0_CONFIG
nop
sw k1,EF_CONFIG(k0)
.set reorder
jal _ExceptionPrint
1: b 1b
BSS(_atsave, 4)
BSS(_rasave, 4)
EXPORT(handle_break)
.set noreorder
.set noat
move k0,AT
sw k0,_atsave
# jump to breakpoint handler
lw AT,SPB_DEBUGADDR # address of debug block
nop
beq AT,zero,2f
nop
lw AT,DB_BPOFF(AT) # breakpoint handle
nop
beq AT,zero,2f
nop
lw k0,_atsave
j AT
nop
2: j ra
nop
END(exception)
.set at
LEAF(debug)
sw ra,_rasave
break BRK_KERNELBP
lw ra,_rasave
j ra
END(debug)
.set noreorder
LEAF(_ExceptionPreamble)
la k0,exception
jr k0
nop
END(_ExceptionPreamble)