Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 1 | #ifndef __ASM_SH_FPU_H |
| 2 | #define __ASM_SH_FPU_H |
| 3 | |
Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 4 | #ifndef __ASSEMBLY__ |
Paul Mundt | 9bbafce | 2008-03-26 19:02:47 +0900 | [diff] [blame] | 5 | #include <linux/preempt.h> |
Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 6 | #include <asm/ptrace.h> |
| 7 | |
| 8 | #ifdef CONFIG_SH_FPU |
| 9 | static inline void release_fpu(struct pt_regs *regs) |
| 10 | { |
| 11 | regs->sr |= SR_FD; |
| 12 | } |
| 13 | |
| 14 | static inline void grab_fpu(struct pt_regs *regs) |
| 15 | { |
| 16 | regs->sr &= ~SR_FD; |
| 17 | } |
| 18 | |
| 19 | struct task_struct; |
| 20 | |
| 21 | extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs); |
| 22 | #else |
Paul Mundt | 138bed1 | 2008-03-26 19:09:21 +0900 | [diff] [blame] | 23 | |
Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 24 | #define release_fpu(regs) do { } while (0) |
| 25 | #define grab_fpu(regs) do { } while (0) |
Paul Mundt | 138bed1 | 2008-03-26 19:09:21 +0900 | [diff] [blame] | 26 | |
| 27 | static inline void save_fpu(struct task_struct *tsk, struct pt_regs *regs) |
| 28 | { |
| 29 | clear_tsk_thread_flag(tsk, TIF_USEDFPU); |
| 30 | } |
Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 31 | #endif |
| 32 | |
Paul Mundt | 74d99a5 | 2007-11-26 20:38:36 +0900 | [diff] [blame] | 33 | extern int do_fpu_inst(unsigned short, struct pt_regs *); |
| 34 | |
Paul Mundt | 9bbafce | 2008-03-26 19:02:47 +0900 | [diff] [blame] | 35 | static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs) |
| 36 | { |
| 37 | preempt_disable(); |
| 38 | if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) |
| 39 | save_fpu(tsk, regs); |
| 40 | preempt_enable(); |
| 41 | } |
Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 42 | |
Paul Mundt | 9bbafce | 2008-03-26 19:02:47 +0900 | [diff] [blame] | 43 | static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs) |
| 44 | { |
| 45 | preempt_disable(); |
| 46 | if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { |
| 47 | clear_tsk_thread_flag(tsk, TIF_USEDFPU); |
| 48 | release_fpu(regs); |
| 49 | } |
| 50 | preempt_enable(); |
| 51 | } |
Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 52 | |
| 53 | #endif /* __ASSEMBLY__ */ |
| 54 | |
| 55 | #endif /* __ASM_SH_FPU_H */ |