fpu.h 1.7 KB
Newer Older
1 2 3 4
#ifndef __ASM_SH_FPU_H
#define __ASM_SH_FPU_H

#ifndef __ASSEMBLY__
5

6 7
#include <asm/ptrace.h>

8
struct task_struct;
9 10 11 12 13 14 15 16 17 18 19 20

#ifdef CONFIG_SH_FPU
static inline void release_fpu(struct pt_regs *regs)
{
	regs->sr |= SR_FD;
}

static inline void grab_fpu(struct pt_regs *regs)
{
	regs->sr &= ~SR_FD;
}

21
extern void save_fpu(struct task_struct *__tsk);
22 23 24
extern void restore_fpu(struct task_struct *__tsk);
extern void fpu_state_restore(struct pt_regs *regs);
extern void __fpu_state_restore(void);
25
#else
26 27 28 29 30 31
#define save_fpu(tsk)			do { } while (0)
#define restore_fpu(tsk)		do { } while (0)
#define release_fpu(regs)		do { } while (0)
#define grab_fpu(regs)			do { } while (0)
#define fpu_state_restore(regs)		do { } while (0)
#define __fpu_state_restore(regs)	do { } while (0)
32 33
#endif

34 35
struct user_regset;

P
Paul Mundt 已提交
36
extern int do_fpu_inst(unsigned short, struct pt_regs *);
37
extern int init_fpu(struct task_struct *);
P
Paul Mundt 已提交
38

39 40 41 42 43
extern int fpregs_get(struct task_struct *target,
		      const struct user_regset *regset,
		      unsigned int pos, unsigned int count,
		      void *kbuf, void __user *ubuf);

44 45 46 47 48 49 50
static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
{
	if (task_thread_info(tsk)->status & TS_USEDFPU) {
		task_thread_info(tsk)->status &= ~TS_USEDFPU;
		save_fpu(tsk);
		release_fpu(regs);
	} else
51
		tsk->thread.fpu_counter = 0;
52 53
}

54 55 56
static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
{
	preempt_disable();
57
	__unlazy_fpu(tsk, regs);
58 59 60 61 62 63
	preempt_enable();
}

static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
{
	preempt_disable();
64 65
	if (task_thread_info(tsk)->status & TS_USEDFPU) {
		task_thread_info(tsk)->status &= ~TS_USEDFPU;
66 67 68 69
		release_fpu(regs);
	}
	preempt_enable();
}
70 71 72 73

#endif /* __ASSEMBLY__ */

#endif /* __ASM_SH_FPU_H */