Details | 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 | /* Context switch code */ |
||
23 | |||
24 | #include <ll/i386/sel.h> |
||
25 | #include <ll/i386/linkage.h> |
||
26 | #include <ll/i386/defs.h> |
||
27 | |||
28 | #include <ll/sys/ll/exc.h> |
||
29 | |||
30 | .data |
||
31 | |||
32 | ASMFILE(Context) |
||
33 | |||
34 | .globl SYMBOL_NAME(currCtx) |
||
35 | .globl JmpSel |
||
36 | .globl JmpZone |
||
37 | |||
38 | SYMBOL_NAME_LABEL(currCtx) .word 0 |
||
39 | |||
40 | JmpZone: |
||
41 | JmpOffset: |
||
42 | .word 0 |
||
43 | .word 0 |
||
44 | JmpSel: |
||
45 | .word 0 |
||
46 | |||
47 | .text |
||
48 | |||
49 | .globl SYMBOL_NAME(context_save) |
||
50 | .globl SYMBOL_NAME(context_change) |
||
51 | .globl SYMBOL_NAME(context_load) |
||
52 | .globl SYMBOL_NAME(init_TR) |
||
53 | |||
54 | /* This function assign a value to the TASK register of 386 architecture */ |
||
55 | /* We MUST do this BEFORE we use the HW multitask */ |
||
56 | |||
57 | SYMBOL_NAME_LABEL(init_TR) |
||
58 | pushl %ebp |
||
59 | movl %esp,%ebp |
||
60 | movl 8(%ebp),%eax |
||
61 | ltrw %ax |
||
62 | movw %ax,JmpSel |
||
63 | movw %ax,SYMBOL_NAME(currCtx) |
||
64 | popl %ebp |
||
65 | ret |
||
66 | |||
67 | /* CONTEXT __cdecl context_save(void); */ |
||
68 | /* The context is returned into AX; Interrupts are also cleared as we are */ |
||
69 | /* entering into kernel primitives */ |
||
70 | |||
71 | SYMBOL_NAME_LABEL(context_save) |
||
72 | xorl %eax,%eax |
||
73 | strw %ax |
||
74 | ret |
||
75 | |||
76 | /* void __cdecl context_change(CONTEXT c) */ |
||
77 | /* Use 386 task switch ability. This is the last call of any preemption */ |
||
78 | /* generating primitive; when the original task is re-activated the */ |
||
79 | /* interrupt flag is restored with STI */ |
||
80 | /* In 32 bit systems, context_load is an alias for context_change!*/ |
||
81 | |||
82 | SYMBOL_NAME_LABEL(context_load) |
||
83 | SYMBOL_NAME_LABEL(context_change) |
||
84 | pushl %ebp |
||
85 | movl %esp,%ebp |
||
86 | movw $(X_FLATDATA_SEL),%ax |
||
87 | movw %ax,%ds |
||
88 | movw %ax,%es |
||
89 | movl 8(%ebp),%eax |
||
90 | cmpw JmpSel,%ax |
||
91 | je NoPreempt |
||
92 | movw %ax,JmpSel |
||
93 | ljmp JmpZone |
||
94 | NoPreempt: popl %ebp |
||
95 | ret |
||
96 |