1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_SH_FPU_H 3 #define __ASM_SH_FPU_H 4 5 #ifndef __ASSEMBLY__ 6 7 #include <asm/ptrace.h> 8 9 struct task_struct; 10 11 #ifdef CONFIG_SH_FPU release_fpu(struct pt_regs * regs)12static inline void release_fpu(struct pt_regs *regs) 13 { 14 regs->sr |= SR_FD; 15 } 16 grab_fpu(struct pt_regs * regs)17static inline void grab_fpu(struct pt_regs *regs) 18 { 19 regs->sr &= ~SR_FD; 20 } 21 22 extern void save_fpu(struct task_struct *__tsk); 23 extern void restore_fpu(struct task_struct *__tsk); 24 extern void fpu_state_restore(struct pt_regs *regs); 25 extern void __fpu_state_restore(void); 26 #else 27 #define save_fpu(tsk) do { } while (0) 28 #define restore_fpu(tsk) do { } while (0) 29 #define release_fpu(regs) do { } while (0) 30 #define grab_fpu(regs) do { } while (0) 31 #define fpu_state_restore(regs) do { } while (0) 32 #define __fpu_state_restore(regs) do { } while (0) 33 #endif 34 35 struct user_regset; 36 37 extern int do_fpu_inst(unsigned short, struct pt_regs *); 38 extern int init_fpu(struct task_struct *); 39 __unlazy_fpu(struct task_struct * tsk,struct pt_regs * regs)40static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs) 41 { 42 if (task_thread_info(tsk)->status & TS_USEDFPU) { 43 task_thread_info(tsk)->status &= ~TS_USEDFPU; 44 save_fpu(tsk); 45 release_fpu(regs); 46 } else 47 tsk->thread.fpu_counter = 0; 48 } 49 unlazy_fpu(struct task_struct * tsk,struct pt_regs * regs)50static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs) 51 { 52 preempt_disable(); 53 __unlazy_fpu(tsk, regs); 54 preempt_enable(); 55 } 56 clear_fpu(struct task_struct * tsk,struct pt_regs * regs)57static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs) 58 { 59 preempt_disable(); 60 if (task_thread_info(tsk)->status & TS_USEDFPU) { 61 task_thread_info(tsk)->status &= ~TS_USEDFPU; 62 release_fpu(regs); 63 } 64 preempt_enable(); 65 } 66 67 #endif /* __ASSEMBLY__ */ 68 69 #endif /* __ASM_SH_FPU_H */ 70