Rev 357 | Rev 380 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
214 | serge | 1 | |
2 | clts |
||
3 | fninit |
||
4 | |||
5 | |||
221 | serge | 6 | jnc .no_SSE |
7 | |||
214 | serge | 8 | |
9 | mov ecx, cr0 |
||
10 | or ebx, CR4_OSFXSR+CR4_OSXMMEXPT |
||
11 | mov cr4, ebx |
||
12 | |||
13 | |||
14 | or ecx, CR0_NE |
||
15 | mov cr0, ecx |
||
16 | |||
17 | |||
18 | ldmxcsr [esp-4] |
||
19 | |||
20 | |||
21 | xorps xmm1, xmm1 |
||
22 | xorps xmm2, xmm2 |
||
23 | xorps xmm3, xmm3 |
||
24 | xorps xmm4, xmm4 |
||
25 | xorps xmm5, xmm5 |
||
26 | xorps xmm6, xmm6 |
||
27 | xorps xmm7, xmm7 |
||
28 | fxsave [fpu_data] ;[eax] |
||
357 | serge | 29 | ret |
214 | serge | 30 | .no_SSE: |
221 | serge | 31 | mov ecx, cr0 |
214 | serge | 32 | and ecx, not CR0_EM |
33 | or ecx, CR0_MP+CR0_NE |
||
34 | mov cr0, ecx |
||
35 | fnsave [fpu_data] |
||
357 | serge | 36 | ret |
214 | serge | 37 | |
38 | |||
378 | serge | 39 | ; eax= 512 bytes memory area |
40 | |||
41 | |||
214 | serge | 42 | fpu_save: |
378 | serge | 43 | push ecx |
44 | push esi |
||
45 | push edi |
||
46 | |||
47 | |||
48 | cli |
||
49 | |||
50 | |||
214 | serge | 51 | mov edi, eax |
378 | serge | 52 | |
214 | serge | 53 | |
378 | serge | 54 | mov eax, [CURRENT_TASK] |
55 | cmp ecx, eax |
||
56 | jne .save |
||
57 | .copy: |
||
58 | shl eax, 8 |
||
59 | mov esi, [eax+PROC_BASE+APPDATA.fpu_state] |
||
60 | mov ecx, 512/4 |
||
61 | cld |
||
62 | rep movsd |
||
63 | fninit |
||
64 | |||
65 | |||
66 | pop edi |
||
67 | pop esi |
||
68 | pop ecx |
||
69 | ret |
||
70 | .save: |
||
71 | mov [fpu_owner], eax |
||
72 | |||
73 | |||
74 | mov ecx, [ecx+PROC_BASE+APPDATA.fpu_state] |
||
75 | |||
76 | |||
221 | serge | 77 | jnc .no_SSE |
214 | serge | 78 | |
79 | |||
378 | serge | 80 | jmp .copy |
81 | .no_SSE: |
||
214 | serge | 82 | fnsave [ecx] |
378 | serge | 83 | jmp .copy |
84 | |||
214 | serge | 85 | |
86 | fpu_restore: |
||
378 | serge | 87 | push ecx |
88 | push esi |
||
89 | |||
90 | |||
91 | |||
92 | |||
93 | cli |
||
94 | |||
95 | |||
96 | mov eax, [CURRENT_TASK] |
||
97 | cmp ecx, eax |
||
98 | jne .copy |
||
99 | |||
100 | |||
101 | |||
102 | |||
221 | serge | 103 | jnc .no_SSE |
214 | serge | 104 | |
105 | |||
378 | serge | 106 | popfd |
107 | pop esi |
||
108 | pop ecx |
||
109 | ret |
||
214 | serge | 110 | .no_SSE: |
111 | fnclex ;fix possible problems |
||
112 | frstor [esi] |
||
378 | serge | 113 | popfd |
114 | pop esi |
||
115 | pop ecx |
||
116 | ret |
||
214 | serge | 117 | .copy: |
378 | serge | 118 | shl eax, 8 |
119 | mov edi, [eax+PROC_BASE+APPDATA.fpu_state] |
||
120 | mov ecx, 512/4 |
||
121 | cld |
||
122 | rep movsd |
||
123 | popfd |
||
124 | pop esi |
||
125 | pop ecx |
||
126 | ret |
||
127 | |||
214 | serge | 128 | |
129 | e7: ;#NM exception handler |
||
130 | save_ring3_context |
||
131 | clts |
||
132 | mov ax, os_data |
||
133 | mov ds, ax |
||
134 | mov es, ax |
||
135 | |||
136 | |||
137 | cmp ebx, [CURRENT_TASK] |
||
138 | je .exit |
||
139 | |||
140 | |||
141 | mov eax, [ebx+PROC_BASE+APPDATA.fpu_state] |
||
142 | bt [cpu_caps], CAPS_SSE |
||
221 | serge | 143 | jnc .no_SSE |
214 | serge | 144 | |
145 | |||
146 | mov ebx, [CURRENT_TASK] |
||
147 | mov [fpu_owner], ebx |
||
148 | shl ebx, 8 |
||
149 | mov eax, [ebx+PROC_BASE+APPDATA.fpu_state] |
||
150 | fxrstor [eax] |
||
151 | .exit: |
||
152 | restore_ring3_context |
||
153 | iret |
||
154 | |||
155 | |||
156 | fnsave [eax] |
||
157 | mov ebx, [CURRENT_TASK] |
||
158 | mov [fpu_owner], ebx |
||
159 | shl ebx, 8 |
||
160 | mov eax, [ebx+PROC_BASE+APPDATA.fpu_state] |
||
161 | frstor [eax] |
||
162 | restore_ring3_context |
||
163 | iret |
||
164 | |||
165 | |||
166 | fpu_owner dd 1 |
||
167 | endg |
||
168 | |||
169 | |||
170 | reg_cs equ ebp+8 |
||
171 | reg_eflags equ ebp+12 |
||
172 | reg_esp equ ebp+16 |
||
173 | reg_ss equ ebp+20 |
||
174 | |||
175 | |||
176 | except_16: ;fpu native exceptions handler |
||
177 | push ebp |
||
178 | mov ebp, esp |
||
179 | |||
180 | |||
181 | push ebx |
||
182 | push ecx |
||
183 | push edx |
||
184 | |||
185 | |||
186 | shl ebx, 8 |
||
187 | |||
188 | |||
189 | test eax, eax |
||
190 | jz .default |
||
191 | |||
192 | |||
193 | mov edx, [reg_esp] |
||
194 | sub edx, 4 |
||
195 | mov [ss:edx+new_app_base], ecx |
||
196 | mov [reg_esp], edx |
||
197 | mov dword [reg_eip], eax |
||
198 | |||
199 | |||
200 | pop ecx |
||
201 | pop ebx |
||
202 | pop eax |
||
203 | |||
204 | |||
205 | iretd |
||
206 | |||
207 | |||
208 | pop edx |
||
209 | pop ecx |
||
210 | pop ebx |
||
211 | pop eax |
||
212 | leave |
||
213 | |||
214 | |||
215 | |||
216 | |||
217 | jmp exc_c |
||
218 | |||
219 | |||
220 | except_19: ;sse exceptions handler |
||
221 | push ebp |
||
222 | mov ebp, esp |
||
223 | |||
224 | |||
225 | push ebx |
||
226 | push ecx |
||
227 | push edx |
||
228 | |||
229 | |||
230 | shl ebx, 8 |
||
231 | |||
232 | |||
233 | test eax, eax |
||
234 | jz .default |
||
235 | |||
236 | |||
237 | mov edx, [reg_esp] |
||
238 | sub edx, 4 |
||
239 | mov [ss:edx+new_app_base], ecx |
||
240 | mov [reg_esp], edx |
||
241 | mov dword [reg_eip], eax |
||
242 | |||
243 | |||
244 | pop ecx |
||
245 | pop ebx |
||
246 | pop eax |
||
247 | |||
248 | |||
249 | iretd |
||
250 | |||
251 | |||
252 | pop edx |
||
253 | pop ecx |
||
254 | pop ebx |
||
255 | pop eax |
||
256 | leave |
||
257 | |||
258 | |||
259 | |||
260 | |||
261 | jmp exc_c |
||
262 | |||
263 | |||
264 | restore reg_cs |
||
265 | restore reg_eflags |
||
266 | restore reg_esp |
||
267 | restore reg_ss |
||
268 |