Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-i386 / i387.h
blobf6feb98a93972e7971662fbe09fec8f247e53fee
1 /*
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
9 */
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>
18 #include <asm/user.h>
20 extern void mxcsr_feature_mask_init(void);
21 extern void init_fpu(struct task_struct *);
23 * FPU lazy state save handling...
25 extern void restore_fpu( struct task_struct *tsk );
27 extern void kernel_fpu_begin(void);
28 #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
31 * These must be called with preempt disabled
33 static inline void __save_init_fpu( struct task_struct *tsk )
35 if ( cpu_has_fxsr ) {
36 asm volatile( "fxsave %0 ; fnclex"
37 : "=m" (tsk->thread.i387.fxsave) );
38 } else {
39 asm volatile( "fnsave %0 ; fwait"
40 : "=m" (tsk->thread.i387.fsave) );
42 tsk->thread_info->status &= ~TS_USEDFPU;
45 #define __unlazy_fpu( tsk ) do { \
46 if ((tsk)->thread_info->status & TS_USEDFPU) \
47 save_init_fpu( tsk ); \
48 } while (0)
50 #define __clear_fpu( tsk ) \
51 do { \
52 if ((tsk)->thread_info->status & TS_USEDFPU) { \
53 asm volatile("fnclex ; fwait"); \
54 (tsk)->thread_info->status &= ~TS_USEDFPU; \
55 stts(); \
56 } \
57 } while (0)
61 * These disable preemption on their own and are safe
63 static inline void save_init_fpu( struct task_struct *tsk )
65 preempt_disable();
66 __save_init_fpu(tsk);
67 stts();
68 preempt_enable();
71 #define unlazy_fpu( tsk ) do { \
72 preempt_disable(); \
73 __unlazy_fpu(tsk); \
74 preempt_enable(); \
75 } while (0)
77 #define clear_fpu( tsk ) do { \
78 preempt_disable(); \
79 __clear_fpu( tsk ); \
80 preempt_enable(); \
81 } while (0)
84 * FPU state interaction...
86 extern unsigned short get_fpu_cwd( struct task_struct *tsk );
87 extern unsigned short get_fpu_swd( struct task_struct *tsk );
88 extern unsigned short get_fpu_mxcsr( struct task_struct *tsk );
91 * Signal frame handlers...
93 extern int save_i387( struct _fpstate __user *buf );
94 extern int restore_i387( struct _fpstate __user *buf );
97 * ptrace request handers...
99 extern int get_fpregs( struct user_i387_struct __user *buf,
100 struct task_struct *tsk );
101 extern int set_fpregs( struct task_struct *tsk,
102 struct user_i387_struct __user *buf );
104 extern int get_fpxregs( struct user_fxsr_struct __user *buf,
105 struct task_struct *tsk );
106 extern int set_fpxregs( struct task_struct *tsk,
107 struct user_fxsr_struct __user *buf );
110 * FPU state for core dumps...
112 extern int dump_fpu( struct pt_regs *regs,
113 struct user_i387_struct *fpu );
115 #endif /* __ASM_I386_I387_H */