internal.h 1.4 KB

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