M68kException.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19: package xeij;
20:
21: import java.lang.*;
22:
23: public class M68kException extends Exception {
24:
25: public static final boolean M6E_DEBUG_ERROR = false;
26:
27:
28:
29:
30: public static final int M6E_RESET_INITIAL_SSP = 0;
31: public static final int M6E_RESET_INITIAL_PC = 1;
32: public static final int M6E_ACCESS_FAULT = 2;
33: public static final int M6E_ADDRESS_ERROR = 3;
34: public static final int M6E_ILLEGAL_INSTRUCTION = 4;
35: public static final int M6E_DIVIDE_BY_ZERO = 5;
36: public static final int M6E_CHK_INSTRUCTION = 6;
37: public static final int M6E_TRAPV_INSTRUCTION = 7;
38: public static final int M6E_PRIVILEGE_VIOLATION = 8;
39: public static final int M6E_TRACE = 9;
40: public static final int M6E_LINE_1010_EMULATOR = 10;
41: public static final int M6E_LINE_1111_EMULATOR = 11;
42: public static final int M6E_FP_UNIMPLEMENTED_INSTRUCTION = 11;
43: public static final int M6E_FP_DISABLED = 11;
44: public static final int M6E_EMULATOR_INTERRUPT = 12;
45: public static final int M6E_COPROCESSOR_PROTOCOL_VIOLATION = 13;
46: public static final int M6E_FORMAT_ERROR = 14;
47: public static final int M6E_UNINITIALIZED_INTERRUPT = 15;
48: public static final int M6E_SPURIOUS_INTERRUPT = 24;
49: public static final int M6E_LEVEL_1_INTERRUPT_AUTOVECTOR = 25;
50: public static final int M6E_LEVEL_2_INTERRUPT_AUTOVECTOR = 26;
51: public static final int M6E_LEVEL_3_INTERRUPT_AUTOVECTOR = 27;
52: public static final int M6E_LEVEL_4_INTERRUPT_AUTOVECTOR = 28;
53: public static final int M6E_LEVEL_5_INTERRUPT_AUTOVECTOR = 29;
54: public static final int M6E_LEVEL_6_INTERRUPT_AUTOVECTOR = 30;
55: public static final int M6E_LEVEL_7_INTERRUPT_AUTOVECTOR = 31;
56: public static final int M6E_TRAP_0_INSTRUCTION_VECTOR = 32;
57: public static final int M6E_TRAP_1_INSTRUCTION_VECTOR = 33;
58: public static final int M6E_TRAP_2_INSTRUCTION_VECTOR = 34;
59: public static final int M6E_TRAP_3_INSTRUCTION_VECTOR = 35;
60: public static final int M6E_TRAP_4_INSTRUCTION_VECTOR = 36;
61: public static final int M6E_TRAP_5_INSTRUCTION_VECTOR = 37;
62: public static final int M6E_TRAP_6_INSTRUCTION_VECTOR = 38;
63: public static final int M6E_TRAP_7_INSTRUCTION_VECTOR = 39;
64: public static final int M6E_TRAP_8_INSTRUCTION_VECTOR = 40;
65: public static final int M6E_TRAP_9_INSTRUCTION_VECTOR = 41;
66: public static final int M6E_TRAP_10_INSTRUCTION_VECTOR = 42;
67: public static final int M6E_TRAP_11_INSTRUCTION_VECTOR = 43;
68: public static final int M6E_TRAP_12_INSTRUCTION_VECTOR = 44;
69: public static final int M6E_TRAP_13_INSTRUCTION_VECTOR = 45;
70: public static final int M6E_TRAP_14_INSTRUCTION_VECTOR = 46;
71: public static final int M6E_TRAP_15_INSTRUCTION_VECTOR = 47;
72: public static final int M6E_FP_BRANCH_SET_UNORDERED = 48;
73: public static final int M6E_FP_INEXACT_RESULT = 49;
74:
75: public static final int M6E_FP_DIVIDE_BY_ZERO = 50;
76: public static final int M6E_FP_UNDERFLOW = 51;
77:
78: public static final int M6E_FP_OPERAND_ERROR = 52;
79:
80: public static final int M6E_FP_OVERFLOW = 53;
81:
82: public static final int M6E_FP_SIGNALING_NAN = 54;
83:
84: public static final int M6E_FP_UNSUPPORTED_DATA_TYPE = 55;
85:
86:
87: public static final int M6E_MMU_CONFIGULATION_ERROR = 56;
88: public static final int M6E_MMU_ILLEGAL_OPERATION_ERROR = 57;
89: public static final int M6E_MMU_ACCESS_LEVEL_VIOLATION = 58;
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100: public static final int M6E_UNIMPLEMENTED_EFFECTIVE = 60;
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121: public static final int M6E_UNIMPLEMENTED_INSTRUCTION = 61;
122:
123: public static final String[] M6E_ERROR_NAME = {
124: "undefined exception #0",
125: "undefined exception #1",
126: "Access fault",
127: "Address error",
128: "Illegal instruction",
129: "Divide by zero",
130: "CHK instruction",
131: "Trapv instruction",
132: "Privilege violation",
133: "Trace",
134: "Line 1010 emulator",
135: "Line 1111 emulator",
136: "Emulator interrupt",
137: "Coprocessor protocol violation",
138: "Format error",
139: "Uninitialized interrupt",
140: "undefined exception #16",
141: "undefined exception #17",
142: "undefined exception #18",
143: "undefined exception #19",
144: "undefined exception #20",
145: "undefined exception #21",
146: "undefined exception #22",
147: "undefined exception #23",
148: "Spurious interrupt",
149: "Level 1 interrupt autovector",
150: "Level 2 interrupt autovector",
151: "Level 3 interrupt autovector",
152: "Level 4 interrupt autovector",
153: "Level 5 interrupt autovector",
154: "Level 6 interrupt autovector",
155: "Level 7 interrupt autovector",
156: "TRAP #0 instruction vector",
157: "TRAP #1 instruction vector",
158: "TRAP #2 instruction vector",
159: "TRAP #3 instruction vector",
160: "TRAP #4 instruction vector",
161: "TRAP #5 instruction vector",
162: "TRAP #6 instruction vector",
163: "TRAP #7 instruction vector",
164: "TRAP #8 instruction vector",
165: "TRAP #9 instruction vector",
166: "TRAP #10 instruction vector",
167: "TRAP #11 instruction vector",
168: "TRAP #12 instruction vector",
169: "TRAP #13 instruction vector",
170: "TRAP #14 instruction vector",
171: "TRAP #15 instruction vector",
172: "FP branch/set on unordered ",
173: "FP inexact result",
174: "FP divide by zero",
175: "FP underflow",
176: "FP operand error",
177: "FP overflow",
178: "FP signaling NAN",
179: "FP unsupported data type",
180: "MMU configulation error",
181: "MMU illegal operation error",
182: "MMU access level violation",
183: "undefined exception #59",
184: "Unimplemented effective address",
185: "Unimplemented instruction",
186: "undefined exception #62",
187: "undefined exception #63",
188: };
189:
190: public static M68kException m6eSignal;
191: public static int m6eNumber;
192: public static int m6eAddress;
193: public static int m6eDirection;
194: public static int m6eSize;
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212: public static final int M6E_FSLW_MISALIGNED = 1 << 27;
213: public static final int M6E_FSLW_LOCKED = 1 << 25;
214: public static final int M6E_FSLW_READ_AND_WRITE = 3 << 23;
215: public static final int M6E_FSLW_RW_WRITE = 1 << 23;
216: public static final int M6E_FSLW_RW_READ = 2 << 23;
217: public static final int M6E_FSLW_RW_MODIFY = 3 << 23;
218: public static final int M6E_FSLW_TRANSFER_SIZE = 3 << 21;
219: public static final int M6E_FSLW_SIZE_LONG = 0 << 21;
220: public static final int M6E_FSLW_SIZE_BYTE = 1 << 21;
221: public static final int M6E_FSLW_SIZE_WORD = 2 << 21;
222: public static final int M6E_FSLW_SIZE_QUAD = 3 << 21;
223: public static final int M6E_FSLW_TRANSFER_TYPE = 3 << 19;
224: public static final int M6E_FSLW_TT_NORMAL = 0 << 19;
225: public static final int M6E_FSLW_TT_MOVE16 = 1 << 19;
226: public static final int M6E_FSLW_TT_ALTERNATE = 2 << 19;
227: public static final int M6E_FSLW_TT_ACKNOWLEDGE = 3 << 19;
228: public static final int M6E_FSLW_TRANSFER_MODIFIER = 7 << 16;
229: public static final int M6E_FSLW_TM_CACHE_PUSH = 0 << 16;
230: public static final int M6E_FSLW_TM_USER_DATA = 1 << 16;
231: public static final int M6E_FSLW_TM_USER_CODE = 2 << 16;
232: public static final int M6E_FSLW_TM_MMU_DATA = 3 << 16;
233: public static final int M6E_FSLW_TM_MMU_CODE = 4 << 16;
234: public static final int M6E_FSLW_TM_SUPER_DATA = 5 << 16;
235: public static final int M6E_FSLW_TM_SUPER_CODE = 6 << 16;
236: public static final int M6E_FSLW_TM_DATA = 1 << 16;
237: public static final int M6E_FSLW_TM_CODE = 2 << 16;
238: public static final int M6E_FSLW_TM_SUPERVISOR = 4 << 16;
239: public static final int M6E_FSLW_INSTRUCTION = 1 << 15;
240: public static final int M6E_FSLW_IOMA_FIRST = 0 << 15 | 0 << 27;
241: public static final int M6E_FSLW_IOMA_SECOND = 0 << 15 | 1 << 27;
242: public static final int M6E_FSLW_IOMA_OPWORD = 1 << 15 | 0 << 27;
243: public static final int M6E_FSLW_IOMA_EXWORD = 1 << 15 | 1 << 27;
244: public static final int M6E_FSLW_PUSH_BUFFER = 1 << 14;
245: public static final int M6E_FSLW_STORE_BUFFER = 1 << 13;
246: public static final int M6E_FSLW_ROOT_DESCRIPTOR = 1 << 12;
247: public static final int M6E_FSLW_POINTER_DESCRIPTOR = 1 << 11;
248: public static final int M6E_FSLW_INDIRECT_LEVEL = 1 << 10;
249: public static final int M6E_FSLW_PAGE_FAULT = 1 << 9;
250: public static final int M6E_FSLW_SUPERVISOR_PROTECT = 1 << 8;
251: public static final int M6E_FSLW_WRITE_PROTECT = 1 << 7;
252: public static final int M6E_FSLW_TABLE_SEARCH = 1 << 6;
253: public static final int M6E_FSLW_BUS_ERROR_ON_READ = 1 << 5;
254: public static final int M6E_FSLW_BUS_ERROR_ON_WRITE = 1 << 4;
255: public static final int M6E_FSLW_TRANSPARENT = 1 << 3;
256: public static final int M6E_FSLW_BRANCH_PREDICTION = 1 << 2;
257: public static final int M6E_FSLW_SOFTWARE_EMULATION = 1 << 0;
258:
259: public static int m6eFSLW;
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270: public static long m6eIncremented;
271:
272: public static final String[] M6E_FSLW_TEXT_IOMA = {
273: "IO=0,MA=0 First access of a misaligned transfer or only access of an aligned transfer",
274: "IO=0,MA=1 Second or later access of a misaligned transfer",
275: "IO=1,MA=0 Instruction opword fetch",
276: "IO=1,MA=1 Fetch of an extension word",
277: };
278: public static final String[] M6E_FSLW_TEXT_LK = {
279: "LK=0 Not locked",
280: "LK=1 Locked",
281: };
282: public static final String[] M6E_FSLW_TEXT_RW = {
283: "RW=0 Undefined, reserved",
284: "RW=1 Write",
285: "RW=2 Read",
286: "RW=3 Read-Modify-Write",
287: };
288: public static final String[] M6E_FSLW_TEXT_SIZE = {
289: "SIZE=0 Byte",
290: "SIZE=1 Word",
291: "SIZE=2 Long",
292: "SIZE=3 Double precision or MOVE16",
293: };
294: public static final String[] M6E_FSLW_TEXT_TT = {
295: "TT=0 Normal access",
296: "TT=1 MOVE16 access",
297: "TT=2 Alternate or debug access",
298: "TT=3 Acknowledge or LPSTOP broadcast",
299: };
300: public static final String[] M6E_FSLW_TEXT_TM = {
301: "TM=0 Data cache push access",
302: "TM=1 User data or MOVE16 access",
303: "TM=2 User code access",
304: "TM=3 MMU table search data access",
305: "TM=4 MMU table search code access",
306: "TM=5 Supervisor data access",
307: "TM=6 Supervisor code access",
308: "TM=7 Reserved",
309:
310:
311:
312:
313:
314:
315:
316:
317: };
318: public static final String[] M6E_FSLW_TEXT_CAUSE = {
319: "SEE=1 Software emulation error",
320: "",
321: "BPE=1 Branch prediction error",
322: "TTR=1 TTR hit",
323: "WE=1 Bus error on write",
324: "RE=1 Bus error on read",
325: "TWE=1 Bus error on table search",
326: "WP=1 Write protect",
327: "SP=1 Supervisor protect",
328: "PF=1 Page fault",
329: "IL=1 Indirect level fault",
330: "PTB=1 Pointer B fault",
331: "PTA=1 Pointer A fault",
332: "SBE=1 Store buffer bus error",
333: "PBE=1 Push buffer bus error",
334: };
335:
336: public static String m6eToString6 () {
337: StringBuilder sb = new StringBuilder ();
338: int supervisor = m6eFSLW & M6E_FSLW_TM_SUPERVISOR;
339: int instruction = m6eFSLW & M6E_FSLW_TM_CODE;
340: if (0 <= m6eNumber && m6eNumber < M6E_ERROR_NAME.length) {
341: sb.append (M6E_ERROR_NAME[m6eNumber]);
342: } else {
343: sb.append ("undefined exception #").append (m6eNumber);
344: }
345: XEiJ.fmtHex8 (sb.append (" at PC=$"), XEiJ.regPC0).append ("($");
346: int pa = MC68060.mmuTranslatePeek (XEiJ.regPC0, supervisor, 1);
347: if ((XEiJ.regPC0 ^ pa) == 1) {
348: sb.append ("????????");
349: } else {
350: XEiJ.fmtHex8 (sb, pa);
351: }
352: XEiJ.fmtHex4 (sb.append ("), SR=$"), XEiJ.regSRT1 | XEiJ.regSRS | XEiJ.regSRI | XEiJ.regCCR);
353:
354:
355: if (0b0011011101000000000000000000000000000000000000000000000000000000L << m6eNumber < 0L) {
356: if ((m6eFSLW & (M6E_FSLW_BUS_ERROR_ON_READ | M6E_FSLW_BUS_ERROR_ON_WRITE)) != 0) {
357: XEiJ.fmtHex8 (sb.append ("\n Fault or effective address is EA=($"), m6eAddress).append (')');
358: } else {
359: XEiJ.fmtHex8 (sb.append ("\n Fault or effective address is EA=$"), m6eAddress).append ("($");
360: pa = MC68060.mmuTranslatePeek (m6eAddress, supervisor, instruction);
361: if ((m6eAddress ^ pa) == 1) {
362: sb.append ("????????");
363: } else {
364: XEiJ.fmtHex8 (sb, pa);
365: }
366: sb.append (')');
367: }
368: }
369: if (m6eNumber == M6E_ACCESS_FAULT) {
370: XEiJ.fmtHex8 (sb.append ("\n Fault status long word is FSLW=$"), m6eFSLW);
371: sb.append ("\n Fault was caused by:");
372: for (int i = 14; i >= 0; i--) {
373: if ((m6eFSLW & (1 << i)) != 0) {
374: sb.append ("\n ").append (M6E_FSLW_TEXT_CAUSE[i]);
375: }
376: }
377: sb.append ("\n Fault occured on:\n ")
378: .append (M6E_FSLW_TEXT_IOMA[(m6eFSLW & M6E_FSLW_INSTRUCTION) >>> 15 - 1 | (m6eFSLW & M6E_FSLW_MISALIGNED) >>> 27])
379: .append ("\n ").append (M6E_FSLW_TEXT_LK[(m6eFSLW & M6E_FSLW_LOCKED) >>> 25])
380: .append ("\n ").append (M6E_FSLW_TEXT_RW[(m6eFSLW & M6E_FSLW_READ_AND_WRITE) >>> 23])
381: .append ("\n ").append (M6E_FSLW_TEXT_SIZE[(m6eFSLW & M6E_FSLW_TRANSFER_SIZE) >>> 21])
382: .append ("\n ").append (M6E_FSLW_TEXT_TT[(m6eFSLW & M6E_FSLW_TRANSFER_TYPE) >>> 19])
383: .append ("\n ").append (M6E_FSLW_TEXT_TM[(m6eFSLW & M6E_FSLW_TRANSFER_MODIFIER) >>> 16]);
384: }
385: return sb.toString ();
386: }
387:
388: }
389:
390:
391: