Rev 7165 | Rev 7199 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7165 | Rev 7168 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 7165 $ |
8 | $Revision: 7168 $ |
9 | 9 | ||
10 | 10 | ||
Line 11... | Line 11... | ||
11 | init_fpu: |
11 | init_fpu: |
12 | clts |
12 | clts |
Line 13... | Line 13... | ||
13 | fninit |
13 | fninit |
14 | 14 | ||
15 | bt [cpu_caps+(CAPS_XSAVE/8)], CAPS_XSAVE mod 8 |
15 | bt [cpu_caps+(CAPS_XSAVE/32)], CAPS_XSAVE mod 32 |
Line 134... | Line 134... | ||
134 | vpxorq zmm7, zmm7, zmm7 |
134 | vpxorq zmm7, zmm7, zmm7 |
Line 135... | Line 135... | ||
135 | 135 | ||
Line 136... | Line 136... | ||
136 | ret |
136 | ret |
137 | 137 | ||
Line 138... | Line 138... | ||
138 | ; param |
138 | ; param |
139 | ; eax= 512 bytes memory area |
139 | ; eax= 512 bytes memory area aligned on a 16-byte boundary |
140 | 140 | ||
141 | align 4 |
141 | align 4 |
Line 153... | Line 153... | ||
153 | mov ecx, [fpu_owner] |
153 | mov ecx, [fpu_owner] |
154 | mov esi, [CURRENT_TASK] |
154 | mov esi, [CURRENT_TASK] |
155 | cmp ecx, esi |
155 | cmp ecx, esi |
156 | jne .save |
156 | jne .save |
Line 157... | Line 157... | ||
157 | 157 | ||
158 | call save_context |
158 | call save_fpu_context |
159 | jmp .exit |
159 | jmp .exit |
160 | .save: |
160 | .save: |
Line 161... | Line 161... | ||
161 | mov [fpu_owner], esi |
161 | mov [fpu_owner], esi |
162 | 162 | ||
Line 163... | Line 163... | ||
163 | shl ecx, 8 |
163 | shl ecx, 8 |
Line -... | Line 164... | ||
- | 164 | mov eax, [ecx+SLOT_BASE+APPDATA.fpu_state] |
|
164 | mov eax, [ecx+SLOT_BASE+APPDATA.fpu_state] |
165 | |
165 | 166 | call save_context |
|
166 | call save_context |
167 | |
167 | 168 | ; first 512 bytes of XSAVE area have the same format as FXSAVE |
|
168 | shl esi, 8 |
169 | shl esi, 8 |
Line 176... | Line 177... | ||
176 | pop edi |
177 | pop edi |
177 | pop esi |
178 | pop esi |
178 | pop ecx |
179 | pop ecx |
179 | ret |
180 | ret |
Line -... | Line 181... | ||
- | 181 | ||
- | 182 | avx_save_size: |
|
- | 183 | mov eax, [xsave_area_size] |
|
- | 184 | ret |
|
- | 185 | ||
- | 186 | ; param |
|
- | 187 | ; eax= avx_save_size() bytes memory area aligned on a 64-byte boundary |
|
- | 188 | ||
- | 189 | avx_save: |
|
- | 190 | push ecx |
|
- | 191 | push esi |
|
- | 192 | push edi |
|
- | 193 | ||
- | 194 | pushfd |
|
- | 195 | cli |
|
- | 196 | ||
- | 197 | clts |
|
- | 198 | mov edi, eax |
|
- | 199 | ||
- | 200 | mov ecx, [fpu_owner] |
|
- | 201 | mov esi, [CURRENT_TASK] |
|
- | 202 | cmp ecx, esi |
|
- | 203 | jne .save |
|
- | 204 | ||
- | 205 | call save_context |
|
- | 206 | jmp .exit |
|
- | 207 | .save: |
|
- | 208 | mov [fpu_owner], esi |
|
- | 209 | ||
- | 210 | shl ecx, 8 |
|
- | 211 | mov eax, [ecx+SLOT_BASE+APPDATA.fpu_state] |
|
- | 212 | ||
- | 213 | call save_context |
|
- | 214 | ||
- | 215 | shl esi, 8 |
|
- | 216 | mov esi, [esi+SLOT_BASE+APPDATA.fpu_state] |
|
- | 217 | mov ecx, [xsave_area_size] |
|
- | 218 | add ecx, 3 |
|
- | 219 | shr ecx, 2 |
|
- | 220 | rep movsd |
|
- | 221 | fninit |
|
- | 222 | .exit: |
|
- | 223 | popfd |
|
- | 224 | pop edi |
|
- | 225 | pop esi |
|
- | 226 | pop ecx |
|
- | 227 | ret |
|
180 | 228 | ||
181 | align 4 |
229 | align 4 |
182 | save_context: |
230 | save_context: |
183 | bt [cpu_caps+(CAPS_OSXSAVE/8)], CAPS_OSXSAVE mod 8 |
231 | bt [cpu_caps+(CAPS_OSXSAVE/32)], CAPS_OSXSAVE mod 32 |
184 | jnc .no_xsave |
232 | jnc save_fpu_context |
185 | xsave [eax] |
233 | xsave [eax] |
186 | ret |
234 | ret |
187 | .no_xsave: |
235 | save_fpu_context: |
188 | bt [cpu_caps], CAPS_SSE |
236 | bt [cpu_caps], CAPS_SSE |
189 | jnc .no_SSE |
- | |
190 | 237 | jnc .no_SSE |
|
191 | fxsave [eax] |
238 | fxsave [eax] |
192 | ret |
239 | ret |
193 | .no_SSE: |
240 | .no_SSE: |
194 | fnsave [eax] |
241 | fnsave [eax] |
Line -... | Line 242... | ||
- | 242 | ret |
|
195 | ret |
243 | |
196 | 244 | ||
197 | align 4 |
245 | align 4 |
198 | fpu_restore: |
246 | fpu_restore: |
Line 208... | Line 256... | ||
208 | mov eax, [CURRENT_TASK] |
256 | mov eax, [CURRENT_TASK] |
209 | cmp ecx, eax |
257 | cmp ecx, eax |
210 | jne .copy |
258 | jne .copy |
Line 211... | Line 259... | ||
211 | 259 | ||
- | 260 | clts |
|
- | 261 | bt [cpu_caps], CAPS_SSE |
|
- | 262 | jnc .no_SSE |
|
- | 263 | ||
- | 264 | fxrstor [esi] |
|
- | 265 | popfd |
|
- | 266 | pop esi |
|
- | 267 | pop ecx |
|
- | 268 | ret |
|
- | 269 | .no_SSE: |
|
- | 270 | fnclex ;fix possible problems |
|
- | 271 | frstor [esi] |
|
- | 272 | popfd |
|
- | 273 | pop esi |
|
- | 274 | pop ecx |
|
- | 275 | ret |
|
- | 276 | .copy: |
|
- | 277 | shl eax, 8 |
|
- | 278 | mov edi, [eax+SLOT_BASE+APPDATA.fpu_state] |
|
- | 279 | mov ecx, 512/4 |
|
- | 280 | cld |
|
- | 281 | rep movsd |
|
- | 282 | popfd |
|
- | 283 | pop esi |
|
- | 284 | pop ecx |
|
- | 285 | ret |
|
- | 286 | ||
- | 287 | avx_restore: |
|
- | 288 | push ecx |
|
- | 289 | push esi |
|
- | 290 | ||
- | 291 | mov esi, eax |
|
- | 292 | ||
- | 293 | pushfd |
|
- | 294 | cli |
|
- | 295 | ||
- | 296 | mov ecx, [fpu_owner] |
|
- | 297 | mov eax, [CURRENT_TASK] |
|
- | 298 | cmp ecx, eax |
|
- | 299 | jne .copy |
|
- | 300 | ||
212 | clts |
301 | clts |
213 | bt [cpu_caps+(CAPS_OSXSAVE/8)], CAPS_OSXSAVE mod 8 |
302 | bt [cpu_caps+(CAPS_OSXSAVE/32)], CAPS_OSXSAVE mod 32 |
214 | jnc .no_xsave |
303 | jnc .no_xsave |
215 | xrstor [esi] |
304 | xrstor [esi] |
216 | popfd |
305 | popfd |
217 | pop esi |
306 | pop esi |
Line 234... | Line 323... | ||
234 | pop ecx |
323 | pop ecx |
235 | ret |
324 | ret |
236 | .copy: |
325 | .copy: |
237 | shl eax, 8 |
326 | shl eax, 8 |
238 | mov edi, [eax+SLOT_BASE+APPDATA.fpu_state] |
327 | mov edi, [eax+SLOT_BASE+APPDATA.fpu_state] |
- | 328 | mov ecx, [xsave_area_size] |
|
- | 329 | add ecx, 3 |
|
239 | mov ecx, 512/4 |
330 | shr ecx, 2 |
240 | cld |
331 | cld |
241 | rep movsd |
332 | rep movsd |
242 | popfd |
333 | popfd |
243 | pop esi |
334 | pop esi |
244 | pop ecx |
335 | pop ecx |
Line 256... | Line 347... | ||
256 | cmp ebx, [CURRENT_TASK] |
347 | cmp ebx, [CURRENT_TASK] |
257 | je .exit |
348 | je .exit |
Line 258... | Line 349... | ||
258 | 349 | ||
259 | shl ebx, 8 |
350 | shl ebx, 8 |
- | 351 | mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state] |
|
- | 352 | bt [cpu_caps+(CAPS_OSXSAVE/32)], CAPS_OSXSAVE mod 32 |
|
- | 353 | jnc .no_xsave |
|
- | 354 | xsave [eax] |
|
- | 355 | mov ebx, [CURRENT_TASK] |
|
- | 356 | mov [fpu_owner], ebx |
|
- | 357 | shl ebx, 8 |
|
- | 358 | mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state] |
|
- | 359 | xrstor [eax] |
|
- | 360 | .exit: |
|
- | 361 | restore_ring3_context |
|
- | 362 | iret |
|
260 | mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state] |
363 | .no_xsave: |
261 | bt [cpu_caps], CAPS_SSE |
364 | bt [cpu_caps], CAPS_SSE |
Line 262... | Line 365... | ||
262 | jnc .no_SSE |
365 | jnc .no_SSE |
263 | 366 | ||
264 | fxsave [eax] |
367 | fxsave [eax] |
265 | mov ebx, [CURRENT_TASK] |
368 | mov ebx, [CURRENT_TASK] |
266 | mov [fpu_owner], ebx |
369 | mov [fpu_owner], ebx |
267 | shl ebx, 8 |
370 | shl ebx, 8 |
268 | mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state] |
- | |
269 | fxrstor [eax] |
371 | mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state] |
270 | .exit: |
372 | fxrstor [eax] |
Line 271... | Line 373... | ||
271 | restore_ring3_context |
373 | restore_ring3_context |
272 | iret |
374 | iret |