blob: bfd78e19de1bd61fb5396d0b7e1d7b52dc2a3720 [file] [log] [blame]
Paul Mundt332fd572007-11-22 17:30:50 +09001#ifndef __ASM_SH_FPU_H
2#define __ASM_SH_FPU_H
3
Paul Mundt332fd572007-11-22 17:30:50 +09004#ifndef __ASSEMBLY__
Paul Mundt9bbafce2008-03-26 19:02:47 +09005#include <linux/preempt.h>
Paul Mundt332fd572007-11-22 17:30:50 +09006#include <asm/ptrace.h>
7
8#ifdef CONFIG_SH_FPU
9static inline void release_fpu(struct pt_regs *regs)
10{
11 regs->sr |= SR_FD;
12}
13
14static inline void grab_fpu(struct pt_regs *regs)
15{
16 regs->sr &= ~SR_FD;
17}
18
19struct task_struct;
20
21extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
Giuseppe CAVALLAROa0458b02009-07-07 16:25:10 +020022void fpu_state_restore(struct pt_regs *regs);
Paul Mundt332fd572007-11-22 17:30:50 +090023#else
Paul Mundt138bed12008-03-26 19:09:21 +090024
Paul Mundt332fd572007-11-22 17:30:50 +090025#define release_fpu(regs) do { } while (0)
26#define grab_fpu(regs) do { } while (0)
Paul Mundt138bed12008-03-26 19:09:21 +090027
28static inline void save_fpu(struct task_struct *tsk, struct pt_regs *regs)
29{
30 clear_tsk_thread_flag(tsk, TIF_USEDFPU);
31}
Paul Mundt332fd572007-11-22 17:30:50 +090032#endif
33
Paul Mundte7ab3cd2008-09-21 19:04:55 +090034struct user_regset;
35
Paul Mundt74d99a52007-11-26 20:38:36 +090036extern int do_fpu_inst(unsigned short, struct pt_regs *);
37
Paul Mundte7ab3cd2008-09-21 19:04:55 +090038extern int fpregs_get(struct task_struct *target,
39 const struct user_regset *regset,
40 unsigned int pos, unsigned int count,
41 void *kbuf, void __user *ubuf);
42
Paul Mundt9bbafce2008-03-26 19:02:47 +090043static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
44{
45 preempt_disable();
46 if (test_tsk_thread_flag(tsk, TIF_USEDFPU))
47 save_fpu(tsk, regs);
Giuseppe CAVALLAROa0458b02009-07-07 16:25:10 +020048 else
49 tsk->fpu_counter = 0;
Paul Mundt9bbafce2008-03-26 19:02:47 +090050 preempt_enable();
51}
Paul Mundt332fd572007-11-22 17:30:50 +090052
Paul Mundt9bbafce2008-03-26 19:02:47 +090053static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
54{
55 preempt_disable();
56 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) {
57 clear_tsk_thread_flag(tsk, TIF_USEDFPU);
58 release_fpu(regs);
59 }
60 preempt_enable();
61}
Paul Mundt332fd572007-11-22 17:30:50 +090062
Paul Mundte7ab3cd2008-09-21 19:04:55 +090063static inline int init_fpu(struct task_struct *tsk)
64{
65 if (tsk_used_math(tsk)) {
66 if ((boot_cpu_data.flags & CPU_HAS_FPU) && tsk == current)
67 unlazy_fpu(tsk, task_pt_regs(tsk));
68 return 0;
69 }
70
71 set_stopped_child_used_math(tsk);
72 return 0;
73}
74
Paul Mundt332fd572007-11-22 17:30:50 +090075#endif /* __ASSEMBLY__ */
76
77#endif /* __ASM_SH_FPU_H */