Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | |
2 | /* Project: OSLib |
||
3 | * Description: The OS Construction Kit |
||
4 | * Date: 1.6.2000 |
||
5 | * Idea by: Luca Abeni & Gerardo Lamastra |
||
6 | * |
||
7 | * OSLib is an SO project aimed at developing a common, easy-to-use |
||
8 | * low-level infrastructure for developing OS kernels and Embedded |
||
9 | * Applications; it partially derives from the HARTIK project but it |
||
10 | * currently is independently developed. |
||
11 | * |
||
12 | * OSLib is distributed under GPL License, and some of its code has |
||
13 | * been derived from the Linux kernel source; also some important |
||
14 | * ideas come from studying the DJGPP go32 extender. |
||
15 | * |
||
16 | * We acknowledge the Linux Community, Free Software Foundation, |
||
17 | * D.J. Delorie and all the other developers who believe in the |
||
18 | * freedom of software and ideas. |
||
19 | * |
||
20 | * For legalese, check out the included GPL license. |
||
21 | */ |
||
22 | |||
23 | /* |
||
24 | FPU Context switch & management functions! |
||
25 | Generic 32 bit module |
||
26 | */ |
||
27 | |||
28 | #include <ll/i386/hw-data.h> |
||
29 | #include <ll/i386/hw-instr.h> |
||
30 | #include <ll/i386/mem.h> |
||
31 | |||
32 | #include <ll/i386/tss-ctx.h> |
||
33 | |||
34 | FILE(FPU); |
||
35 | |||
36 | extern TSS TSS_table[]; |
||
37 | |||
38 | BYTE LL_FPU_savearea[FPU_CONTEXT_SIZE]; /* Global FPU scratch SaveArea */ |
||
39 | #ifdef __FPU_DEBUG__ |
||
40 | long int ndp_called = 0, ndp_switched = 0; |
||
41 | #endif |
||
42 | |||
43 | /* FPU context management */ |
||
44 | static CONTEXT LL_has_FPU = TSSMain; |
||
45 | |||
46 | /* As the 8086 does not have an hardware mechanism to support task */ |
||
47 | /* switch, also the FPU context switch is implemented via software. */ |
||
48 | /* When a preemption occurs, if the task is marked as a MATH task, the */ |
||
49 | /* preemption routine will save/restore the FPU context. */ |
||
50 | /* The hook is called whenever a FPU context switch is necessarty */ |
||
51 | |||
52 | void ll_FPU_hook(void) |
||
53 | { |
||
54 | clts(); |
||
55 | #ifdef __FPU_DEBUG__ |
||
56 | ndp_called++; |
||
57 | #endif |
||
58 | if (LL_has_FPU == TSSsel2index(get_TR())) |
||
59 | return; |
||
60 | #ifdef __FPU_DEBUG__ |
||
61 | ndp_switched++; |
||
62 | #endif |
||
63 | |||
64 | #if 0 |
||
65 | LL_FPU_save(); |
||
66 | memcpy(TSS_table[LL_has_FPU].ctx_FPU, LL_FPU_savearea, |
||
67 | FPU_CONTEXT_SIZE); |
||
68 | #else |
||
69 | save_fpu(&(TSS_table[LL_has_FPU])); |
||
70 | #endif |
||
71 | |||
72 | LL_has_FPU = TSSsel2index(get_TR()); |
||
73 | |||
74 | #if 1 |
||
75 | memcpy(LL_FPU_savearea, TSS_table[LL_has_FPU].ctx_FPU, |
||
76 | FPU_CONTEXT_SIZE); |
||
77 | LL_FPU_restore(); |
||
78 | #else |
||
79 | restore_fpu(&(TSS_table[LL_has_FPU])); |
||
80 | #endif |
||
81 | return; |
||
82 | } |
||
83 | |||
84 | CONTEXT LL_FPU_get_task(void) |
||
85 | { |
||
86 | return (LL_has_FPU); |
||
87 | } |