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