Subversion Repositories Kolibri OS

Rev

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