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