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