Rev 1023 | Rev 1964 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1023 | Rev 1053 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | 29 | ||
30 | #include <fpu_context.h> |
30 | #include <fpu_context.h> |
31 | #include <arch/register.h> |
31 | #include <arch/register.h> |
32 | #include <print.h> |
32 | #include <print.h> |
33 | 33 | ||
- | 34 | ||
34 | void fpu_context_save(fpu_context_t *fctx){ |
35 | void fpu_context_save(fpu_context_t *fctx){ |
35 | asm volatile( |
- | |
36 | "stf.spill [%2]=f2,0x80\n" |
- | |
37 | "stf.spill [%3]=f3,0x80\n" |
- | |
38 | "stf.spill [%4]=f4,0x80\n" |
- | |
39 | "stf.spill [%5]=f5,0x80\n" |
- | |
40 | "stf.spill [%6]=f6,0x80\n" |
- | |
41 | "stf.spill [%7]=f7,0x80\n;;" |
- | |
42 | - | ||
43 | "stf.spill [%0]=f8,0x80\n" |
- | |
44 | "stf.spill [%1]=f9,0x80\n" |
- | |
45 | "stf.spill [%2]=f10,0x80\n" |
- | |
46 | "stf.spill [%3]=f11,0x80\n" |
- | |
47 | "stf.spill [%4]=f12,0x80\n" |
- | |
48 | "stf.spill [%5]=f13,0x80\n" |
- | |
49 | "stf.spill [%6]=f14,0x80\n" |
- | |
50 | "stf.spill [%7]=f15,0x80\n;;" |
- | |
51 | - | ||
52 | "stf.spill [%0]=f16,0x80\n" |
- | |
53 | "stf.spill [%1]=f17,0x80\n" |
- | |
54 | "stf.spill [%2]=f18,0x80\n" |
- | |
55 | "stf.spill [%3]=f19,0x80\n" |
- | |
56 | "stf.spill [%4]=f20,0x80\n" |
- | |
57 | "stf.spill [%5]=f21,0x80\n" |
- | |
58 | "stf.spill [%6]=f22,0x80\n" |
- | |
59 | "stf.spill [%7]=f23,0x80\n;;" |
- | |
60 | - | ||
61 | "stf.spill [%0]=f24,0x80\n" |
- | |
62 | "stf.spill [%1]=f25,0x80\n" |
- | |
63 | "stf.spill [%2]=f26,0x80\n" |
- | |
64 | "stf.spill [%3]=f27,0x80\n" |
- | |
65 | "stf.spill [%4]=f28,0x80\n" |
- | |
66 | "stf.spill [%5]=f29,0x80\n" |
- | |
67 | "stf.spill [%6]=f30,0x80\n" |
- | |
68 | "stf.spill [%7]=f31,0x80\n;;" |
- | |
69 | 36 | ||
- | 37 | asm volatile( |
|
70 | 38 | ||
71 | "stf.spill [%0]=f32,0x80\n" |
39 | "stf.spill [%0]=f32,0x80\n" |
72 | "stf.spill [%1]=f33,0x80\n" |
40 | "stf.spill [%1]=f33,0x80\n" |
73 | "stf.spill [%2]=f34,0x80\n" |
41 | "stf.spill [%2]=f34,0x80\n" |
74 | "stf.spill [%3]=f35,0x80\n" |
42 | "stf.spill [%3]=f35,0x80\n" |
Line 186... | Line 154... | ||
186 | } |
154 | } |
187 | 155 | ||
188 | 156 | ||
189 | void fpu_context_restore(fpu_context_t *fctx) |
157 | void fpu_context_restore(fpu_context_t *fctx) |
190 | { |
158 | { |
191 | asm volatile( |
- | |
192 | "ldf.fill f2=[%2],0x80\n" |
- | |
193 | "ldf.fill f3=[%3],0x80\n" |
- | |
194 | "ldf.fill f4=[%4],0x80\n" |
- | |
195 | "ldf.fill f5=[%5],0x80\n" |
- | |
196 | "ldf.fill f6=[%6],0x80\n" |
- | |
197 | "ldf.fill f7=[%7],0x80\n;;" |
- | |
198 | - | ||
199 | "ldf.fill f8=[%0],0x80\n" |
- | |
200 | "ldf.fill f9=[%1],0x80\n" |
- | |
201 | "ldf.fill f10=[%2],0x80\n" |
- | |
202 | "ldf.fill f11=[%3],0x80\n" |
- | |
203 | "ldf.fill f12=[%4],0x80\n" |
- | |
204 | "ldf.fill f13=[%5],0x80\n" |
- | |
205 | "ldf.fill f14=[%6],0x80\n" |
- | |
206 | "ldf.fill f15=[%7],0x80\n;;" |
- | |
207 | - | ||
208 | "ldf.fill f16=[%0],0x80\n" |
- | |
209 | "ldf.fill f17=[%1],0x80\n" |
- | |
210 | "ldf.fill f18=[%2],0x80\n" |
- | |
211 | "ldf.fill f19=[%3],0x80\n" |
- | |
212 | "ldf.fill f20=[%4],0x80\n" |
- | |
213 | "ldf.fill f21=[%5],0x80\n" |
- | |
214 | "ldf.fill f22=[%6],0x80\n" |
- | |
215 | "ldf.fill f23=[%7],0x80\n;;" |
- | |
216 | - | ||
217 | "ldf.fill f24=[%0],0x80\n" |
- | |
218 | "ldf.fill f25=[%1],0x80\n" |
- | |
219 | "ldf.fill f26=[%2],0x80\n" |
- | |
220 | "ldf.fill f27=[%3],0x80\n" |
- | |
221 | "ldf.fill f28=[%4],0x80\n" |
- | |
222 | "ldf.fill f29=[%5],0x80\n" |
- | |
223 | "ldf.fill f30=[%6],0x80\n" |
- | |
224 | "ldf.fill f31=[%7],0x80\n;;" |
- | |
225 | - | ||
226 | 159 | ||
- | 160 | asm volatile( |
|
227 | "ldf.fill f32=[%0],0x80\n" |
161 | "ldf.fill f32=[%0],0x80\n" |
228 | "ldf.fill f33=[%1],0x80\n" |
162 | "ldf.fill f33=[%1],0x80\n" |
229 | "ldf.fill f34=[%2],0x80\n" |
163 | "ldf.fill f34=[%2],0x80\n" |
230 | "ldf.fill f35=[%3],0x80\n" |
164 | "ldf.fill f35=[%3],0x80\n" |
231 | "ldf.fill f36=[%4],0x80\n" |
165 | "ldf.fill f36=[%4],0x80\n" |
Line 336... | Line 270... | ||
336 | 270 | ||
337 | : |
271 | : |
338 | :"r" (&((fctx->fr)[0])),"r" (&((fctx->fr)[1])),"r" (&((fctx->fr)[2])),"r" (&((fctx->fr)[3])), |
272 | :"r" (&((fctx->fr)[0])),"r" (&((fctx->fr)[1])),"r" (&((fctx->fr)[2])),"r" (&((fctx->fr)[3])), |
339 | "r" (&((fctx->fr)[4])),"r" (&((fctx->fr)[5])),"r" (&((fctx->fr)[6])),"r" (&((fctx->fr)[7])) |
273 | "r" (&((fctx->fr)[4])),"r" (&((fctx->fr)[5])),"r" (&((fctx->fr)[6])),"r" (&((fctx->fr)[7])) |
340 | ); |
274 | ); |
341 | - | ||
342 | - | ||
343 | } |
275 | } |
344 | 276 | ||
345 | void fpu_disable(void) |
277 | void fpu_enable(void) |
346 | { |
278 | { |
- | 279 | __u64 a = 0 ; |
|
347 | asm volatile( |
280 | asm volatile( |
348 | "ssm %0;;\n" |
281 | "rsm %0;;" |
349 | "srlz.i\n" |
282 | "srlz.i\n" |
350 | "srlz.d;;\n" |
283 | "srlz.d;;\n" |
351 | : |
284 | : |
352 | :"i" (PSR_DFL_MASK|PSR_DFH_MASK) |
285 | :"i" (PSR_DFH_MASK) |
- | 286 | ); |
|
- | 287 | asm volatile |
|
- | 288 | ( |
|
- | 289 | "mov %0=ar.fpsr;;\n" |
|
- | 290 | "or %0=%0,%1;;\n" |
|
- | 291 | "mov ar.fpsr=%0;;\n" |
|
- | 292 | : "+r" (a) |
|
- | 293 | : "r" (0x38) |
|
353 | ); |
294 | ); |
354 | 295 | ||
355 | } |
296 | } |
356 | 297 | ||
357 | void fpu_enable(void) |
298 | void fpu_disable(void) |
358 | { |
299 | { |
- | 300 | ||
- | 301 | __u64 a = 0 ; |
|
359 | asm volatile( |
302 | asm volatile( |
360 | "rsm %0;;\n" |
303 | "ssm %0;;\n" |
361 | "srlz.i\n" |
304 | "srlz.i\n" |
362 | "srlz.d;;\n" |
305 | "srlz.d;;\n" |
363 | : |
306 | : |
364 | :"i" (PSR_DFL_MASK|PSR_DFH_MASK) |
307 | :"i" (PSR_DFH_MASK) |
- | 308 | ); |
|
- | 309 | asm volatile |
|
- | 310 | ( |
|
- | 311 | "mov %0=ar.fpsr;;\n" |
|
- | 312 | "or %0=%0,%1;;\n" |
|
- | 313 | "mov ar.fpsr=%0;;\n" |
|
- | 314 | : "+r" (a) |
|
- | 315 | : "r" (0x38) |
|
365 | ); |
316 | ); |
366 | 317 | ||
367 | } |
318 | } |
368 | 319 | ||
369 | void fpu_init(void) |
320 | void fpu_init(void) |
370 | { |
321 | { |
371 | __u64 a = 0; |
322 | __u64 a = 0 ; |
372 | fpu_enable(); |
- | |
373 | asm volatile |
323 | asm volatile |
374 | ( |
324 | ( |
375 | "mov %0=ar.fpsr;;\n" |
325 | "mov %0=ar.fpsr;;\n" |
376 | "or %0=%0,%1;;\n" |
326 | "or %0=%0,%1;;\n" |
377 | "mov ar.fpsr=%0;;\n" |
327 | "mov ar.fpsr=%0;;\n" |
378 | : "+r" (a) |
328 | : "+r" (a) |
379 | : "r" (0x38) |
329 | : "r" (0x38) |
380 | ); |
330 | ); |
381 | 331 | ||
382 | asm volatile( |
332 | asm volatile( |
383 | "mov f2=f0\n" |
333 | "mov f2=f0\n" |
384 | "mov f3=f0\n" |
334 | "mov f3=f0\n" |
385 | "mov f4=f0\n" |
335 | "mov f4=f0\n" |
386 | "mov f5=f0\n" |
336 | "mov f5=f0\n" |
Line 519... | Line 469... | ||
519 | "mov f126=f0\n" |
469 | "mov f126=f0\n" |
520 | "mov f127=f0\n" |
470 | "mov f127=f0\n" |
521 | 471 | ||
522 | ); |
472 | ); |
523 | 473 | ||
524 | fpu_enable(); |
- | |
525 | } |
474 | } |
526 | 475 |