-
Notifications
You must be signed in to change notification settings - Fork 0
/
MIPSException.h
executable file
·271 lines (236 loc) · 5.88 KB
/
MIPSException.h
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
264
265
266
267
268
269
270
271
//
// MIPSException.h
// MIPS_Emulator
//
// Created by Matt on 2/26/16.
// Copyright © 2016 Matt. All rights reserved.
//
#ifndef MIPSException_h
#define MIPSException_h
class CPU; // Forward Reference
// Base Exception Class
class MIPSException {
protected:
// Exception Type
enum class ExceptionType {
TLBRefill,
Interrupt,
General,
None
};
// Exception Code (Table 9.40 pg 189 vol3)
enum ExceptionCode {
Int = 0x00,
Mod = 0x01,
TLBL = 0x02,
TLBS = 0x03,
AdEL = 0x04,
AdES = 0x05,
IBE = 0x06,
DBE = 0x07,
Sys = 0x08,
Bp = 0x09,
RI = 0x0a,
CpU = 0x0b,
Ov = 0x0c,
Tr = 0x0d,
MSAFPE = 0x0e,
FPE = 0x0f,
C2E = 0x12,
TLBRI = 0x13,
TLBXI = 0x14,
MSADis = 0x15,
MDMX = 0x16,
WATCH = 0x17,
MCheck = 0x18,
Thread = 0x19,
DSPDis = 0x1a,
GE = 0x1b,
CacheErr = 0x1e,
};
void generalException(CPU*, ExceptionType, ExceptionCode);
void setBadVaddr(CPU*);
void setContextBadVPN2(CPU*);
void setEntryHiVA(CPU*);
void setErrorEPC(CPU*);
void setExlOn(CPU* cpu);
public:
virtual void execute(CPU*) = 0;
};
// Cold Reset NMI Exception
class ColdResetException : public MIPSException {
public:
ColdResetException();
void execute(CPU*);
};
// Soft Reset NMI Exception
class SoftResetException : public MIPSException {
public:
SoftResetException();
void execute(CPU*);
};
// Nonmaskable Interrupt Exception
class NonmaskableInterruptException : public MIPSException {
public:
NonmaskableInterruptException();
void execute(CPU*);
};
// Machine Check Exception
class MachineCheckException : public MIPSException {
public:
MachineCheckException();
void execute(CPU*);
};
// Watch - Instruction Fetch Exception
class WatchIFException : public MIPSException {
public:
WatchIFException();
void execute(CPU*);
};
// Address Error - Instruction Fetch Exception
class AddressErrorIFException : public MIPSException {
public:
AddressErrorIFException();
void execute(CPU*);
};
// TLB Refill - Instruction Fetch Exception
class TLBRefillIFException : public MIPSException {
public:
TLBRefillIFException();
void execute(CPU*);
};
// TLB Invalid - Instruction Fetch Exception
class TLBInvalidIFException : public MIPSException {
public:
TLBInvalidIFException();
void execute(CPU*);
};
// TLB Execute-Inhibit Exception
class TLBExecuteInhibitException : public MIPSException {
public:
TLBExecuteInhibitException();
void execute(CPU*);
};
// Cache Error - Instruction Fetch Exception
class CacheErrorIFException : public MIPSException {
public:
CacheErrorIFException();
void execute(CPU*);
};
// Bus Error - Instruction Fetch Exception
class BusErrorIFException : public MIPSException {
public:
BusErrorIFException();
void execute(CPU*);
};
// Coprocessor Unusable Exception
class CoprocessorUnusableException : public MIPSException {
public:
enum FaultingCoprocessor {
CO0 = 0,
CO1 = 1,
CO2 = 2
};
FaultingCoprocessor unitnumber;
CoprocessorUnusableException(FaultingCoprocessor);
void execute(CPU*);
};
// Reserved Instruction Exception
class ReservedInstructionException : public MIPSException {
public:
ReservedInstructionException();
void execute(CPU*);
};
// Integer Overflow Exception
class IntegerOverflowException : public MIPSException {
public:
IntegerOverflowException();
void execute(CPU*);
};
// Trap Exception
class TrapException : public MIPSException {
public:
TrapException();
void execute(CPU*);
};
// System Call Exception
class SystemCallException : public MIPSException {
public:
SystemCallException();
void execute(CPU*);
};
// Breakpoint Call Exception
class BreakpointException : public MIPSException {
public:
BreakpointException();
void execute(CPU*);
};
// Floating-point Exception
class FloatingPointException : public MIPSException {
public:
FloatingPointException();
void execute(CPU*);
};
// Coprocessor 2 Exception
class Coprocessor2Exception : public MIPSException {
public:
Coprocessor2Exception();
void execute(CPU*);
};
// Watch - Data Exception
class WatchDataException : public MIPSException {
public:
WatchDataException();
void execute(CPU*);
};
// Address Error - Data Exception
class AddressErrorDataException : public MIPSException {
public:
AddressErrorDataException();
void execute(CPU*);
};
// TLB Refill - Data Exception
class TLBRefillDataException : public MIPSException {
public:
TLBRefillDataException(bool storeRef);
const bool store;
void execute(CPU*);
};
// TLB Invalid - Data Exception
class TLBInvalidDataException : public MIPSException {
public:
TLBInvalidDataException(bool storeRef);
const bool store;
void execute(CPU*);
};
// TLB Read-Inhibit
class TLBReadInhibitException : public MIPSException {
public:
TLBReadInhibitException();
void execute(CPU*);
};
// TLB Modified - Data Exception
class TLBModifiedException : public MIPSException {
public:
TLBModifiedException();
void execute(CPU*);
};
// Cache Error - Data Exception
class CacheErrorDataException : public MIPSException {
public:
CacheErrorDataException();
void execute(CPU*);
};
// Bus Error - Data Exception
class BusErrorDataException : public MIPSException {
public:
BusErrorDataException();
void execute(CPU*);
};
// Interrupt Exception
class InterruptException : public MIPSException {
public:
InterruptException();
void execute(CPU*);
};
#endif /* MIPSException_h */