Subversion Repositories Kolibri OS

Rev

Rev 1 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ha 1
iglobal
2
  prev_user_of_fpu dd 0x1 ; set to OS
3
endg
4
 
5
label fpu_tss at 0xB080
6
label fpu_stack dword at 0xB060
7
 
8
 
9
align 4
10
fpu_handler:
11
 
12
        ; clear TS flag in CR0 -> for task switching
13
        clts
14
 
15
        ; save FPU context of the previous task
16
        mov    eax,[prev_user_of_fpu]
17
        shl    eax,8
18
        add    eax,0x80000+0x10
19
        fsave  [eax]
20
 
21
        ; next task switch save our FPU context
22
        ; now restore context of current task (if exists)
23
        mov    eax,[0x3000]
24
        mov    [prev_user_of_fpu],eax
25
        shl    eax,8
26
        add    eax,0x80000
27
        cmp    [eax+0x7f],byte 0
28
        je     bs7_first_fpu
29
        frstor [eax+0x10]
30
      bs7_first_fpu:
31
        mov    [eax+0x7f],byte 1
32
 
33
        ; prepare structure in stack for proper IRET
34
        movzx  eax,word [fpu_tss+l.ss-tss_sceleton]  ; push ss
35
        push   eax
36
        mov    eax,[fpu_tss+l.esp-tss_sceleton]      ; push esp
37
        push   eax
38
        mov    eax,[fpu_tss+l.eflags-tss_sceleton]   ; push eflags
39
        push   eax
40
 
41
        movzx  eax,word [fpu_tss+l.cs-tss_sceleton]  ; push cs
42
        push   eax
43
        mov    eax,[fpu_tss+l.eip-tss_sceleton]      ; push eip
44
        push   eax
45
 
46
        ; save eax
47
        push   dword [fpu_tss+l.eax-tss_sceleton]
48
 
49
        ; restore all segment registers
50
        mov    ax,[fpu_tss+l.es-tss_sceleton]
51
        mov    es,ax
52
        mov    ax,[fpu_tss+l.fs-tss_sceleton]
53
        mov    fs,ax
54
        mov    ax,[fpu_tss+l.gs-tss_sceleton]
55
        mov    gs,ax
56
        mov    ax,[fpu_tss+l.ds-tss_sceleton]
57
        mov    ds,ax
58
 
59
        ; restore eax
60
        pop    eax
61
 
62
        iret