internal.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * FPU state and register content conversion primitives
  3. *
  4. * Copyright IBM Corp. 2015
  5. * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
  6. */
  7. #ifndef _ASM_S390_FPU_INTERNAL_H
  8. #define _ASM_S390_FPU_INTERNAL_H
  9. #include <linux/string.h>
  10. #include <asm/ctl_reg.h>
  11. #include <asm/fpu/types.h>
  12. static inline void save_vx_regs(__vector128 *vxrs)
  13. {
  14. asm volatile(
  15. " la 1,%0\n"
  16. " .word 0xe70f,0x1000,0x003e\n" /* vstm 0,15,0(1) */
  17. " .word 0xe70f,0x1100,0x0c3e\n" /* vstm 16,31,256(1) */
  18. : "=Q" (*(struct vx_array *) vxrs) : : "1");
  19. }
  20. static inline void convert_vx_to_fp(freg_t *fprs, __vector128 *vxrs)
  21. {
  22. int i;
  23. for (i = 0; i < __NUM_FPRS; i++)
  24. fprs[i] = *(freg_t *)(vxrs + i);
  25. }
  26. static inline void convert_fp_to_vx(__vector128 *vxrs, freg_t *fprs)
  27. {
  28. int i;
  29. for (i = 0; i < __NUM_FPRS; i++)
  30. *(freg_t *)(vxrs + i) = fprs[i];
  31. }
  32. static inline void fpregs_store(_s390_fp_regs *fpregs, struct fpu *fpu)
  33. {
  34. fpregs->pad = 0;
  35. fpregs->fpc = fpu->fpc;
  36. if (MACHINE_HAS_VX)
  37. convert_vx_to_fp((freg_t *)&fpregs->fprs, fpu->vxrs);
  38. else
  39. memcpy((freg_t *)&fpregs->fprs, fpu->fprs,
  40. sizeof(fpregs->fprs));
  41. }
  42. static inline void fpregs_load(_s390_fp_regs *fpregs, struct fpu *fpu)
  43. {
  44. fpu->fpc = fpregs->fpc;
  45. if (MACHINE_HAS_VX)
  46. convert_fp_to_vx(fpu->vxrs, (freg_t *)&fpregs->fprs);
  47. else
  48. memcpy(fpu->fprs, (freg_t *)&fpregs->fprs,
  49. sizeof(fpregs->fprs));
  50. }
  51. #endif /* _ASM_S390_FPU_INTERNAL_H */