-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRTAS.s
182 lines (159 loc) · 4.47 KB
/
RTAS.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
; Run-Time Abstraction Services
KCallRTASDispatch
lwz r8, KDP.RTASDispatch(r1)
cmpwi r8, 0
bne @rtaspresent
li r3, -1
b ReturnFromInt
@rtaspresent
mtcrf crMaskFlags, r7
lwz r9, KDP.SysContextPtr(r1)
;<STOLEN FROM=SwitchContext>
lwz r8, KDP.Enables(r1)
stw r7, CB.InterState.Flags(r6)
stw r8, CB.InterState.Enables(r6)
bc BO_IF_NOT, bContextFlagMemRetryErr, @can_dispose_mr_state
stw r17, CB.InterState.MemRetStatus+4(r6)
stw r20, CB.InterState.MemRetData(r6)
stw r21, CB.InterState.MemRetData+4(r6)
stw r19, CB.InterState.MemRetEAR+4(r6)
stw r18, CB.InterState.MemRetEA+4(r6)
lmw r14, KDP.r14(r1)
@can_dispose_mr_state
mfxer r8
stw r13, CB.CR+4(r6)
stw r8, CB.XER+4(r6)
stw r12, CB.LR+4(r6)
mfctr r8
stw r10, CB.PC+4(r6)
stw r8, CB.CTR+4(r6)
bc BO_IF_NOT, bGlobalFlagMQReg, @no_mq
lwz r8, CB.MQ+4(r9)
mfspr r12, mq
mtspr mq, r8
stw r12, CB.MQ+4(r6)
@no_mq
lwz r8, KDP.r1(r1)
stw r0, CB.r0+4(r6)
stw r8, CB.r1+4(r6)
stw r2, CB.r2+4(r6)
stw r3, CB.r3+4(r6)
stw r4, CB.r4+4(r6)
lwz r8, KDP.r6(r1)
stw r5, CB.r5+4(r6)
stw r8, CB.r6+4(r6)
andi. r8, r11, MsrFP
stw r14, CB.r14+4(r6)
stw r15, CB.r15+4(r6)
stw r16, CB.r16+4(r6)
stw r17, CB.r17+4(r6)
stw r18, CB.r18+4(r6)
stw r19, CB.r19+4(r6)
stw r20, CB.r20+4(r6)
stw r21, CB.r21+4(r6)
stw r22, CB.r22+4(r6)
stw r23, CB.r23+4(r6)
stw r24, CB.r24+4(r6)
stw r25, CB.r25+4(r6)
stw r26, CB.r26+4(r6)
stw r27, CB.r27+4(r6)
stw r28, CB.r28+4(r6)
stw r29, CB.r29+4(r6)
stw r30, CB.r30+4(r6)
stw r31, CB.r31+4(r6)
bnel FreezeFPU
;</STOLEN>
stw r11, CB.MSR+4(r6)
mr r27, r3
addi r29, r1, KDP.CurDBAT0
bl GetPhysical ; EA r27, batPtr r29 // PA r31, EQ=Fail
beql CrashRTAS
rlwimi r3, r31, 0, 0xFFFFF000
lhz r8, 4(r3)
cmpwi r8, 0
beq @something
slwi r8, r8, 2
lwzx r27, r8, r3
addi r29, r1, KDP.CurDBAT0
bl GetPhysical
beql CrashRTAS
lwzx r9, r8, r3
rlwimi r9, r31, 0, 0xFFFFF000
stwx r9, r8, r3
li r9, 0
sth r9, 4(r3)
dcbf r8, r3
@something
li r9, 4
dcbf r9, r3
sync
isync
lwz r4, KDP.RTASData(r1)
mfmsr r8
andi. r8, r8, ~(0xFFFF0000|MsrEE|MsrPR|MsrFP|MsrFE0|MsrSE|MsrBE|MsrFE1|MsrIR|MsrDR)
mtmsr r8
isync
mr r28, r3
lwz r9, KDP.RTASDispatch(r1)
bl @DO_IT
mfsprg r1, 0
lwz r6, KDP.ContextPtr(r1)
clrlwi r29, r28, 20
subfic r29, r29, 0x1000
lhz r27, KDP.ProcInfo.DataCacheBlockSize(r1)
@rl subf. r29, r27, r29
dcbf r29, r28
sync
icbi r29, r28
bge @rl
sync
isync
lwz r8, CB.InterState.Flags(r6)
lwz r11, CB.MSR+4(r6)
mr r7, r8
;<STOLEN FROM=SwitchContext>
andi. r8, r11, MsrFE0 + MsrFE1 ; FP exceptions enabled in new context?
lwz r8, CB.InterState.Enables(r6)
lwz r13, CB.CR+4(r6)
stw r8, KDP.Enables(r1)
lwz r8, CB.XER+4(r6)
lwz r12, CB.LR+4(r6)
mtxer r8
lwz r8, CB.CTR+4(r6)
lwz r10, CB.PC+4(r6)
mtctr r8
bnel QuickThawFPU ; FP exceptions enabled, so load FPU
; stwcx. r0, 0, r1 ; present in orig code in SwitchContext
lwz r8, CB.r1+4(r6)
lwz r0, CB.r0+4(r6)
stw r8, KDP.r1(r1)
lwz r2, CB.r2+4(r6)
lwz r3, CB.r3+4(r6)
lwz r4, CB.r4+4(r6)
lwz r8, CB.r6+4(r6)
lwz r5, CB.r5+4(r6)
stw r8, KDP.r6(r1)
lwz r14, CB.r14+4(r6)
lwz r15, CB.r15+4(r6)
lwz r16, CB.r16+4(r6)
lwz r17, CB.r17+4(r6)
lwz r18, CB.r18+4(r6)
lwz r19, CB.r19+4(r6)
lwz r20, CB.r20+4(r6)
lwz r21, CB.r21+4(r6)
lwz r22, CB.r22+4(r6)
lwz r23, CB.r23+4(r6)
lwz r24, CB.r24+4(r6)
lwz r25, CB.r25+4(r6)
lwz r26, CB.r26+4(r6)
lwz r27, CB.r27+4(r6)
lwz r28, CB.r28+4(r6)
lwz r29, CB.r29+4(r6)
lwz r30, CB.r30+4(r6)
lwz r31, CB.r31+4(r6)
;</STOLEN>
li r3, 0
b ReturnFromInt
@DO_IT
mtctr r9
bctr