1
2 #include <asm/processor.h>
3 #include <asm/ppc_asm.h>
4 #include <asm/reg.h>
5 #include <asm/asm-offsets.h>
6 #include <asm/cputable.h>
7 #include <asm/thread_info.h>
8 #include <asm/page.h>
9 #include <asm/ptrace.h>
10 #include <asm/export.h>
11 #include <asm/asm-compat.h>
12
13
14
15
16
17 _GLOBAL(load_vr_state)
18 li r4,VRSTATE_VSCR
19 lvx v0,r4,r3
20 mtvscr v0
21 REST_32VRS(0,r4,r3)
22 blr
23 EXPORT_SYMBOL(load_vr_state)
24 _ASM_NOKPROBE_SYMBOL(load_vr_state);
25
26
27
28
29
30 _GLOBAL(store_vr_state)
31 SAVE_32VRS(0, r4, r3)
32 mfvscr v0
33 li r4, VRSTATE_VSCR
34 stvx v0, r4, r3
35 blr
36 EXPORT_SYMBOL(store_vr_state)
37
38
39
40
41
42
43
44
45
46
47
48 _GLOBAL(load_up_altivec)
49 mfmsr r5
50 oris r5,r5,MSR_VEC@h
51 MTMSRD(r5)
52 isync
53
54
55
56
57
58
59
60 mfspr r4,SPRN_VRSAVE
61 cmpwi 0,r4,0
62 bne+ 1f
63 li r4,-1
64 mtspr SPRN_VRSAVE,r4
65 1:
66
67 #ifdef CONFIG_PPC32
68 mfspr r5,SPRN_SPRG_THREAD
69 oris r9,r9,MSR_VEC@h
70 #else
71 ld r4,PACACURRENT(r13)
72 addi r5,r4,THREAD
73 oris r12,r12,MSR_VEC@h
74 std r12,_MSR(r1)
75 #endif
76
77 lbz r4,THREAD_LOAD_VEC(r5)
78 addi r4,r4,1
79 stb r4,THREAD_LOAD_VEC(r5)
80 addi r6,r5,THREAD_VRSTATE
81 li r4,1
82 li r10,VRSTATE_VSCR
83 stw r4,THREAD_USED_VR(r5)
84 lvx v0,r10,r6
85 mtvscr v0
86 REST_32VRS(0,r4,r6)
87
88 blr
89
90
91
92
93
94 _GLOBAL(save_altivec)
95 addi r3,r3,THREAD
96 PPC_LL r7,THREAD_VRSAVEAREA(r3)
97 PPC_LL r5,PT_REGS(r3)
98 PPC_LCMPI 0,r7,0
99 bne 2f
100 addi r7,r3,THREAD_VRSTATE
101 2: SAVE_32VRS(0,r4,r7)
102 mfvscr v0
103 li r4,VRSTATE_VSCR
104 stvx v0,r4,r7
105 blr
106
107 #ifdef CONFIG_VSX
108
109 #ifdef CONFIG_PPC32
110 #error This asm code isn't ready for 32-bit kernels
111 #endif
112
113
114
115
116
117
118
119
120 _GLOBAL(load_up_vsx)
121
122 andi. r5,r12,MSR_FP
123 beql+ load_up_fpu
124 andis. r5,r12,MSR_VEC@h
125 beql+ load_up_altivec
126
127 ld r4,PACACURRENT(r13)
128 addi r4,r4,THREAD
129 li r6,1
130 stw r6,THREAD_USED_VSR(r4)
131
132 oris r12,r12,MSR_VSX@h
133 std r12,_MSR(r1)
134 b fast_exception_return
135
136 #endif
137
138
139
140
141
142
143
144 #ifdef CONFIG_PPC32
145 .data
146 fpzero:
147 .long 0
148 fpone:
149 .long 0x3f800000
150 fphalf:
151 .long 0x3f000000
152
153 #define LDCONST(fr, name) \
154 lis r11,name@ha; \
155 lfs fr,name@l(r11)
156 #else
157
158 .section ".toc","aw"
159 fpzero:
160 .tc FD_0_0[TC],0
161 fpone:
162 .tc FD_3ff00000_0[TC],0x3ff0000000000000
163 fphalf:
164 .tc FD_3fe00000_0[TC],0x3fe0000000000000
165
166 #define LDCONST(fr, name) \
167 lfd fr,name@toc(r2)
168 #endif
169
170 .text
171
172
173
174
175 fpenable:
176 #ifdef CONFIG_PPC32
177 stwu r1,-64(r1)
178 #else
179 stdu r1,-64(r1)
180 #endif
181 mfmsr r10
182 ori r11,r10,MSR_FP
183 mtmsr r11
184 isync
185 stfd fr0,24(r1)
186 stfd fr1,16(r1)
187 stfd fr31,8(r1)
188 LDCONST(fr1, fpzero)
189 mffs fr31
190 MTFSF_L(fr1)
191 blr
192
193 fpdisable:
194 mtlr r12
195 MTFSF_L(fr31)
196 lfd fr31,8(r1)
197 lfd fr1,16(r1)
198 lfd fr0,24(r1)
199 mtmsr r10
200 isync
201 addi r1,r1,64
202 blr
203
204
205
206
207 _GLOBAL(vaddfp)
208 mflr r12
209 bl fpenable
210 li r0,4
211 mtctr r0
212 li r6,0
213 1: lfsx fr0,r4,r6
214 lfsx fr1,r5,r6
215 fadds fr0,fr0,fr1
216 stfsx fr0,r3,r6
217 addi r6,r6,4
218 bdnz 1b
219 b fpdisable
220
221
222
223
224 _GLOBAL(vsubfp)
225 mflr r12
226 bl fpenable
227 li r0,4
228 mtctr r0
229 li r6,0
230 1: lfsx fr0,r4,r6
231 lfsx fr1,r5,r6
232 fsubs fr0,fr0,fr1
233 stfsx fr0,r3,r6
234 addi r6,r6,4
235 bdnz 1b
236 b fpdisable
237
238
239
240
241 _GLOBAL(vmaddfp)
242 mflr r12
243 bl fpenable
244 stfd fr2,32(r1)
245 li r0,4
246 mtctr r0
247 li r7,0
248 1: lfsx fr0,r4,r7
249 lfsx fr1,r5,r7
250 lfsx fr2,r6,r7
251 fmadds fr0,fr0,fr2,fr1
252 stfsx fr0,r3,r7
253 addi r7,r7,4
254 bdnz 1b
255 lfd fr2,32(r1)
256 b fpdisable
257
258
259
260
261 _GLOBAL(vnmsubfp)
262 mflr r12
263 bl fpenable
264 stfd fr2,32(r1)
265 li r0,4
266 mtctr r0
267 li r7,0
268 1: lfsx fr0,r4,r7
269 lfsx fr1,r5,r7
270 lfsx fr2,r6,r7
271 fnmsubs fr0,fr0,fr2,fr1
272 stfsx fr0,r3,r7
273 addi r7,r7,4
274 bdnz 1b
275 lfd fr2,32(r1)
276 b fpdisable
277
278
279
280
281
282 _GLOBAL(vrefp)
283 mflr r12
284 bl fpenable
285 li r0,4
286 LDCONST(fr1, fpone)
287 mtctr r0
288 li r6,0
289 1: lfsx fr0,r4,r6
290 fdivs fr0,fr1,fr0
291 stfsx fr0,r3,r6
292 addi r6,r6,4
293 bdnz 1b
294 b fpdisable
295
296
297
298
299
300
301
302 _GLOBAL(vrsqrtefp)
303 mflr r12
304 bl fpenable
305 stfd fr2,32(r1)
306 stfd fr3,40(r1)
307 stfd fr4,48(r1)
308 stfd fr5,56(r1)
309 li r0,4
310 LDCONST(fr4, fpone)
311 LDCONST(fr5, fphalf)
312 mtctr r0
313 li r6,0
314 1: lfsx fr0,r4,r6
315 frsqrte fr1,fr0
316 fmuls fr3,fr1,fr0
317 fmuls fr2,fr1,fr5
318 fnmsubs fr3,fr1,fr3,fr4
319 fmadds fr1,fr2,fr3,fr1
320 fmuls fr3,fr1,fr0
321 fmuls fr2,fr1,fr5
322 fnmsubs fr3,fr1,fr3,fr4
323 fmadds fr1,fr2,fr3,fr1
324 stfsx fr1,r3,r6
325 addi r6,r6,4
326 bdnz 1b
327 lfd fr5,56(r1)
328 lfd fr4,48(r1)
329 lfd fr3,40(r1)
330 lfd fr2,32(r1)
331 b fpdisable