2007-03-26 14:18:08 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2006-11-20 08:06:00 +01:00
|
|
|
|
2007-07-27 15:52:03 +02:00
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
2006-11-20 08:06:00 +01:00
|
|
|
init_fpu:
|
|
|
|
clts
|
|
|
|
fninit
|
|
|
|
|
2006-11-27 11:07:51 +01:00
|
|
|
bt [cpu_caps], CAPS_SSE
|
|
|
|
jnc .no_SSE
|
2006-11-20 08:06:00 +01:00
|
|
|
|
|
|
|
mov ebx, cr4
|
|
|
|
mov ecx, cr0
|
|
|
|
or ebx, CR4_OSFXSR+CR4_OSXMMEXPT
|
|
|
|
mov cr4, ebx
|
|
|
|
|
|
|
|
and ecx, not (CR0_MP+CR0_EM)
|
|
|
|
or ecx, CR0_NE
|
|
|
|
mov cr0, ecx
|
|
|
|
|
|
|
|
mov dword [esp-4], SSE_INIT
|
|
|
|
ldmxcsr [esp-4]
|
|
|
|
|
|
|
|
xorps xmm0, xmm0
|
|
|
|
xorps xmm1, xmm1
|
|
|
|
xorps xmm2, xmm2
|
|
|
|
xorps xmm3, xmm3
|
|
|
|
xorps xmm4, xmm4
|
|
|
|
xorps xmm5, xmm5
|
|
|
|
xorps xmm6, xmm6
|
|
|
|
xorps xmm7, xmm7
|
2007-02-17 11:09:23 +01:00
|
|
|
fxsave [fpu_data] ;[eax]
|
2006-11-20 08:06:00 +01:00
|
|
|
ret
|
2006-11-27 11:07:51 +01:00
|
|
|
.no_SSE:
|
2006-11-20 08:06:00 +01:00
|
|
|
mov ecx, cr0
|
|
|
|
and ecx, not CR0_EM
|
|
|
|
or ecx, CR0_MP+CR0_NE
|
|
|
|
mov cr0, ecx
|
2007-02-17 11:09:23 +01:00
|
|
|
fnsave [fpu_data]
|
2006-11-20 08:06:00 +01:00
|
|
|
ret
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
; param
|
|
|
|
; eax= 512 bytes memory area
|
|
|
|
|
2006-11-20 08:06:00 +01:00
|
|
|
align 4
|
2007-02-27 12:47:52 +01:00
|
|
|
fpu_save:
|
|
|
|
push ecx
|
|
|
|
push esi
|
|
|
|
push edi
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
|
2006-11-20 08:06:00 +01:00
|
|
|
clts
|
2007-02-27 12:47:52 +01:00
|
|
|
mov edi, eax
|
|
|
|
|
|
|
|
mov ecx, [fpu_owner]
|
2007-03-28 19:06:08 +02:00
|
|
|
mov esi, [CURRENT_TASK]
|
|
|
|
cmp ecx, esi
|
2007-02-27 12:47:52 +01:00
|
|
|
jne .save
|
2007-03-28 19:06:08 +02:00
|
|
|
|
|
|
|
call save_context
|
|
|
|
jmp .exit
|
|
|
|
.save:
|
|
|
|
mov [fpu_owner], esi
|
|
|
|
|
|
|
|
shl ecx, 8
|
|
|
|
mov eax, [ecx+SLOT_BASE+APPDATA.fpu_state]
|
|
|
|
|
|
|
|
call save_context
|
|
|
|
|
|
|
|
shl esi, 8
|
|
|
|
mov esi, [esi+SLOT_BASE+APPDATA.fpu_state]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ecx, 512/4
|
|
|
|
cld
|
|
|
|
rep movsd
|
|
|
|
fninit
|
2007-03-28 19:06:08 +02:00
|
|
|
.exit:
|
2007-02-27 12:47:52 +01:00
|
|
|
popfd
|
|
|
|
pop edi
|
|
|
|
pop esi
|
|
|
|
pop ecx
|
|
|
|
ret
|
2006-11-20 08:06:00 +01:00
|
|
|
|
2007-03-28 19:06:08 +02:00
|
|
|
align 4
|
|
|
|
save_context:
|
2006-11-27 11:07:51 +01:00
|
|
|
bt [cpu_caps], CAPS_SSE
|
2006-11-20 08:06:00 +01:00
|
|
|
jnc .no_SSE
|
|
|
|
|
2007-03-28 19:06:08 +02:00
|
|
|
fxsave [eax]
|
|
|
|
ret
|
2006-11-20 08:06:00 +01:00
|
|
|
.no_SSE:
|
2007-03-28 19:06:08 +02:00
|
|
|
fnsave [eax]
|
|
|
|
ret
|
2006-11-20 08:06:00 +01:00
|
|
|
|
|
|
|
align 4
|
2007-02-27 12:47:52 +01:00
|
|
|
fpu_restore:
|
|
|
|
push ecx
|
|
|
|
push esi
|
|
|
|
|
|
|
|
mov esi, eax
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
|
|
|
|
mov ecx, [fpu_owner]
|
|
|
|
mov eax, [CURRENT_TASK]
|
|
|
|
cmp ecx, eax
|
|
|
|
jne .copy
|
|
|
|
|
|
|
|
clts
|
2006-11-27 11:07:51 +01:00
|
|
|
bt [cpu_caps], CAPS_SSE
|
2006-11-20 08:06:00 +01:00
|
|
|
jnc .no_SSE
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
fxrstor [esi]
|
|
|
|
popfd
|
|
|
|
pop esi
|
|
|
|
pop ecx
|
2006-11-20 08:06:00 +01:00
|
|
|
ret
|
|
|
|
.no_SSE:
|
|
|
|
fnclex ;fix possible problems
|
2007-02-27 12:47:52 +01:00
|
|
|
frstor [esi]
|
|
|
|
popfd
|
|
|
|
pop esi
|
|
|
|
pop ecx
|
|
|
|
ret
|
|
|
|
.copy:
|
|
|
|
shl eax, 8
|
2007-02-28 11:51:05 +01:00
|
|
|
mov edi, [eax+SLOT_BASE+APPDATA.fpu_state]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ecx, 512/4
|
|
|
|
cld
|
|
|
|
rep movsd
|
|
|
|
popfd
|
|
|
|
pop esi
|
|
|
|
pop ecx
|
2006-11-20 08:06:00 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
align 4
|
2009-04-04 21:58:42 +02:00
|
|
|
except_7: ;#NM exception handler
|
2007-04-18 08:37:14 +02:00
|
|
|
save_ring3_context
|
|
|
|
clts
|
|
|
|
mov ax, app_data ;
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
|
|
|
|
mov ebx, [fpu_owner]
|
|
|
|
cmp ebx, [CURRENT_TASK]
|
|
|
|
je .exit
|
|
|
|
|
|
|
|
shl ebx, 8
|
|
|
|
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
|
|
|
|
bt [cpu_caps], CAPS_SSE
|
|
|
|
jnc .no_SSE
|
|
|
|
|
|
|
|
fxsave [eax]
|
|
|
|
mov ebx, [CURRENT_TASK]
|
|
|
|
mov [fpu_owner], ebx
|
|
|
|
shl ebx, 8
|
|
|
|
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
|
|
|
|
fxrstor [eax]
|
2006-11-20 08:06:00 +01:00
|
|
|
.exit:
|
2007-04-18 08:37:14 +02:00
|
|
|
restore_ring3_context
|
|
|
|
iret
|
2006-11-20 08:06:00 +01:00
|
|
|
|
|
|
|
.no_SSE:
|
2007-04-18 08:37:14 +02:00
|
|
|
fnsave [eax]
|
|
|
|
mov ebx, [CURRENT_TASK]
|
|
|
|
mov [fpu_owner], ebx
|
|
|
|
shl ebx, 8
|
|
|
|
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
|
|
|
|
frstor [eax]
|
|
|
|
restore_ring3_context
|
|
|
|
iret
|
2006-11-20 08:06:00 +01:00
|
|
|
|
|
|
|
iglobal
|
2008-02-04 16:31:59 +01:00
|
|
|
fpu_owner dd 0
|
2009-04-04 21:58:42 +02:00
|
|
|
endg
|