blob: 1d3aee04b5ccc4c3c0181ead9ca3401733a6ece2 [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);
22#else
Paul Mundt138bed12008-03-26 19:09:21 +090023
Paul Mundt332fd572007-11-22 17:30:50 +090024#define release_fpu(regs) do { } while (0)
25#define grab_fpu(regs) do { } while (0)
Paul Mundt138bed12008-03-26 19:09:21 +090026
27static inline void save_fpu(struct task_struct *tsk, struct pt_regs *regs)
28{
29 clear_tsk_thread_flag(tsk, TIF_USEDFPU);
30}
Paul Mundt332fd572007-11-22 17:30:50 +090031#endif
32
Paul Mundte7ab3cd2008-09-21 19:04:55 +090033struct user_regset;
34
Paul Mundt74d99a52007-11-26 20:38:36 +090035extern int do_fpu_inst(unsigned short, struct pt_regs *);
36
Paul Mundte7ab3cd2008-09-21 19:04:55 +090037extern int fpregs_get(struct task_struct *target,
38 const struct user_regset *regset,
39 unsigned int pos, unsigned int count,
40 void *kbuf, void __user *ubuf);
41
Paul Mundt9bbafce2008-03-26 19:02:47 +090042static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
43{
44 preempt_disable();
45 if (test_tsk_thread_flag(tsk, TIF_USEDFPU))
46 save_fpu(tsk, regs);
47 preempt_enable();
48}
Paul Mundt332fd572007-11-22 17:30:50 +090049
Paul Mundt9bbafce2008-03-26 19:02:47 +090050static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
51{
52 preempt_disable();
53 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) {
54 clear_tsk_thread_flag(tsk, TIF_USEDFPU);
55 release_fpu(regs);
56 }
57 preempt_enable();
58}
Paul Mundt332fd572007-11-22 17:30:50 +090059
Paul Mundte7ab3cd2008-09-21 19:04:55 +090060static inline int init_fpu(struct task_struct *tsk)
61{
62 if (tsk_used_math(tsk)) {
63 if ((boot_cpu_data.flags & CPU_HAS_FPU) && tsk == current)
64 unlazy_fpu(tsk, task_pt_regs(tsk));
65 return 0;
66 }
67
68 set_stopped_child_used_math(tsk);
69 return 0;
70}
71
Paul Mundt332fd572007-11-22 17:30:50 +090072#endif /* __ASSEMBLY__ */
73
74#endif /* __ASM_SH_FPU_H */