-
Notifications
You must be signed in to change notification settings - Fork 4
/
PPCExceptionTable.s
483 lines (351 loc) · 6.63 KB
/
PPCExceptionTable.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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
HASH1 equ 978
HASH2 equ 979
ICMP equ 981
DCMP equ 977
IMISS equ 980
DMISS equ 976
RPA equ 982
macro
Vanilla &idx
@start
b @jump1
b @jump2
@jump1
; r1 -> SPRG1
; LR -> SPRG2
; targ -> r1
; optr -> LR
mtsprg 1, r1
mflr r1
mtsprg 2, r1
mfsprg r1, 3
lwz r1, &idx(r1)
mtlr r1
blrl
dc.l @start - TableStart
mflr r1
@jump2
mtsprg 1, r1
mfsprg r1, 3
mtsprg 2, r1
mtlr r1
lwz r1, &idx(r1)
dc.l @start - TableStart
blrl
endm
TableStart
; 0000-00ff: For software use only
org 0x0000
mtsprg 1, r1
mfsprg r1, 3
lwz r1, 0x00BC(r1)
mtlr r1
blrl
org 0x0080
dc.l 0x0000D000 ; '....' (invalid instruction)
; 0100-0fff: Architecture-defined exceptions
org 0x0100
b $+0x0008 ; 0x00000108
b $+0x0050 ; 0x00000154
mtsprg 1, r1
mfcr r1
mtsprg 2, r1
mfsrr1 r1
mtcrf 255, r1
bne cr7, RTASFairyDust
mfspr r1, HID0
mtcrf 255, r1
bns cr3, RTASFairyDust
mfsprg r1, 2
mtcrf 255, r1
mflr r1
mtsprg 2, r1
mfsprg r1, 3
lwz r1, 0x0004(r1)
mtlr r1
blrl
dc.l 0x00000100 ; '....' (invalid instruction)
org 0x180
PerfMon
mtsprg 2, r1
mfsprg r1, 3
stw r2, 0x0000(r1)
mfsprg r2, 2
rlwinm r2, r2, 26, 24, 29
lwzx r1, r2, r1
mflr r2
mtlr r1
mfsprg r1, 2
mtsprg 2, r2
mfsprg r2, 3
lwz r2, 0x0000(r2)
blr
org 0x0200 ; Machine Check
Vanilla 0x0008
org 0x0300 ; Data Storage
Vanilla 0x000C
org 0x0400 ; Instruction Storage
Vanilla 0x0010
org 0x0500 ; External
Vanilla 0x0014
org 0x0600 ; Alignment
Vanilla 0x0018
org 0x0700 ; Program
Vanilla 0x001C
org 0x0800 ; FP Unavailable
Vanilla 0x0020
org 0x0900 ; Decrementer
Vanilla 0x0024
org 0x0A00
Vanilla 0x0028
org 0x0B00
Vanilla 0x002C
org 0x0C00 ; System Call
Vanilla 0x0030
org 0x0D00 ; Trace
Vanilla 0x0034
org 0x0E00
Vanilla 0x0038
; Performance monitor???
org 0x0F00
mtsprg 1, r1
li r1, 0xF00
b PerfMon
org 0x0F20
mtsprg 1, r1
li r1, 0xF20
b PerfMon
; 1000-2fff: Implementation-specific exceptions
org 0x1000
mfspr r2, HASH1
lwz r1, 0x0000(r2)
mfctr r0
mfspr r3, ICMP
cmpw r1, r3
beq $+0x001C ; 0x00001030
li r1, 7
mtctr r1
lwzu r1, 0x0008(r2)
cmpw r1, r3
bdnzf cr0_EQ, $-0x0008 ; 0x00001020
bne $+0x0038 ; 0x00001064
lwz r1, 0x0004(r2)
mtctr r0
andi. r3, r1, 0x0008
bne $+0x006C ; 0x000010A8
mfspr r0, IMISS
mfsrr1 r3
mtcrf 128, r3
mtspr RPA, r1
ori r1, r1, 0x0100
srwi r1, r1, 8
dc.l 0x7C0007E4 ; '|...' (invalid instruction)
stb r1, 0x0006(r2)
rfi
andi. r1, r3, 0x0040
bne $+0x0014 ; 0x0000107C
mfspr r2, HASH2
lwz r1, 0x0000(r2)
ori r3, r3, 0x0040
b $-0x0068 ; 0x00001010
mfsrr1 r3
clrlwi r2, r3, 16
oris r2, r2, 0x4000
mtctr r0
mtsrr1 r2
mfmsr r0
xoris r0, r0, 0x0002
mtcrf 128, r3
mtmsr r0
isync
b $-0x0CA4 ; 0x00000400
mfsrr1 r3
clrlwi r2, r3, 16
oris r2, r2, 0x1000
b $-0x0028 ; 0x0000108C
org 0x1100
mfspr r2, HASH1
lwz r1, 0x0000(r2)
mfctr r0
mfspr r3, DCMP
cmpw r1, r3
beq $+0x001C ; 0x00001130
li r1, 7
mtctr r1
lwzu r1, 0x0008(r2)
cmpw r1, r3
bdnzf cr0_EQ, $-0x0008 ; 0x00001120
bne $+0x0034 ; 0x00001160
lwz r1, 0x0004(r2)
mtctr r0
mfspr r0, DMISS
mfsrr1 r3
mtcrf 128, r3
mtspr RPA, r1
ori r1, r1, 0x0100
srwi r1, r1, 8
dc.l 0x7C0007A4 ; '|...' (invalid instruction)
stb r1, 0x0006(r2)
rfi
nop
andi. r1, r3, 0x0040
bne $+0x013C ; 0x000012A0
mfspr r2, HASH2
lwz r1, 0x0000(r2)
ori r3, r3, 0x0040
b $-0x0064 ; 0x00001110
org 0x1200
mfspr r2, HASH1
lwz r1, 0x0000(r2)
mfctr r0
mfspr r3, DCMP
cmpw r1, r3
beq $+0x001C ; 0x00001230
li r1, 7
mtctr r1
lwzu r1, 0x0008(r2)
cmpw r1, r3
bdnzf cr0_EQ, $-0x0008 ; 0x00001220
bne $+0x003C ; 0x00001268
lwz r1, 0x0004(r2)
mtctr r0
slwi. r3, r1, 30
bge $+0x0044 ; 0x00001280
andi. r3, r1, 0x0001
bne $+0x0054 ; 0x00001298
mfspr r0, DMISS
mfsrr1 r3
mtcrf 128, r3
ori r1, r1, 0x0180
mtspr RPA, r1
dc.l 0x7C0007A4 ; '|...' (invalid instruction)
sth r1, 0x0006(r2)
rfi
andi. r1, r3, 0x0040
bne $+0x0034 ; 0x000012A0
mfspr r2, HASH2
lwz r1, 0x0000(r2)
ori r3, r3, 0x0040
b $-0x006C ; 0x00001210
mfsrr1 r0
extrwi r0, r0, 1, 17
mfspr r3, DMISS
mfsrin r3, r3
rlwnm. r3, r3, r0, 1, 1
beq $-0x004C ; 0x00001248
lis r1, 2048
b $+0x000C ; 0x000012A8
lis r1, 16384
mtctr r0
mfsrr1 r3
rlwimi r1, r3, 9, 6, 6
clrlwi r2, r3, 16
mtsrr1 r2
mtdsisr r1
mfspr r1, DMISS
andi. r2, r2, 0x0001
beq+ $+0x0008 ; 0x000012CC
xori r1, r1, 0x0007
mtdar r1
mfmsr r0
xoris r0, r0, 0x0002
mtcrf 128, r3
mtmsr r0
isync
b $-0x0FE4 ; 0x00000300
org 0x1300
Vanilla 0x004C
org 0x1400
Vanilla 0x0050
org 0x1500
Vanilla 0x0054
org 0x1600
Vanilla 0x0058
org 0x1700
Vanilla 0x005C
org 0x1800
Vanilla 0x0060
org 0x1900
Vanilla 0x0064
org 0x1A00
Vanilla 0x0068
org 0x1B00
Vanilla 0x006C
org 0x1C00
Vanilla 0x0070
org 0x1D00
Vanilla 0x0074
org 0x1E00
Vanilla 0x0078
org 0x1F00
Vanilla 0x007C
org 0x2000
Vanilla 0x0080
org 0x2100
Vanilla 0x0084
org 0x2200
Vanilla 0x0088
org 0x2300
Vanilla 0x008C
org 0x2400
Vanilla 0x0090
org 0x2500
Vanilla 0x0094
org 0x2600
Vanilla 0x0098
org 0x2700
Vanilla 0x009C
org 0x2800
Vanilla 0x00A0
org 0x2900
Vanilla 0x00A4
org 0x2A00
Vanilla 0x00A8
org 0x2B00
Vanilla 0x00AC
org 0x2C00
Vanilla 0x00B0
org 0x2D00
Vanilla 0x00B4
org 0x2E00
Vanilla 0x00B8
org 0x2F00
Vanilla 0x00BC
; Outside the exception table, but called by it:
org 0x3000
RTASFairyDust
mr r21,r3
li r0,0
lwz r5, 0(r21)
lwz r4, 4(r21)
lwz r9, 12(r21)
lwz r3, 12(r9)
lwz r6, 8(r21)
lwz r8, 16(r21)
lwz r22,24(r21)
lwz r23,28(r21)
bl @clrbats
lis r7, 'RT'
ori r7,r7,'AS'
; Soo, we jump to *(arg + 24) the ugly way
mtlr r22
blr
@clrbats
mtdbatl 0,r0
mtdbatu 0,r0
mtdbatl 1,r0
mtdbatu 1,r0
mtdbatl 2,r0
mtdbatu 2,r0
mtdbatl 3,r0
mtdbatu 3,r0
mtibatl 0,r0
mtibatu 0,r0
mtibatl 1,r0
mtibatu 1,r0
mtibatl 2,r0
mtibatu 2,r0
mtibatl 3,r0
mtibatu 3,r0
isync
blr