2 * include/asm-i386/i387.h
4 * Copyright (C) 1994 Linus Torvalds
6 * Pentium III FXSR, SSE support
7 * General FPU state handling cleanups
8 * Gareth Hughes <gareth@valinux.com>, May 2000
11 #ifndef __ASM_I386_I387_H
12 #define __ASM_I386_I387_H
14 #include <linux/sched.h>
15 #include <linux/init.h>
16 #include <asm/processor.h>
17 #include <asm/sigcontext.h>
20 extern void mxcsr_feature_mask_init(void);
21 extern void init_fpu(struct task_struct *);
24 * FPU lazy state save handling...
28 * The "nop" is needed to make the instructions the same
31 #define restore_fpu(tsk) \
36 "m" ((tsk)->thread.i387.fxsave))
38 extern void kernel_fpu_begin(void);
39 #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
42 * These must be called with preempt disabled
44 static inline void __save_init_fpu( struct task_struct *tsk )
47 "fnsave %1 ; fwait ;" GENERIC_NOP2,
50 "m" (tsk->thread.i387.fxsave)
52 tsk->thread_info->status &= ~TS_USEDFPU;
55 #define __unlazy_fpu( tsk ) do { \
56 if ((tsk)->thread_info->status & TS_USEDFPU) \
57 save_init_fpu( tsk ); \
60 #define __clear_fpu( tsk ) \
62 if ((tsk)->thread_info->status & TS_USEDFPU) { \
63 asm volatile("fnclex ; fwait"); \
64 (tsk)->thread_info->status &= ~TS_USEDFPU; \
71 * These disable preemption on their own and are safe
73 static inline void save_init_fpu( struct task_struct *tsk )
81 #define unlazy_fpu( tsk ) do { \
87 #define clear_fpu( tsk ) do { \
94 * FPU state interaction...
96 extern unsigned short get_fpu_cwd( struct task_struct *tsk );
97 extern unsigned short get_fpu_swd( struct task_struct *tsk );
98 extern unsigned short get_fpu_mxcsr( struct task_struct *tsk );
101 * Signal frame handlers...
103 extern int save_i387( struct _fpstate __user *buf );
104 extern int restore_i387( struct _fpstate __user *buf );
107 * ptrace request handers...
109 extern int get_fpregs( struct user_i387_struct __user *buf,
110 struct task_struct *tsk );
111 extern int set_fpregs( struct task_struct *tsk,
112 struct user_i387_struct __user *buf );
114 extern int get_fpxregs( struct user_fxsr_struct __user *buf,
115 struct task_struct *tsk );
116 extern int set_fpxregs( struct task_struct *tsk,
117 struct user_fxsr_struct __user *buf );
120 * FPU state for core dumps...
122 extern int dump_fpu( struct pt_regs *regs,
123 struct user_i387_struct *fpu );
125 #endif /* __ASM_I386_I387_H */