| 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 | 0ea820c | 2010-01-13 12:51:40 +0900 | [diff] [blame] | 5 |  | 
|  | 6 | struct task_struct; | 
| Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 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 |  | 
| Stuart Menefy | d3ea9fa | 2009-09-25 18:25:10 +0100 | [diff] [blame] | 19 | extern void save_fpu(struct task_struct *__tsk); | 
| Paul Mundt | 0ea820c | 2010-01-13 12:51:40 +0900 | [diff] [blame] | 20 | extern void restore_fpu(struct task_struct *__tsk); | 
|  | 21 | extern void fpu_state_restore(struct pt_regs *regs); | 
|  | 22 | extern void __fpu_state_restore(void); | 
| Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 23 | #else | 
| Paul Mundt | 0ea820c | 2010-01-13 12:51:40 +0900 | [diff] [blame] | 24 | #define save_fpu(tsk)			do { } while (0) | 
|  | 25 | #define restore_fpu(tsk)		do { } while (0) | 
|  | 26 | #define release_fpu(regs)		do { } while (0) | 
|  | 27 | #define grab_fpu(regs)			do { } while (0) | 
|  | 28 | #define fpu_state_restore(regs)		do { } while (0) | 
|  | 29 | #define __fpu_state_restore(regs)	do { } while (0) | 
| Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 30 | #endif | 
|  | 31 |  | 
| Paul Mundt | e7ab3cd | 2008-09-21 19:04:55 +0900 | [diff] [blame] | 32 | struct user_regset; | 
|  | 33 |  | 
| Paul Mundt | 74d99a5 | 2007-11-26 20:38:36 +0900 | [diff] [blame] | 34 | extern int do_fpu_inst(unsigned short, struct pt_regs *); | 
| Paul Mundt | 0ea820c | 2010-01-13 12:51:40 +0900 | [diff] [blame] | 35 | extern int init_fpu(struct task_struct *); | 
| Paul Mundt | 74d99a5 | 2007-11-26 20:38:36 +0900 | [diff] [blame] | 36 |  | 
| Paul Mundt | e7ab3cd | 2008-09-21 19:04:55 +0900 | [diff] [blame] | 37 | extern 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 |  | 
| Stuart Menefy | d3ea9fa | 2009-09-25 18:25:10 +0100 | [diff] [blame] | 42 | static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs) | 
|  | 43 | { | 
|  | 44 | if (task_thread_info(tsk)->status & TS_USEDFPU) { | 
|  | 45 | task_thread_info(tsk)->status &= ~TS_USEDFPU; | 
|  | 46 | save_fpu(tsk); | 
|  | 47 | release_fpu(regs); | 
|  | 48 | } else | 
|  | 49 | tsk->fpu_counter = 0; | 
|  | 50 | } | 
|  | 51 |  | 
| Paul Mundt | 9bbafce | 2008-03-26 19:02:47 +0900 | [diff] [blame] | 52 | static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs) | 
|  | 53 | { | 
|  | 54 | preempt_disable(); | 
| Stuart Menefy | d3ea9fa | 2009-09-25 18:25:10 +0100 | [diff] [blame] | 55 | __unlazy_fpu(tsk, regs); | 
| Paul Mundt | 9bbafce | 2008-03-26 19:02:47 +0900 | [diff] [blame] | 56 | preempt_enable(); | 
|  | 57 | } | 
| Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 58 |  | 
| Paul Mundt | 9bbafce | 2008-03-26 19:02:47 +0900 | [diff] [blame] | 59 | static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs) | 
|  | 60 | { | 
|  | 61 | preempt_disable(); | 
| Stuart Menefy | d3ea9fa | 2009-09-25 18:25:10 +0100 | [diff] [blame] | 62 | if (task_thread_info(tsk)->status & TS_USEDFPU) { | 
|  | 63 | task_thread_info(tsk)->status &= ~TS_USEDFPU; | 
| Paul Mundt | 9bbafce | 2008-03-26 19:02:47 +0900 | [diff] [blame] | 64 | release_fpu(regs); | 
|  | 65 | } | 
|  | 66 | preempt_enable(); | 
|  | 67 | } | 
| Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 68 |  | 
| Paul Mundt | 332fd57 | 2007-11-22 17:30:50 +0900 | [diff] [blame] | 69 | #endif /* __ASSEMBLY__ */ | 
|  | 70 |  | 
|  | 71 | #endif /* __ASM_SH_FPU_H */ |