[STORPORT] Fix x64 build
[reactos.git] / ntoskrnl / ke / powerpc / ctxhelp.S
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/ke/powerpc/ctxhelp.S
5 * PURPOSE: Thread Context Switching
6 *
7 * PROGRAMMERS: arty
8 (i386 implementation by Alex Ionescu)
9 */
10
11 /* INCLUDES ******************************************************************/
12
13 .text
14 .globl syscall_start
15 .globl syscall_end
16 .globl KiSystemService
17 syscall_start:
18 mtsprg0 0
19 mtsprg1 1
20 /* Save and modify srr0 */
21 /* Make a place to store the old srr0 and srr1 ... we may fault
22 * getting KiSystemService1 which will clobber them. */
23 lis 1,1
24 mfsrr0 0
25 stw 0,-16(1)
26 mfsrr1 0
27 stw 0,-12(1)
28 /* Load the target address */
29 lis 1,KiSystemService1@ha
30 addi 1,1,KiSystemService1@l
31 mtsrr0 1
32 mfsprg0 0
33 mfsprg1 1
34 rfi
35 syscall_end:
36 .space 4
37
38 .globl KiSystemService
39 .globl KiSystemService1
40 .globl kiss_proceed
41 .globl kiss_end
42 .align 8
43 KiSystemService1:
44 stwu 1,-256(1)
45 stw 0,16(1)
46 mflr 0
47 stw 0,264(1)
48 addi 1,1,16
49 stw 2,8(1)
50 stw 3,12(1)
51 stw 4,16(1)
52 stw 5,20(1)
53 stw 6,24(1)
54 stw 7,28(1)
55 stw 8,32(1)
56 stw 9,36(1)
57 stw 10,40(1)
58 stw 11,44(1)
59 stw 12,48(1)
60 stw 13,52(1)
61 stw 14,56(1)
62 stw 15,60(1)
63 stw 16,64(1)
64 stw 17,68(1)
65 stw 18,72(1)
66 stw 19,76(1)
67 stw 20,80(1)
68 stw 21,84(1)
69 stw 22,88(1)
70 stw 23,92(1)
71 stw 24,96(1)
72 stw 25,100(1)
73 stw 26,104(1)
74 stw 27,108(1)
75 stw 28,112(1)
76 stw 29,116(1)
77 stw 30,120(1)
78 stw 31,124(1)
79 mflr 0
80 stw 0,128(1)
81 mfctr 0
82 stw 0,136(1)
83 mfmsr 0
84 andi. 0,0,0xffef
85 mtmsr 0
86 lis 2,1
87 lwz 30,-12(2)
88 lwz 31,-16(2)
89 mfmsr 0
90 ori 0,0,0x10
91 mtmsr 0
92 stw 31,140(1)
93 stw 30,144(1)
94 mfdsisr 0
95 stw 0,148(1)
96 mfdar 0
97 stw 0,152(1)
98 lis 3,KiSystemService@ha
99 addi 3,3,KiSystemService@l
100 mtctr 3
101 mr 3,1
102 subi 1,1,16
103 bctrl
104 addi 1,1,16
105 /* Return from kernel */
106 lwz 3,32(1) /* Result */
107 lwz 0,128(1)
108 mtlr 0
109 lwz 0,140(1)
110 mtsrr0 0
111 lwz 0,144(1)
112 mtsrr1 0
113 addi 1,1,0x100 - 16
114 rfi
115
116 .globl KiDecrementerTrapHandler
117 .globl KiDecrementerTrapHandlerEnd
118 .globl KiDecrementerTrap
119 KiDecrementerTrapHandler:
120 mtsprg0 0
121 mtsprg1 1
122 /* Save and modify srr0 */
123 /* Make a place to store the old srr0 and srr1 ... we may fault
124 * getting KiSystemService1 which will clobber them. */
125 lis 1,1
126 mfsprg1 0
127 stw 0,-24(1)
128 mfsrr1 0
129 stw 0,-28(1)
130 mfsrr0 0
131 stw 0,-32(1)
132 /* Load the target address */
133 lis 1,KiDecrementerTrapUpper@ha
134 addi 1,1,KiDecrementerTrapUpper@l
135 mtsrr0 1
136 mfsprg0 0
137 mfsprg1 1
138 rfi
139 KiDecrementerTrapHandlerEnd:
140 .long 0
141
142 /* Decrementer needs to restore the full CPU state */
143 .globl KiDecrementerTrapUpper
144 .align 8
145 KiDecrementerTrapUpper:
146 lis 1,_kernel_trap_stack@ha
147 addi 1,1,_kernel_trap_stack@l
148 subi 1,1,0x200
149 stw 0,0x5c(1)
150 /* Stack handled a bit later */
151 stw 2,0x64(1)
152 stw 3,0x68(1)
153 stw 4,0x6c(1)
154 stw 5,0x70(1)
155 stw 6,0x74(1)
156 stw 7,0x78(1)
157 stw 8,0x7c(1)
158 stw 9,0x80(1)
159 stw 10,0x84(1)
160 stw 11,0x88(1)
161 stw 12,0x8c(1)
162 stw 13,0x90(1)
163 stw 14,0x94(1)
164 stw 15,0x98(1)
165 stw 16,0x9c(1)
166 stw 17,0xa0(1)
167 stw 18,0xa4(1)
168 stw 19,0xa8(1)
169 stw 20,0xac(1)
170 stw 21,0xb0(1)
171 stw 22,0xb4(1)
172 stw 23,0xb8(1)
173 stw 24,0xbc(1)
174 stw 25,0xc0(1)
175 stw 26,0xc4(1)
176 stw 27,0xc8(1)
177 stw 28,0xcc(1)
178 stw 29,0xd0(1)
179 stw 30,0xd4(1)
180 stw 31,0xd8(1)
181 mfcr 0
182 stw 0,0x108(1)
183 mfxer 0
184 stw 0,0x10c(1)
185 mflr 0
186 stw 0,0x118(1)
187 mfctr 0
188 stw 0,0x11c(1)
189 mfmsr 0
190 andi. 0,0,0x7fef
191 mtmsr 0
192 lis 2,1
193 lwz 29,-24(2) // Stack
194 lwz 30,-28(2) // srr1
195 lwz 31,-32(2) // srr0
196 mfmsr 0
197 ori 0,0,0x30
198 mtmsr 0
199 stw 29,0x60(1) // Stack
200 stw 30,0x110(1) // srr1
201 stw 31,0x114(1) // srr0
202 mr 3,1
203 subi 1,1,16
204 bl KiDecrementerTrap
205 addi 1,1,16
206 lwz 2,0x64(1)
207 lwz 3,0x68(1)
208 lwz 4,0x6c(1)
209 lwz 5,0x70(1)
210 lwz 6,0x74(1)
211 lwz 7,0x78(1)
212 lwz 8,0x7c(1)
213 lwz 9,0x80(1)
214 lwz 10,0x84(1)
215 lwz 11,0x88(1)
216 lwz 12,0x8c(1)
217 lwz 13,0x90(1)
218 lwz 14,0x94(1)
219 lwz 15,0x98(1)
220 lwz 16,0x9c(1)
221 lwz 17,0xa0(1)
222 lwz 18,0xa4(1)
223 lwz 19,0xa8(1)
224 lwz 20,0xac(1)
225 lwz 21,0xb0(1)
226 lwz 22,0xb4(1)
227 lwz 23,0xb8(1)
228 lwz 24,0xbc(1)
229 lwz 25,0xc0(1)
230 lwz 26,0xc4(1)
231 lwz 27,0xc8(1)
232 lwz 28,0xcc(1)
233 lwz 29,0xd0(1)
234 lwz 30,0xd4(1)
235 lwz 31,0xd8(1)
236 lwz 0,0x108(1)
237 mtcr 0
238 lwz 0,0x10c(1)
239 mtxer 0
240 lwz 0,0x110(1)
241 mtsrr1 0
242 lwz 0,0x114(1)
243 mtsrr0 0
244 lwz 0,0x118(1)
245 mtlr 0
246 lwz 0,0x11c(1)
247 mtctr 0
248 // back out r0 and r1
249 lwz 0,0x5c(1)
250 lwz 1,0x60(1)
251 // Bye!!1
252 rfi