Subversion Repositories Kolibri OS

Rev

Rev 221 | Rev 378 | 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
 
39
proc fpu_save
40
           clts
41
           mov ebx, [fpu_owner]
42
           shl ebx, 8
43
           mov eax, [ebx+PROC_BASE+0x10]
44
           mov ebx, [CURRENT_TASK]
45
           mov [fpu_owner], ebx
46
47
 
221 serge 48
           jnc .no_SSE
214 serge 49
50
 
51
           fninit            ;re-init fpu
52
           ret
53
.no_SSE:
54
           fnsave [eax]
55
           ret
56
endp
57
58
 
59
proc fpu_restore
60
           mov ebx, [CURRENT_TASK]
61
           shl ebx, 8
62
           mov eax, [ebx+PROC_BASE+0x10]
63
           bt [cpu_caps], CAPS_SSE
221 serge 64
           jnc .no_SSE
214 serge 65
66
 
67
           ret
68
.no_SSE:
69
           fnclex               ;fix possible problems
70
           frstor [eax]
71
           ret
72
endp
73
74
 
75
e7:                        ;#NM exception handler
76
        save_ring3_context
77
        clts
78
        mov ax, os_data
79
        mov ds, ax
80
        mov es, ax
81
82
 
83
        cmp ebx, [CURRENT_TASK]
84
        je .exit
85
86
 
87
        mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
88
        bt [cpu_caps], CAPS_SSE
221 serge 89
        jnc .no_SSE
214 serge 90
91
 
92
        mov ebx, [CURRENT_TASK]
93
        mov [fpu_owner], ebx
94
        shl ebx, 8
95
        mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
96
        fxrstor [eax]
97
.exit:
98
        restore_ring3_context
99
        iret
100
101
 
102
        fnsave [eax]
103
        mov ebx, [CURRENT_TASK]
104
        mov [fpu_owner], ebx
105
        shl ebx, 8
106
        mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
107
        frstor [eax]
108
        restore_ring3_context
109
        iret
110
111
 
112
  fpu_owner dd 1
113
 endg
114
115
 
116
reg_cs        equ ebp+8
117
reg_eflags    equ ebp+12
118
reg_esp       equ ebp+16
119
reg_ss        equ ebp+20
120
121
 
122
except_16:           ;fpu native exceptions handler
123
           push ebp
124
           mov ebp, esp
125
126
 
127
           push ebx
128
           push ecx
129
           push edx
130
131
 
132
           shl ebx, 8
133
134
 
135
           test eax, eax
136
           jz .default
137
138
 
139
           mov edx, [reg_esp]
140
           sub edx, 4
141
           mov [ss:edx+new_app_base], ecx
142
           mov [reg_esp], edx
143
           mov dword [reg_eip], eax
144
145
 
146
           pop ecx
147
           pop ebx
148
           pop eax
149
150
 
151
           iretd
152
153
 
154
           pop edx
155
           pop ecx
156
           pop ebx
157
           pop eax
158
           leave
159
160
 
161
162
 
163
           jmp exc_c
164
165
 
166
except_19:          ;sse exceptions handler
167
           push ebp
168
           mov ebp, esp
169
170
 
171
           push ebx
172
           push ecx
173
           push edx
174
175
 
176
           shl ebx, 8
177
178
 
179
           test eax, eax
180
           jz .default
181
182
 
183
           mov edx, [reg_esp]
184
           sub edx, 4
185
           mov [ss:edx+new_app_base], ecx
186
           mov [reg_esp], edx
187
           mov dword [reg_eip], eax
188
189
 
190
           pop ecx
191
           pop ebx
192
           pop eax
193
194
 
195
           iretd
196
197
 
198
           pop edx
199
           pop ecx
200
           pop ebx
201
           pop eax
202
           leave
203
204
 
205
206
 
207
           jmp exc_c
208
209
 
210
restore reg_cs
211
restore reg_eflags
212
restore reg_esp
213
restore reg_ss
214