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 | /* Safe abort routine & timer asm handler */ |
||
23 | |||
24 | .title "VmCx32a.S" |
||
25 | |||
26 | #include <ll/i386/sel.h> |
||
27 | #include <ll/i386/linkage.h> |
||
28 | #include <ll/i386/defs.h> |
||
29 | |||
30 | #include <ll/sys/ll/exc.h> |
||
31 | |||
32 | .data |
||
33 | |||
34 | ASMFILE(Context) |
||
35 | |||
36 | .extern JmpSel |
||
37 | .extern JmpZone |
||
38 | .globl SYMBOL_NAME(ll_clock) |
||
39 | .globl SYMBOL_NAME(SafeStack) |
||
40 | |||
41 | /* Used as JMP entry point to check if a real */ |
||
42 | /* context switch is necessary */ |
||
43 | |||
44 | SYMBOL_NAME_LABEL(ll_clock) .int 0 |
||
45 | |||
46 | /* Safe stack area for aborts */ |
||
47 | .space 4096,0 |
||
48 | SYMBOL_NAME_LABEL(SafeStack) |
||
49 | |||
50 | .extern SYMBOL_NAME(periodic_wake_up) |
||
51 | .extern SYMBOL_NAME(oneshot_wake_up) |
||
52 | .extern SYMBOL_NAME(act_int) |
||
53 | .extern SYMBOL_NAME(abort_tail) |
||
54 | |||
55 | .text |
||
56 | .globl SYMBOL_NAME(ll_timer) |
||
57 | .globl SYMBOL_NAME(ll_abort) |
||
58 | |||
59 | SYMBOL_NAME_LABEL(ll_abort) |
||
60 | /* As we are terminating we cannnot handle */ |
||
61 | /* any other interrupt! */ |
||
62 | cli |
||
63 | /* Get argument */ |
||
64 | movl 4(%esp),%eax |
||
65 | /* Switch to safe stack */ |
||
66 | movl $(SYMBOL_NAME(SafeStack)),%esp |
||
67 | /* Push argument */ |
||
68 | pushl %eax |
||
69 | /* Call sys_abort(code) */ |
||
70 | call SYMBOL_NAME(abort_tail) |
||
71 | |||
72 | /* This is the timer handler; it reloads for safety the DS register; this */ |
||
73 | /* prevents from mess when timer interrupts linear access to memory (not in */ |
||
74 | /* ELF address space); then EOI is sent in order to detect timer overrun */ |
||
75 | /* The high level kernel procedure wake_up() is called to perform the */ |
||
76 | /* preeption at higher level (process descriptos); the resulting context */ |
||
77 | /* if different from the old one is used to trigger the task activation. */ |
||
78 | |||
79 | SYMBOL_NAME_LABEL(ll_timer) |
||
80 | pushal |
||
81 | pushw %ds |
||
82 | pushw %es |
||
83 | pushw %fs |
||
84 | pushw %gs |
||
85 | |||
86 | movw $(X_FLATDATA_SEL),%ax |
||
87 | movw %ax,%ds |
||
88 | movw %ax,%es |
||
89 | |||
90 | /* Send EOI to master PIC */ |
||
91 | /* to perform later the overrun test */ |
||
92 | movb $0x20,%al |
||
93 | movl $0x20,%edx |
||
94 | outb %al,%dx |
||
95 | |||
96 | /* Call wake_up(actual_context) */ |
||
97 | |||
98 | cld |
||
99 | movl SYMBOL_NAME(ll_clock),%eax |
||
100 | incl %eax |
||
101 | movl %eax,SYMBOL_NAME(ll_clock) |
||
102 | |||
103 | xorl %eax,%eax |
||
104 | #if 0 |
||
105 | strw %ax |
||
106 | pushl %eax |
||
107 | call SYMBOL_NAME(wake_up) |
||
108 | addl $4,%esp |
||
109 | pushl %eax /* Save result on stack */ |
||
110 | |||
111 | #else |
||
112 | movl SYMBOL_NAME(timermode), %eax |
||
113 | cmpl $1, %eax |
||
114 | je oneshot |
||
115 | call SYMBOL_NAME(periodic_wake_up) |
||
116 | jmp goon |
||
117 | oneshot: call SYMBOL_NAME(oneshot_wake_up) |
||
118 | goon: |
||
119 | #endif |
||
120 | /* This is the overrun test */ |
||
121 | /* Do it after sending EOI to master PIC */ |
||
122 | |||
123 | movb $0x0A,%al |
||
124 | movl $0x020,%edx |
||
125 | outb %al,%dx |
||
126 | inb %dx,%al |
||
127 | testb $1,%al |
||
128 | jz Timer_OK |
||
129 | movl $(CLOCK_OVERRUN),%eax |
||
130 | pushl %eax |
||
131 | call SYMBOL_NAME(ll_abort) |
||
132 | |||
133 | #ifdef __VIRCSW__ |
||
134 | Timer_OK: |
||
135 | |||
136 | movw SYMBOL_NAME(currCtx), %ax |
||
137 | cmpw %ax,JmpSel |
||
138 | je NoPreempt2 |
||
139 | movw %ax,JmpSel |
||
140 | ljmp JmpZone /* DISPATCH! */ |
||
141 | #else |
||
142 | Timer_OK: |
||
143 | #endif |
||
144 | NoPreempt2: |
||
145 | popw %gs |
||
146 | popw %fs |
||
147 | popw %es |
||
148 | popw %ds |
||
149 | popal |
||
150 | iret |