Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 1 | /* |
2 | * include/asm-i386/i387.h |
||
3 | * |
||
4 | * Copyright (C) 1994 Linus Torvalds |
||
5 | * |
||
6 | * Pentium III FXSR, SSE support |
||
7 | * General FPU state handling cleanups |
||
8 | * Gareth Hughes <gareth@valinux.com>, May 2000 |
||
9 | */ |
||
10 | |||
11 | #ifndef __ASM_I386_I387_H |
||
12 | #define __ASM_I386_I387_H |
||
13 | |||
14 | #include <linux/sched.h> |
||
15 | #include <asm/processor.h> |
||
16 | #include <asm/sigcontext.h> |
||
17 | #include <asm/user.h> |
||
18 | |||
19 | extern void init_fpu(struct task_struct *); |
||
20 | /* |
||
21 | * FPU lazy state save handling... |
||
22 | */ |
||
23 | extern void restore_fpu( struct task_struct *tsk ); |
||
24 | |||
25 | extern void kernel_fpu_begin(void); |
||
26 | #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0) |
||
27 | |||
28 | /* |
||
29 | * These must be called with preempt disabled |
||
30 | */ |
||
31 | static inline void __save_init_fpu( struct task_struct *tsk ) |
||
32 | { |
||
33 | if ( cpu_has_fxsr ) { |
||
34 | asm volatile( "fxsave %0 ; fnclex" |
||
35 | : "=m" (tsk->thread.i387.fxsave) ); |
||
36 | } else { |
||
37 | asm volatile( "fnsave %0 ; fwait" |
||
38 | : "=m" (tsk->thread.i387.fsave) ); |
||
39 | } |
||
40 | tsk->thread_info->status &= ~TS_USEDFPU; |
||
41 | } |
||
42 | |||
43 | #define __unlazy_fpu( tsk ) do { \ |
||
44 | if ((tsk)->thread_info->status & TS_USEDFPU) \ |
||
45 | save_init_fpu( tsk ); \ |
||
46 | } while (0) |
||
47 | |||
48 | #define __clear_fpu( tsk ) \ |
||
49 | do { \ |
||
50 | if ((tsk)->thread_info->status & TS_USEDFPU) { \ |
||
51 | asm volatile("fwait"); \ |
||
52 | (tsk)->thread_info->status &= ~TS_USEDFPU; \ |
||
53 | stts(); \ |
||
54 | } \ |
||
55 | } while (0) |
||
56 | |||
57 | |||
58 | /* |
||
59 | * These disable preemption on their own and are safe |
||
60 | */ |
||
61 | static inline void save_init_fpu( struct task_struct *tsk ) |
||
62 | { |
||
63 | preempt_disable(); |
||
64 | __save_init_fpu(tsk); |
||
65 | stts(); |
||
66 | preempt_enable(); |
||
67 | } |
||
68 | |||
69 | #define unlazy_fpu( tsk ) do { \ |
||
70 | preempt_disable(); \ |
||
71 | __unlazy_fpu(tsk); \ |
||
72 | preempt_enable(); \ |
||
73 | } while (0) |
||
74 | |||
75 | #define clear_fpu( tsk ) do { \ |
||
76 | preempt_disable(); \ |
||
77 | __clear_fpu( tsk ); \ |
||
78 | preempt_enable(); \ |
||
79 | } while (0) |
||
80 | \ |
||
81 | /* |
||
82 | * FPU state interaction... |
||
83 | */ |
||
84 | extern unsigned short get_fpu_cwd( struct task_struct *tsk ); |
||
85 | extern unsigned short get_fpu_swd( struct task_struct *tsk ); |
||
86 | extern unsigned short get_fpu_twd( struct task_struct *tsk ); |
||
87 | extern unsigned short get_fpu_mxcsr( struct task_struct *tsk ); |
||
88 | |||
89 | extern void set_fpu_cwd( struct task_struct *tsk, unsigned short cwd ); |
||
90 | extern void set_fpu_swd( struct task_struct *tsk, unsigned short swd ); |
||
91 | extern void set_fpu_twd( struct task_struct *tsk, unsigned short twd ); |
||
92 | extern void set_fpu_mxcsr( struct task_struct *tsk, unsigned short mxcsr ); |
||
93 | |||
94 | #define load_mxcsr( val ) do { \ |
||
95 | unsigned long __mxcsr = ((unsigned long)(val) & 0xffbf); \ |
||
96 | asm volatile( "ldmxcsr %0" : : "m" (__mxcsr) ); \ |
||
97 | } while (0) |
||
98 | |||
99 | /* |
||
100 | * Signal frame handlers... |
||
101 | */ |
||
102 | extern int save_i387( struct _fpstate __user *buf ); |
||
103 | extern int restore_i387( struct _fpstate __user *buf ); |
||
104 | |||
105 | /* |
||
106 | * ptrace request handers... |
||
107 | */ |
||
108 | extern int get_fpregs( struct user_i387_struct __user *buf, |
||
109 | struct task_struct *tsk ); |
||
110 | extern int set_fpregs( struct task_struct *tsk, |
||
111 | struct user_i387_struct __user *buf ); |
||
112 | |||
113 | extern int get_fpxregs( struct user_fxsr_struct __user *buf, |
||
114 | struct task_struct *tsk ); |
||
115 | extern int set_fpxregs( struct task_struct *tsk, |
||
116 | struct user_fxsr_struct __user *buf ); |
||
117 | |||
118 | /* |
||
119 | * FPU state for core dumps... |
||
120 | */ |
||
121 | extern int dump_fpu( struct pt_regs *regs, |
||
122 | struct user_i387_struct *fpu ); |
||
123 | extern int dump_extended_fpu( struct pt_regs *regs, |
||
124 | struct user_fxsr_struct *fpu ); |
||
125 | |||
126 | #endif /* __ASM_I386_I387_H */ |