1 /* SPDX-License-Identifier: GPL-2.0 */
3 * FPU state and register content conversion primitives
5 * Copyright IBM Corp. 2015
6 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
9 #ifndef _ASM_S390_FPU_INTERNAL_H
10 #define _ASM_S390_FPU_INTERNAL_H
12 #include <linux/string.h>
13 #include <asm/ctl_reg.h>
14 #include <asm/fpu/types.h>
16 static inline void save_vx_regs(__vector128
*vxrs
)
20 " .word 0xe70f,0x1000,0x003e\n" /* vstm 0,15,0(1) */
21 " .word 0xe70f,0x1100,0x0c3e\n" /* vstm 16,31,256(1) */
22 : "=Q" (*(struct vx_array
*) vxrs
) : : "1");
25 static inline void convert_vx_to_fp(freg_t
*fprs
, __vector128
*vxrs
)
29 for (i
= 0; i
< __NUM_FPRS
; i
++)
30 fprs
[i
] = *(freg_t
*)(vxrs
+ i
);
33 static inline void convert_fp_to_vx(__vector128
*vxrs
, freg_t
*fprs
)
37 for (i
= 0; i
< __NUM_FPRS
; i
++)
38 *(freg_t
*)(vxrs
+ i
) = fprs
[i
];
41 static inline void fpregs_store(_s390_fp_regs
*fpregs
, struct fpu
*fpu
)
44 fpregs
->fpc
= fpu
->fpc
;
46 convert_vx_to_fp((freg_t
*)&fpregs
->fprs
, fpu
->vxrs
);
48 memcpy((freg_t
*)&fpregs
->fprs
, fpu
->fprs
,
49 sizeof(fpregs
->fprs
));
52 static inline void fpregs_load(_s390_fp_regs
*fpregs
, struct fpu
*fpu
)
54 fpu
->fpc
= fpregs
->fpc
;
56 convert_fp_to_vx(fpu
->vxrs
, (freg_t
*)&fpregs
->fprs
);
58 memcpy(fpu
->fprs
, (freg_t
*)&fpregs
->fprs
,
59 sizeof(fpregs
->fprs
));
62 #endif /* _ASM_S390_FPU_INTERNAL_H */