Rev 1066 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1066 | Rev 2971 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; MenuetOS process management, protected ring3 ;; |
7 | ;; MenuetOS process management, protected ring3 ;; |
8 | ;; ;; |
8 | ;; ;; |
9 | ;; Distributed under GPL. See file COPYING for details. ;; |
9 | ;; Distributed under GPL. See file COPYING for details. ;; |
10 | ;; Copyright 2003 Ville Turjanmaa ;; |
10 | ;; Copyright 2003 Ville Turjanmaa ;; |
11 | ;; ;; |
11 | ;; ;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
13 | 13 | ||
14 | $Revision: 1066 $ |
14 | $Revision: 2971 $ |
15 | 15 | ||
16 | align 4 |
16 | align 4 |
17 | init_idt: |
17 | init_idt: |
18 | push edi |
18 | push edi |
19 | push esi |
19 | push esi |
20 | mov edi, idts |
20 | mov edi, idts |
21 | mov dword [idtreg+2], edi |
21 | mov dword [idtreg+2], edi |
22 | 22 | ||
23 | mov esi, sys_int |
23 | mov esi, sys_int |
24 | mov ecx, 0x40 |
24 | mov ecx, 0x40 |
25 | @@: |
25 | @@: |
26 | lodsd |
26 | lodsd |
27 | mov [edi], ax ; lower part of offset |
27 | mov [edi], ax ; lower part of offset |
28 | mov [edi+2], word sel_os_code ; segment selector |
28 | mov [edi+2], word sel_os_code ; segment selector |
29 | mov ax, word 10001110b shl 8 ; type: interrupt gate |
29 | mov ax, word 10001110b shl 8 ; type: interrupt gate |
30 | mov [edi+4], eax |
30 | mov [edi+4], eax |
31 | add edi, 8 |
31 | add edi, 8 |
32 | loop @b |
32 | loop @b |
33 | 33 | ||
34 | mov eax, _i40 |
34 | mov eax, _i40 |
35 | mov ecx, _i40 |
35 | mov ecx, _i40 |
36 | and eax, 0x0000FFFF |
36 | and eax, 0x0000FFFF |
37 | and ecx, 0xFFFF0000 |
37 | and ecx, 0xFFFF0000 |
38 | or eax, sel_app_code shl 16 |
38 | or eax, sel_app_code shl 16 |
39 | or ecx, (11101111b shl 8) |
39 | or ecx, (11101111b shl 8) |
40 | mov [edi], eax |
40 | mov [edi], eax |
41 | mov [edi+4], ecx |
41 | mov [edi+4], ecx |
42 | 42 | ||
43 | mov eax, i41 |
43 | mov eax, i41 |
44 | mov ecx, i41 |
44 | mov ecx, i41 |
45 | and eax, 0x0000FFFF |
45 | and eax, 0x0000FFFF |
46 | and ecx, 0xFFFF0000 |
46 | and ecx, 0xFFFF0000 |
47 | or eax, sel_os_code shl 16 |
47 | or eax, sel_os_code shl 16 |
48 | or ecx, (11101111b shl 8) |
48 | or ecx, (11101111b shl 8) |
49 | mov [edi+8], eax |
49 | mov [edi+8], eax |
50 | mov [edi+12], ecx |
50 | mov [edi+12], ecx |
51 | 51 | ||
52 | lidt [idtreg] |
52 | lidt [idtreg] |
53 | pop esi |
53 | pop esi |
54 | pop edi |
54 | pop edi |
55 | ret |
55 | ret |
56 | 56 | ||
57 | iglobal |
57 | iglobal |
58 | 58 | ||
59 | msg_sel_ker db "kernel", 0 |
59 | msg_sel_ker db "kernel", 0 |
60 | msg_sel_app db "application", 0 |
60 | msg_sel_app db "application", 0 |
61 | 61 | ||
62 | align 4 |
62 | align 4 |
63 | 63 | ||
64 | sys_int: |
64 | sys_int: |
65 | dd e0,debug_exc,e2,e3 |
65 | dd e0,debug_exc,e2,e3 |
66 | dd e4,e5,e6,e7 |
66 | dd e4,e5,e6,e7 |
67 | dd e8,e9,e10,e11 |
67 | dd e8,e9,e10,e11 |
68 | dd e12,e13,page_fault_handler,e15 |
68 | dd e12,e13,page_fault_handler,e15 |
69 | 69 | ||
70 | dd except_16, e17,e18, except_19 |
70 | dd except_16, e17,e18, except_19 |
71 | times 12 dd unknown_interrupt |
71 | times 12 dd unknown_interrupt |
72 | 72 | ||
73 | dd irq0, irq_serv.irq_1, irq_serv.irq_2 |
73 | dd irq0, irq_serv.irq_1, irq_serv.irq_2 |
74 | if USE_COM_IRQ |
74 | if USE_COM_IRQ |
75 | dd irq_serv.irq_3, irq_serv.irq_4 |
75 | dd irq_serv.irq_3, irq_serv.irq_4 |
76 | else |
76 | else |
77 | dd p_irq3, p_irq4 |
77 | dd p_irq3, p_irq4 |
78 | end if |
78 | end if |
79 | dd irq_serv.irq_5, p_irq6, irq_serv.irq_7 |
79 | dd irq_serv.irq_5, p_irq6, irq_serv.irq_7 |
80 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
80 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
81 | dd irq_serv.irq_11, irq_serv.irq_12,irqD ,p_irq14,p_irq15 |
81 | dd irq_serv.irq_11, irq_serv.irq_12,irqD ,p_irq14,p_irq15 |
82 | 82 | ||
83 | times 16 dd unknown_interrupt |
83 | times 16 dd unknown_interrupt |
84 | 84 | ||
85 | dd i41 |
85 | dd i41 |
86 | 86 | ||
87 | idtreg: |
87 | idtreg: |
88 | dw 8*0x42-1 |
88 | dw 8*0x42-1 |
89 | dd idts |
89 | dd idts |
90 | 90 | ||
91 | endg |
91 | endg |
92 | 92 | ||
93 | macro save_ring3_context |
93 | macro save_ring3_context |
94 | { |
94 | { |
95 | pushad |
95 | pushad |
96 | } |
96 | } |
97 | macro restore_ring3_context |
97 | macro restore_ring3_context |
98 | { |
98 | { |
99 | popad |
99 | popad |
100 | } |
100 | } |
101 | 101 | ||
102 | ; simply return control to interrupted process |
102 | ; simply return control to interrupted process |
103 | unknown_interrupt: |
103 | unknown_interrupt: |
104 | iret |
104 | iret |
105 | 105 | ||
106 | macro exc_wo_code [num] |
106 | macro exc_wo_code [num] |
107 | { |
107 | { |
108 | forward |
108 | forward |
109 | e#num : |
109 | e#num : |
110 | save_ring3_context |
110 | save_ring3_context |
111 | mov bl, num |
111 | mov bl, num |
112 | jmp exc_c |
112 | jmp exc_c |
113 | } |
113 | } |
114 | 114 | ||
115 | macro exc_w_code [num] |
115 | macro exc_w_code [num] |
116 | { |
116 | { |
117 | forward |
117 | forward |
118 | e#num : |
118 | e#num : |
119 | add esp, 4 |
119 | add esp, 4 |
120 | save_ring3_context |
120 | save_ring3_context |
121 | mov bl, num |
121 | mov bl, num |
122 | jmp exc_c |
122 | jmp exc_c |
123 | } |
123 | } |
124 | 124 | ||
125 | exc_wo_code 0, 2, 3, 4, 5, 6, 9, 15, 18 |
125 | exc_wo_code 0, 2, 3, 4, 5, 6, 9, 15, 18 |
126 | exc_w_code 8, 10, 11, 12, 13, 14, 17 |
126 | exc_w_code 8, 10, 11, 12, 13, 14, 17 |
127 | 127 | ||
128 | align 4 |
128 | align 4 |
129 | exc_c: |
129 | exc_c: |
130 | mov ax, sel_app_data ;èñêëþ÷åíèå |
130 | mov ax, sel_app_data ;èñêëþ÷åíèå |
131 | mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíèÿ' |
131 | mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíèÿ' |
132 | mov es, ax ;â ðåãèñòðû |
132 | mov es, ax ;â ðåãèñòðû |
133 | 133 | ||
134 | ; redirect to V86 manager? (EFLAGS & 0x20000) != 0? |
134 | ; redirect to V86 manager? (EFLAGS & 0x20000) != 0? |
135 | test byte [esp+20h+8+2], 2 |
135 | test byte [esp+20h+8+2], 2 |
136 | jnz v86_exc_c |
136 | jnz v86_exc_c |
137 | 137 | ||
138 | ; test if debugging |
138 | ; test if debugging |
139 | cli |
139 | cli |
140 | mov eax, [current_slot] |
140 | mov eax, [current_slot] |
141 | mov eax, [eax+APPDATA.debugger_slot] |
141 | mov eax, [eax+APPDATA.debugger_slot] |
142 | test eax, eax |
142 | test eax, eax |
143 | jnz .debug |
143 | jnz .debug |
144 | sti |
144 | sti |
145 | ; not debuggee => say error and terminate |
145 | ; not debuggee => say error and terminate |
146 | movzx eax, bl |
146 | movzx eax, bl |
147 | mov [error_interrupt], eax |
147 | mov [error_interrupt], eax |
148 | call show_error_parameters |
148 | call show_error_parameters |
149 | add esp, 0x20 |
149 | add esp, 0x20 |
150 | mov edx, [TASK_BASE] |
150 | mov edx, [TASK_BASE] |
151 | mov [edx + TASKDATA.state], byte 4 |
151 | mov [edx + TASKDATA.state], byte 4 |
152 | 152 | ||
153 | jmp change_task |
153 | jmp change_task |
154 | 154 | ||
155 | .debug: |
155 | .debug: |
156 | ; we are debugged process, notify debugger and suspend ourself |
156 | ; we are debugged process, notify debugger and suspend ourself |
157 | ; eax=debugger PID |
157 | ; eax=debugger PID |
158 | cld |
158 | cld |
159 | movzx ecx, bl |
159 | movzx ecx, bl |
160 | push ecx |
160 | push ecx |
161 | mov ecx, [TASK_BASE] |
161 | mov ecx, [TASK_BASE] |
162 | push dword [ecx+TASKDATA.pid] ; PID of current process |
162 | push dword [ecx+TASKDATA.pid] ; PID of current process |
163 | push 12 |
163 | push 12 |
164 | pop ecx |
164 | pop ecx |
165 | push 1 ; 1=exception |
165 | push 1 ; 1=exception |
166 | call debugger_notify |
166 | call debugger_notify |
167 | pop ecx |
167 | pop ecx |
168 | pop ecx |
168 | pop ecx |
169 | pop ecx |
169 | pop ecx |
170 | mov edx, [TASK_BASE] |
170 | mov edx, [TASK_BASE] |
171 | mov byte [edx+TASKDATA.state], 1 ; suspended |
171 | mov byte [edx+TASKDATA.state], 1 ; suspended |
172 | call change_task |
172 | call change_task |
173 | restore_ring3_context |
173 | restore_ring3_context |
174 | iretd |
174 | iretd |
175 | 175 | ||
176 | iglobal |
176 | iglobal |
177 | hexletters db '0123456789ABCDEF' |
177 | hexletters db '0123456789ABCDEF' |
178 | error_interrupt dd -1 |
178 | error_interrupt dd -1 |
179 | endg |
179 | endg |
180 | 180 | ||
181 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
181 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
182 | show_error_parameters: |
182 | show_error_parameters: |
183 | mov eax,[CURRENT_TASK] |
183 | mov eax,[CURRENT_TASK] |
184 | shl eax, 5 |
184 | shl eax, 5 |
185 | DEBUGF 1, "K : Process - forced terminate PID: %x\n", [CURRENT_TASK + TASKDATA.pid + eax] |
185 | DEBUGF 1, "K : Process - forced terminate PID: %x\n", [CURRENT_TASK + TASKDATA.pid + eax] |
186 | mov eax, [error_interrupt] |
186 | mov eax, [error_interrupt] |
187 | cmp al, 0x08 |
187 | cmp al, 0x08 |
188 | jne @f |
188 | jne @f |
189 | DEBUGF 1, "K : Double fault\n" |
189 | DEBUGF 1, "K : Double fault\n" |
190 | jmp defined_error |
190 | jmp defined_error |
191 | @@: |
191 | @@: |
192 | cmp al, 0x0a |
192 | cmp al, 0x0a |
193 | jne @f |
193 | jne @f |
194 | DEBUGF 1, "K : Invalid TSS\n" |
194 | DEBUGF 1, "K : Invalid TSS\n" |
195 | jmp defined_error |
195 | jmp defined_error |
196 | @@: |
196 | @@: |
197 | cmp al, 0x0b |
197 | cmp al, 0x0b |
198 | jne @f |
198 | jne @f |
199 | DEBUGF 1, "K : Segment not present\n" |
199 | DEBUGF 1, "K : Segment not present\n" |
200 | jmp defined_error |
200 | jmp defined_error |
201 | @@: |
201 | @@: |
202 | cmp al, 0x0c |
202 | cmp al, 0x0c |
203 | jne @f |
203 | jne @f |
204 | DEBUGF 1, "K : Stack fault\n" |
204 | DEBUGF 1, "K : Stack fault\n" |
205 | jmp defined_error |
205 | jmp defined_error |
206 | @@: |
206 | @@: |
207 | cmp al, 0x0d |
207 | cmp al, 0x0d |
208 | jne @f |
208 | jne @f |
209 | DEBUGF 1, "K : General protection fault\n" |
209 | DEBUGF 1, "K : General protection fault\n" |
210 | jmp defined_error |
210 | jmp defined_error |
211 | @@: |
211 | @@: |
212 | cmp al, 0x0e |
212 | cmp al, 0x0e |
213 | jne @f |
213 | jne @f |
214 | DEBUGF 1, "K : Page fault\n" |
214 | DEBUGF 1, "K : Page fault\n" |
215 | jmp defined_error |
215 | jmp defined_error |
216 | @@: |
216 | @@: |
217 | DEBUGF 1, "K : Undefined Exception\n" |
217 | DEBUGF 1, "K : Undefined Exception\n" |
218 | defined_error: |
218 | defined_error: |
219 | DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [esp + 0x20], [esp - 12 + 0x20], [esp - 4 + 0x20] |
219 | DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [esp + 0x20], [esp - 12 + 0x20], [esp - 4 + 0x20] |
220 | DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [esp - 8 + 0x20], [esp - 24 + 0x20], [esp - 28 + 0x20] |
220 | DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [esp - 8 + 0x20], [esp - 24 + 0x20], [esp - 28 + 0x20] |
221 | DEBUGF 1, "K : EBP : %x EIP : %x ", [esp - 20 + 0x20], [esp + 4 + 0x20] |
221 | DEBUGF 1, "K : EBP : %x EIP : %x ", [esp - 20 + 0x20], [esp + 4 + 0x20] |
222 | 222 | ||
223 | mov eax, [esp + 8 + 0x20] |
223 | mov eax, [esp + 8 + 0x20] |
224 | mov edi, msg_sel_app |
224 | mov edi, msg_sel_app |
225 | mov ebx, [esp + 16 + 0x20] |
225 | mov ebx, [esp + 16 + 0x20] |
226 | cmp eax, sel_app_code |
226 | cmp eax, sel_app_code |
227 | je @f |
227 | je @f |
228 | mov edi, msg_sel_ker |
228 | mov edi, msg_sel_ker |
229 | mov ebx, [esp - 16 + 0x20] |
229 | mov ebx, [esp - 16 + 0x20] |
230 | @@: |
230 | @@: |
231 | DEBUGF 1, "ESP : %x\nK : Flags : %x CS : %x (%s)\n", ebx, [esp + 12 + 0x20], eax, edi |
231 | DEBUGF 1, "ESP : %x\nK : Flags : %x CS : %x (%s)\n", ebx, [esp + 12 + 0x20], eax, edi |
232 | ret |
232 | ret |
233 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
233 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
234 | 234 | ||
235 | 235 | ||
236 | ; irq1 -> hid/keyboard.inc |
236 | ; irq1 -> hid/keyboard.inc |
237 | macro irqh [num] |
237 | macro irqh [num] |
238 | { |
238 | { |
239 | forward |
239 | forward |
240 | p_irq#num : |
240 | p_irq#num : |
241 | mov edi, num |
241 | mov edi, num |
242 | jmp irqhandler |
242 | jmp irqhandler |
243 | } |
243 | } |
244 | 244 | ||
245 | irqh 2,3,4,5,7,8,9,10,11 |
245 | irqh 2,3,4,5,7,8,9,10,11 |
246 | 246 | ||
247 | 247 | ||
248 | p_irq6: |
248 | p_irq6: |
249 | save_ring3_context |
249 | save_ring3_context |
250 | mov ax, sel_app_data |
250 | mov ax, sel_app_data |
251 | mov ds, ax |
251 | mov ds, ax |
252 | mov es, ax |
252 | mov es, ax |
253 | call fdc_irq |
253 | call fdc_irq |
254 | call ready_for_next_irq |
254 | call ready_for_next_irq |
255 | restore_ring3_context |
255 | restore_ring3_context |
256 | iret |
256 | iret |
257 | 257 | ||
258 | 258 | ||
259 | p_irq14: |
259 | p_irq14: |
260 | save_ring3_context |
260 | save_ring3_context |
261 | mov ax, sel_app_data |
261 | mov ax, sel_app_data |
262 | mov ds, ax |
262 | mov ds, ax |
263 | mov es, ax |
263 | mov es, ax |
264 | mov byte [BOOT_VAR + 0x48E], 0xFF |
264 | mov byte [BOOT_VAR + 0x48E], 0xFF |
265 | call [irq14_func] |
265 | call [irq14_func] |
266 | call ready_for_next_irq_1 |
266 | call ready_for_next_irq_1 |
267 | restore_ring3_context |
267 | restore_ring3_context |
268 | iret |
268 | iret |
269 | p_irq15: |
269 | p_irq15: |
270 | save_ring3_context |
270 | save_ring3_context |
271 | mov ax, sel_app_data |
271 | mov ax, sel_app_data |
272 | mov ds, ax |
272 | mov ds, ax |
273 | mov es, ax |
273 | mov es, ax |
274 | mov byte [BOOT_VAR + 0x48E], 0xFF |
274 | mov byte [BOOT_VAR + 0x48E], 0xFF |
275 | call [irq15_func] |
275 | call [irq15_func] |
276 | call ready_for_next_irq_1 |
276 | call ready_for_next_irq_1 |
277 | restore_ring3_context |
277 | restore_ring3_context |
278 | iret |
278 | iret |
279 | 279 | ||
280 | ready_for_next_irq: |
280 | ready_for_next_irq: |
281 | mov [check_idle_semaphore],5 |
281 | mov [check_idle_semaphore],5 |
282 | mov al, 0x20 |
282 | mov al, 0x20 |
283 | out 0x20, al |
283 | out 0x20, al |
284 | ret |
284 | ret |
285 | 285 | ||
286 | ready_for_next_irq_1: |
286 | ready_for_next_irq_1: |
287 | mov [check_idle_semaphore],5 |
287 | mov [check_idle_semaphore],5 |
288 | mov al, 0x20 |
288 | mov al, 0x20 |
289 | out 0xa0,al |
289 | out 0xa0,al |
290 | out 0x20, al |
290 | out 0x20, al |
291 | ret |
291 | ret |
292 | 292 | ||
293 | irqD: |
293 | irqD: |
294 | save_ring3_context |
- | |
295 | mov ax, sel_app_data |
- | |
296 | mov ds, ax |
- | |
297 | mov es, ax |
294 | push eax |
298 | - | ||
299 | mov dx,0xf0 |
- | |
300 | mov al,0 |
295 | mov al,0 |
301 | out dx,al |
296 | out 0xf0,al |
302 | - | ||
303 | mov dx,0xa0 |
- | |
304 | mov al,0x20 |
297 | mov al,0x20 |
305 | out dx,al |
298 | out 0xa0,al |
306 | mov dx,0x20 |
299 | out 0x20,al |
307 | out dx,al |
300 | pop eax |
308 | - | ||
309 | restore_ring3_context |
- | |
310 | 301 | ||
311 | iret |
302 | iret |
312 | 303 | ||
313 | 304 | ||
314 | irqhandler: |
305 | irqhandler: |
315 | 306 | ||
316 | mov esi,edi ; 1 |
307 | mov esi,edi ; 1 |
317 | shl esi,6 ; 1 |
308 | shl esi,6 ; 1 |
318 | add esi,irq00read ; 1 |
309 | add esi,irq00read ; 1 |
319 | shl edi,12 ; 1 |
310 | shl edi,12 ; 1 |
320 | add edi,IRQ_SAVE |
311 | add edi,IRQ_SAVE |
321 | mov ecx,16 |
312 | mov ecx,16 |
322 | 313 | ||
323 | irqnewread: |
314 | irqnewread: |
324 | dec ecx |
315 | dec ecx |
325 | js irqover |
316 | js irqover |
326 | 317 | ||
327 | movzx edx, word [esi] ; 2+ |
318 | movzx edx, word [esi] ; 2+ |
328 | 319 | ||
329 | test edx, edx ; 1 |
320 | test edx, edx ; 1 |
330 | jz irqover |
321 | jz irqover |
331 | 322 | ||
332 | 323 | ||
333 | mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size |
324 | mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size |
334 | mov eax, 4000 ; + 0x4 dword - data begin offset |
325 | mov eax, 4000 ; + 0x4 dword - data begin offset |
335 | cmp ebx, eax |
326 | cmp ebx, eax |
336 | je irqfull |
327 | je irqfull |
337 | add ebx, [edi + 0x4] ; add data size to data begin offset |
328 | add ebx, [edi + 0x4] ; add data size to data begin offset |
338 | cmp ebx, eax ; if end of buffer, begin cycle again |
329 | cmp ebx, eax ; if end of buffer, begin cycle again |
339 | jb @f |
330 | jb @f |
340 | 331 | ||
341 | xor ebx, ebx |
332 | xor ebx, ebx |
342 | 333 | ||
343 | @@: |
334 | @@: |
344 | add ebx, edi |
335 | add ebx, edi |
345 | movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word |
336 | movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word |
346 | dec eax |
337 | dec eax |
347 | jz irqbyte |
338 | jz irqbyte |
348 | dec eax |
339 | dec eax |
349 | jnz noirqword |
340 | jnz noirqword |
350 | 341 | ||
351 | in ax,dx |
342 | in ax,dx |
352 | cmp ebx, 3999 ; check for address odd in the end of buffer |
343 | cmp ebx, 3999 ; check for address odd in the end of buffer |
353 | jne .odd |
344 | jne .odd |
354 | mov [ebx + 0x10], ax |
345 | mov [ebx + 0x10], ax |
355 | jmp .add_size |
346 | jmp .add_size |
356 | .odd: |
347 | .odd: |
357 | mov [ebx + 0x10], al ; I could make mistake here :) |
348 | mov [ebx + 0x10], al ; I could make mistake here :) |
358 | mov [edi + 0x10], ah |
349 | mov [edi + 0x10], ah |
359 | .add_size: |
350 | .add_size: |
360 | add dword [edi], 2 |
351 | add dword [edi], 2 |
361 | jmp nextport |
352 | jmp nextport |
362 | 353 | ||
363 | 354 | ||
364 | irqbyte: |
355 | irqbyte: |
365 | in al,dx |
356 | in al,dx |
366 | mov [ebx + 0x10],al |
357 | mov [ebx + 0x10],al |
367 | inc dword [edi] |
358 | inc dword [edi] |
368 | nextport: |
359 | nextport: |
369 | add esi,4 |
360 | add esi,4 |
370 | jmp irqnewread |
361 | jmp irqnewread |
371 | 362 | ||
372 | 363 | ||
373 | noirqword: |
364 | noirqword: |
374 | irqfull: |
365 | irqfull: |
375 | irqover: |
366 | irqover: |
376 | 367 | ||
377 | ret |
368 | ret |
378 | 369 | ||
379 | 370 | ||
380 | 371 | ||
381 | set_application_table_status: |
372 | set_application_table_status: |
382 | push eax |
373 | push eax |
383 | 374 | ||
384 | mov eax,[CURRENT_TASK] |
375 | mov eax,[CURRENT_TASK] |
385 | shl eax, 5 |
376 | shl eax, 5 |
386 | add eax,CURRENT_TASK+TASKDATA.pid |
377 | add eax,CURRENT_TASK+TASKDATA.pid |
387 | mov eax,[eax] |
378 | mov eax,[eax] |
388 | 379 | ||
389 | mov [application_table_status],eax |
380 | mov [application_table_status],eax |
390 | 381 | ||
391 | pop eax |
382 | pop eax |
392 | 383 | ||
393 | ret |
384 | ret |
394 | 385 | ||
395 | 386 | ||
396 | clear_application_table_status: |
387 | clear_application_table_status: |
397 | push eax |
388 | push eax |
398 | 389 | ||
399 | mov eax,[CURRENT_TASK] |
390 | mov eax,[CURRENT_TASK] |
400 | shl eax, 5 |
391 | shl eax, 5 |
401 | add eax,CURRENT_TASK+TASKDATA.pid |
392 | add eax,CURRENT_TASK+TASKDATA.pid |
402 | mov eax,[eax] |
393 | mov eax,[eax] |
403 | 394 | ||
404 | cmp eax,[application_table_status] |
395 | cmp eax,[application_table_status] |
405 | jne apptsl1 |
396 | jne apptsl1 |
406 | mov [application_table_status],0 |
397 | mov [application_table_status],0 |
407 | apptsl1: |
398 | apptsl1: |
408 | 399 | ||
409 | pop eax |
400 | pop eax |
410 | 401 | ||
411 | ret |
402 | ret |
412 | 403 | ||
413 | sys_resize_app_memory: |
404 | sys_resize_app_memory: |
414 | ; eax = 1 - resize |
405 | ; eax = 1 - resize |
415 | ; ebx = new amount of memory |
406 | ; ebx = new amount of memory |
416 | 407 | ||
417 | cmp eax,1 |
408 | cmp eax,1 |
418 | jne .no_application_mem_resize |
409 | jne .no_application_mem_resize |
419 | 410 | ||
420 | stdcall new_mem_resize, ebx |
411 | stdcall new_mem_resize, ebx |
421 | mov [esp+36], eax |
412 | mov [esp+36], eax |
422 | ret |
413 | ret |
423 | 414 | ||
424 | .no_application_mem_resize: |
415 | .no_application_mem_resize: |
425 | ret |
416 | ret |
426 | 417 | ||
427 | sys_threads: |
418 | sys_threads: |
428 | 419 | ||
429 | ; eax=1 create thread |
420 | ; eax=1 create thread |
430 | ; |
421 | ; |
431 | ; ebx=thread start |
422 | ; ebx=thread start |
432 | ; ecx=thread stack value |
423 | ; ecx=thread stack value |
433 | ; |
424 | ; |
434 | ; on return : eax = pid |
425 | ; on return : eax = pid |
435 | jmp new_sys_threads |
426 | jmp new_sys_threads |
436 | 427 | ||
437 | iglobal |
428 | iglobal |
438 | process_terminating db 'K : Process - terminating',13,10,0 |
429 | process_terminating db 'K : Process - terminating',13,10,0 |
439 | process_terminated db 'K : Process - done',13,10,0 |
430 | process_terminated db 'K : Process - done',13,10,0 |
440 | msg_obj_destroy db 'K : destroy app object',13,10,0 |
431 | msg_obj_destroy db 'K : destroy app object',13,10,0 |
441 | endg |
432 | endg |
442 | 433 | ||
443 | ; param |
434 | ; param |
444 | ; esi= slot |
435 | ; esi= slot |
445 | 436 | ||
446 | terminate: ; terminate application |
437 | terminate: ; terminate application |
447 | 438 | ||
448 | .slot equ esp ;locals |
439 | .slot equ esp ;locals |
449 | 440 | ||
450 | push esi ;save .slot |
441 | push esi ;save .slot |
451 | 442 | ||
452 | shl esi, 8 |
443 | shl esi, 8 |
453 | cmp [SLOT_BASE+esi+APPDATA.dir_table], 0 |
444 | cmp [SLOT_BASE+esi+APPDATA.dir_table], 0 |
454 | jne @F |
445 | jne @F |
455 | pop esi |
446 | pop esi |
456 | shl esi, 5 |
447 | shl esi, 5 |
457 | mov [CURRENT_TASK+esi+TASKDATA.state], 9 |
448 | mov [CURRENT_TASK+esi+TASKDATA.state], 9 |
458 | ret |
449 | ret |
459 | @@: |
450 | @@: |
460 | ;mov esi,process_terminating |
451 | ;mov esi,process_terminating |
461 | ;call sys_msg_board_str |
452 | ;call sys_msg_board_str |
462 | DEBUGF 1,"%s",process_terminating |
- | |
463 | @@: |
453 | @@: |
464 | cli |
454 | cli |
465 | cmp [application_table_status],0 |
455 | cmp [application_table_status],0 |
466 | je term9 |
456 | je term9 |
467 | sti |
457 | sti |
468 | call change_task |
458 | call change_task |
469 | jmp @b |
459 | jmp @b |
470 | term9: |
460 | term9: |
471 | call set_application_table_status |
461 | call set_application_table_status |
472 | 462 | ||
473 | ; if the process is in V86 mode... |
463 | ; if the process is in V86 mode... |
474 | mov eax, [.slot] |
464 | mov eax, [.slot] |
475 | shl eax, 8 |
465 | shl eax, 8 |
476 | mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] |
466 | mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] |
477 | add esi, RING0_STACK_SIZE |
467 | add esi, RING0_STACK_SIZE |
478 | cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi |
468 | cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi |
479 | jz .nov86 |
469 | jz .nov86 |
480 | ; ...it has page directory for V86 mode |
470 | ; ...it has page directory for V86 mode |
481 | mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0] |
471 | mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0] |
482 | mov ecx, [esi+4] |
472 | mov ecx, [esi+4] |
483 | mov [eax+SLOT_BASE+APPDATA.dir_table], ecx |
473 | mov [eax+SLOT_BASE+APPDATA.dir_table], ecx |
484 | ; ...and I/O permission map for V86 mode |
474 | ; ...and I/O permission map for V86 mode |
485 | mov ecx, [esi+12] |
475 | mov ecx, [esi+12] |
486 | mov [eax+SLOT_BASE+APPDATA.io_map], ecx |
476 | mov [eax+SLOT_BASE+APPDATA.io_map], ecx |
487 | mov ecx, [esi+8] |
477 | mov ecx, [esi+8] |
488 | mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx |
478 | mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx |
489 | .nov86: |
479 | .nov86: |
490 | 480 | ||
491 | mov esi, [.slot] |
481 | mov esi, [.slot] |
492 | shl esi,8 |
482 | shl esi,8 |
493 | add esi, SLOT_BASE+APP_OBJ_OFFSET |
483 | add esi, SLOT_BASE+APP_OBJ_OFFSET |
494 | @@: |
484 | @@: |
495 | mov eax, [esi+APPOBJ.fd] |
485 | mov eax, [esi+APPOBJ.fd] |
496 | test eax, eax |
486 | test eax, eax |
497 | jz @F |
487 | jz @F |
498 | 488 | ||
499 | cmp eax, esi |
489 | cmp eax, esi |
500 | je @F |
490 | je @F |
501 | 491 | ||
502 | push esi |
492 | push esi |
503 | call [eax+APPOBJ.destroy] |
493 | call [eax+APPOBJ.destroy] |
504 | DEBUGF 1,"%s",msg_obj_destroy |
494 | DEBUGF 1,"%s",msg_obj_destroy |
505 | pop esi |
495 | pop esi |
506 | jmp @B |
496 | jmp @B |
507 | @@: |
497 | @@: |
508 | mov eax, [.slot] |
498 | mov eax, [.slot] |
509 | shl eax, 8 |
499 | shl eax, 8 |
510 | mov eax,[SLOT_BASE+eax+APPDATA.dir_table] |
500 | mov eax,[SLOT_BASE+eax+APPDATA.dir_table] |
511 | stdcall destroy_app_space, eax |
501 | stdcall destroy_app_space, eax |
512 | 502 | ||
513 | mov esi, [.slot] |
503 | mov esi, [.slot] |
514 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
504 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
515 | jne @F |
505 | jne @F |
516 | 506 | ||
517 | mov [fpu_owner],1 |
507 | mov [fpu_owner],1 |
518 | mov eax, [256+SLOT_BASE+APPDATA.fpu_state] |
508 | mov eax, [256+SLOT_BASE+APPDATA.fpu_state] |
519 | clts |
509 | clts |
520 | bt [cpu_caps], CAPS_SSE |
510 | bt [cpu_caps], CAPS_SSE |
521 | jnc .no_SSE |
511 | jnc .no_SSE |
522 | fxrstor [eax] |
512 | fxrstor [eax] |
523 | jmp @F |
513 | jmp @F |
524 | .no_SSE: |
514 | .no_SSE: |
525 | fnclex |
515 | fnclex |
526 | frstor [eax] |
516 | frstor [eax] |
527 | @@: |
517 | @@: |
528 | 518 | ||
529 | mov [KEY_COUNT], 0 ; empty keyboard buffer |
519 | mov [KEY_COUNT], 0 ; empty keyboard buffer |
530 | mov [BTN_COUNT], 0 ; empty button buffer |
520 | mov [BTN_COUNT], 0 ; empty button buffer |
531 | 521 | ||
532 | 522 | ||
533 | ; remove defined hotkeys |
523 | ; remove defined hotkeys |
534 | mov eax, hotkey_list |
524 | mov eax, hotkey_list |
535 | .loop: |
525 | .loop: |
536 | cmp [eax+8], esi |
526 | cmp [eax+8], esi |
537 | jnz .cont |
527 | jnz .cont |
538 | mov ecx, [eax] |
528 | mov ecx, [eax] |
539 | jecxz @f |
529 | jecxz @f |
540 | push dword [eax+12] |
530 | push dword [eax+12] |
541 | pop dword [ecx+12] |
531 | pop dword [ecx+12] |
542 | @@: |
532 | @@: |
543 | mov ecx, [eax+12] |
533 | mov ecx, [eax+12] |
544 | push dword [eax] |
534 | push dword [eax] |
545 | pop dword [ecx] |
535 | pop dword [ecx] |
546 | xor ecx, ecx |
536 | xor ecx, ecx |
547 | mov [eax], ecx |
537 | mov [eax], ecx |
548 | mov [eax+4], ecx |
538 | mov [eax+4], ecx |
549 | mov [eax+8], ecx |
539 | mov [eax+8], ecx |
550 | mov [eax+12], ecx |
540 | mov [eax+12], ecx |
551 | .cont: |
541 | .cont: |
552 | add eax, 16 |
542 | add eax, 16 |
553 | cmp eax, hotkey_list+256*16 |
543 | cmp eax, hotkey_list+256*16 |
554 | jb .loop |
544 | jb .loop |
555 | ; remove hotkeys in buffer |
545 | ; remove hotkeys in buffer |
556 | mov eax, hotkey_buffer |
546 | mov eax, hotkey_buffer |
557 | .loop2: |
547 | .loop2: |
558 | cmp [eax], esi |
548 | cmp [eax], esi |
559 | jnz .cont2 |
549 | jnz .cont2 |
560 | and dword [eax+4], 0 |
550 | and dword [eax+4], 0 |
561 | and dword [eax], 0 |
551 | and dword [eax], 0 |
562 | .cont2: |
552 | .cont2: |
563 | add eax, 8 |
553 | add eax, 8 |
564 | cmp eax, hotkey_buffer+120*8 |
554 | cmp eax, hotkey_buffer+120*8 |
565 | jb .loop2 |
555 | jb .loop2 |
566 | 556 | ||
567 | mov ecx,esi ; remove buttons |
557 | mov ecx,esi ; remove buttons |
568 | bnewba2: |
558 | bnewba2: |
569 | mov edi,[btn_addr] |
559 | mov edi,[btn_addr] |
570 | mov eax,edi |
560 | mov eax,edi |
571 | cld |
561 | cld |
572 | movzx ebx,word [edi] |
562 | movzx ebx,word [edi] |
573 | inc bx |
563 | inc bx |
574 | bnewba: |
564 | bnewba: |
575 | dec bx |
565 | dec bx |
576 | jz bnmba |
566 | jz bnmba |
577 | add eax,0x10 |
567 | add eax,0x10 |
578 | cmp cx,[eax] |
568 | cmp cx,[eax] |
579 | jnz bnewba |
569 | jnz bnewba |
580 | pusha |
570 | pusha |
581 | mov ecx,ebx |
571 | mov ecx,ebx |
582 | inc ecx |
572 | inc ecx |
583 | shl ecx,4 |
573 | shl ecx,4 |
584 | mov ebx,eax |
574 | mov ebx,eax |
585 | add eax,0x10 |
575 | add eax,0x10 |
586 | call memmove |
576 | call memmove |
587 | dec dword [edi] |
577 | dec dword [edi] |
588 | popa |
578 | popa |
589 | jmp bnewba2 |
579 | jmp bnewba2 |
590 | bnmba: |
580 | bnmba: |
591 | 581 | ||
592 | pusha ; save window coordinates for window restoring |
582 | pusha ; save window coordinates for window restoring |
593 | cld |
583 | cld |
594 | shl esi,5 |
584 | shl esi,5 |
595 | mov eax,[window_data+esi+WDATA.box.left] |
585 | mov eax,[window_data+esi+WDATA.box.left] |
596 | mov [dlx],eax |
586 | mov [dlx],eax |
597 | add eax,[window_data+esi+WDATA.box.width] |
587 | add eax,[window_data+esi+WDATA.box.width] |
598 | mov [dlxe],eax |
588 | mov [dlxe],eax |
599 | mov eax,[window_data+esi+WDATA.box.top] |
589 | mov eax,[window_data+esi+WDATA.box.top] |
600 | mov [dly],eax |
590 | mov [dly],eax |
601 | add eax,[window_data+esi+WDATA.box.height] |
591 | add eax,[window_data+esi+WDATA.box.height] |
602 | mov [dlye],eax |
592 | mov [dlye],eax |
603 | 593 | ||
604 | xor eax, eax |
594 | xor eax, eax |
605 | mov [window_data+esi+WDATA.box.left],eax |
595 | mov [window_data+esi+WDATA.box.left],eax |
- | 596 | ||
606 | mov [window_data+esi+WDATA.box.width],eax |
597 | mov [window_data+esi+WDATA.box.width],eax |
607 | mov [window_data+esi+WDATA.box.top],eax |
598 | mov [window_data+esi+WDATA.box.top],eax |
608 | mov [window_data+esi+WDATA.box.height],eax |
599 | mov [window_data+esi+WDATA.box.height],eax |
609 | mov [window_data+esi+WDATA.cl_workarea],eax |
600 | mov [window_data+esi+WDATA.cl_workarea],eax |
610 | mov [window_data+esi+WDATA.cl_titlebar],eax |
601 | mov [window_data+esi+WDATA.cl_titlebar],eax |
- | 602 | ||
611 | mov [window_data+esi+WDATA.cl_frames],eax |
603 | mov [window_data+esi+WDATA.cl_frames],eax |
612 | mov dword [window_data+esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
604 | mov dword [window_data+esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
613 | lea edi, [esi+draw_data] |
605 | lea edi, [esi+draw_data] |
614 | mov ecx,32/4 |
606 | mov ecx,32/4 |
615 | rep stosd |
607 | rep stosd |
616 | popa |
608 | popa |
617 | 609 | ||
618 | ; debuggee test |
610 | ; debuggee test |
619 | pushad |
611 | pushad |
620 | mov edi, esi |
612 | mov edi, esi |
621 | shl edi, 5 |
613 | shl edi, 5 |
622 | mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] |
614 | mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] |
623 | test eax, eax |
615 | test eax, eax |
624 | jz .nodebug |
616 | jz .nodebug |
625 | push 8 |
617 | push 8 |
626 | pop ecx |
618 | pop ecx |
627 | push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID |
619 | push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID |
628 | push 2 |
620 | push 2 |
629 | call debugger_notify |
621 | call debugger_notify |
630 | pop ecx |
622 | pop ecx |
631 | pop ecx |
623 | pop ecx |
632 | .nodebug: |
624 | .nodebug: |
633 | popad |
625 | popad |
634 | 626 | ||
635 | mov edi, [.slot] |
627 | mov edi, [.slot] |
636 | shl edi, 8 |
628 | shl edi, 8 |
637 | add edi,SLOT_BASE |
629 | add edi,SLOT_BASE |
638 | 630 | ||
639 | mov ecx,[edi+APPDATA.pl0_stack] |
631 | mov ecx,[edi+APPDATA.pl0_stack] |
640 | sub ecx, OS_BASE |
632 | sub ecx, OS_BASE |
641 | call @frame_free@4 |
633 | call @frame_free@4 |
642 | 634 | ||
643 | mov ecx,[edi+APPDATA.cur_dir] |
635 | mov ecx,[edi+APPDATA.cur_dir] |
644 | sub ecx, OS_BASE |
636 | sub ecx, OS_BASE |
645 | call @frame_free@4 |
637 | call @frame_free@4 |
646 | 638 | ||
647 | mov ecx, [edi+APPDATA.io_map] |
639 | mov ecx, [edi+APPDATA.io_map] |
648 | cmp ecx, (tss._io_map_0-OS_BASE+PG_MAP) |
640 | cmp ecx, (tss._io_map_0-OS_BASE+PG_MAP) |
649 | je @F |
641 | je @F |
650 | 642 | ||
651 | call @frame_free@4 |
643 | call @frame_free@4 |
652 | @@: |
644 | @@: |
653 | mov ecx, [edi+APPDATA.io_map+4] |
645 | mov ecx, [edi+APPDATA.io_map+4] |
654 | cmp ecx, (tss._io_map_1-OS_BASE+PG_MAP) |
646 | cmp ecx, (tss._io_map_1-OS_BASE+PG_MAP) |
655 | je @F |
647 | je @F |
656 | 648 | ||
657 | call @frame_free@4 |
649 | call @frame_free@4 |
658 | @@: |
650 | @@: |
659 | mov eax, 0x20202020 |
651 | mov eax, 0x20202020 |
660 | stosd |
652 | stosd |
661 | stosd |
653 | stosd |
662 | stosd |
654 | stosd |
663 | mov ecx,244/4 |
655 | mov ecx,244/4 |
664 | xor eax, eax |
656 | xor eax, eax |
665 | rep stosd |
657 | rep stosd |
666 | 658 | ||
667 | ; activate window |
659 | ; activate window |
668 | movzx eax, word [WIN_STACK + esi*2] |
660 | movzx eax, word [WIN_STACK + esi*2] |
669 | cmp eax, [TASK_COUNT] |
661 | cmp eax, [TASK_COUNT] |
670 | jne .dont_activate |
662 | jne .dont_activate |
671 | pushad |
663 | pushad |
672 | .check_next_window: |
664 | .check_next_window: |
673 | dec eax |
665 | dec eax |
674 | cmp eax, 1 |
666 | cmp eax, 1 |
675 | jbe .nothing_to_activate |
667 | jbe .nothing_to_activate |
676 | lea esi, [WIN_POS+eax*2] |
668 | lea esi, [WIN_POS+eax*2] |
677 | movzx edi, word [esi] ; edi = process |
669 | movzx edi, word [esi] ; edi = process |
678 | shl edi, 5 |
670 | shl edi, 5 |
679 | cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots |
671 | cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots |
680 | je .check_next_window |
672 | je .check_next_window |
681 | add edi, window_data |
673 | add edi, window_data |
682 | ; \begin{diamond}[19.09.2006] |
674 | ; \begin{diamond}[19.09.2006] |
683 | ; skip minimized windows |
675 | ; skip minimized windows |
684 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
676 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
685 | jnz .check_next_window |
677 | jnz .check_next_window |
686 | ; \end{diamond} |
678 | ; \end{diamond} |
687 | call waredraw |
679 | call waredraw |
688 | .nothing_to_activate: |
680 | .nothing_to_activate: |
689 | popad |
681 | popad |
690 | .dont_activate: |
682 | .dont_activate: |
691 | 683 | ||
692 | push esi ; remove hd1 & cd & flp reservation |
684 | push esi ; remove hd1 & cd & flp reservation |
693 | shl esi, 5 |
685 | shl esi, 5 |
694 | mov esi, [esi+CURRENT_TASK+TASKDATA.pid] |
686 | mov esi, [esi+CURRENT_TASK+TASKDATA.pid] |
695 | cmp [hd1_status], esi |
687 | cmp [hd1_status], esi |
696 | jnz @f |
688 | jnz @f |
697 | call free_hd_channel |
689 | call free_hd_channel |
698 | mov [hd1_status], 0 |
690 | mov [hd1_status], 0 |
699 | @@: |
691 | @@: |
700 | cmp [cd_status], esi |
692 | cmp [cd_status], esi |
701 | jnz @f |
693 | jnz @f |
702 | call free_cd_channel |
694 | call free_cd_channel |
703 | mov [cd_status], 0 |
695 | mov [cd_status], 0 |
704 | @@: |
696 | @@: |
705 | cmp [flp_status], esi |
697 | cmp [flp_status], esi |
706 | jnz @f |
698 | jnz @f |
707 | mov [flp_status], 0 |
699 | mov [flp_status], 0 |
708 | @@: |
700 | @@: |
709 | pop esi |
701 | pop esi |
710 | cmp [bgrlockpid], esi |
702 | cmp [bgrlockpid], esi |
711 | jnz @f |
703 | jnz @f |
712 | and [bgrlockpid], 0 |
704 | and [bgrlockpid], 0 |
713 | mov [bgrlock], 0 |
705 | mov [bgrlock], 0 |
714 | @@: |
706 | @@: |
715 | 707 | ||
716 | pusha ; remove all irq reservations |
708 | pusha ; remove all irq reservations |
717 | mov eax,esi |
709 | mov eax,esi |
718 | shl eax, 5 |
710 | shl eax, 5 |
719 | mov eax,[eax+CURRENT_TASK+TASKDATA.pid] |
711 | mov eax,[eax+CURRENT_TASK+TASKDATA.pid] |
720 | mov edi,irq_owner |
712 | mov edi,irq_owner |
721 | xor ebx, ebx |
713 | xor ebx, ebx |
722 | xor edx, edx |
714 | xor edx, edx |
723 | newirqfree: |
715 | newirqfree: |
724 | cmp [edi + 4 * ebx], eax |
716 | cmp [edi + 4 * ebx], eax |
725 | jne nofreeirq |
717 | jne nofreeirq |
726 | mov [edi + 4 * ebx], edx ; remove irq reservation |
718 | mov [edi + 4 * ebx], edx ; remove irq reservation |
727 | mov [irq_tab + 4 * ebx], edx ; remove irq handler |
719 | mov [irq_tab + 4 * ebx], edx ; remove irq handler |
728 | mov [irq_rights + 4 * ebx], edx ; set access rights to full access |
720 | mov [irq_rights + 4 * ebx], edx ; set access rights to full access |
729 | nofreeirq: |
721 | nofreeirq: |
730 | inc ebx |
722 | inc ebx |
731 | cmp ebx, 16 |
723 | cmp ebx, 16 |
732 | jb newirqfree |
724 | jb newirqfree |
733 | popa |
725 | popa |
734 | 726 | ||
735 | pusha ; remove all port reservations |
727 | pusha ; remove all port reservations |
736 | mov edx,esi |
728 | mov edx,esi |
737 | shl edx, 5 |
729 | shl edx, 5 |
738 | add edx,CURRENT_TASK |
730 | add edx,CURRENT_TASK |
739 | mov edx,[edx+TASKDATA.pid] |
731 | mov edx,[edx+TASKDATA.pid] |
740 | 732 | ||
741 | rmpr0: |
733 | rmpr0: |
742 | 734 | ||
743 | mov esi,[RESERVED_PORTS] |
735 | mov esi,[RESERVED_PORTS] |
744 | 736 | ||
745 | cmp esi,0 |
737 | cmp esi,0 |
746 | je rmpr9 |
738 | je rmpr9 |
747 | 739 | ||
748 | rmpr3: |
740 | rmpr3: |
749 | 741 | ||
750 | mov edi,esi |
742 | mov edi,esi |
751 | shl edi,4 |
743 | shl edi,4 |
752 | add edi,RESERVED_PORTS |
744 | add edi,RESERVED_PORTS |
753 | 745 | ||
754 | cmp edx,[edi] |
746 | cmp edx,[edi] |
755 | je rmpr4 |
747 | je rmpr4 |
756 | 748 | ||
757 | dec esi |
749 | dec esi |
758 | jnz rmpr3 |
750 | jnz rmpr3 |
759 | 751 | ||
760 | jmp rmpr9 |
752 | jmp rmpr9 |
761 | 753 | ||
762 | rmpr4: |
754 | rmpr4: |
763 | 755 | ||
764 | mov ecx,256 |
756 | mov ecx,256 |
765 | sub ecx,esi |
757 | sub ecx,esi |
766 | shl ecx,4 |
758 | shl ecx,4 |
767 | 759 | ||
768 | mov esi,edi |
760 | mov esi,edi |
769 | add esi,16 |
761 | add esi,16 |
770 | cld |
762 | cld |
771 | rep movsb |
763 | rep movsb |
772 | 764 | ||
773 | dec dword [RESERVED_PORTS] |
765 | dec dword [RESERVED_PORTS] |
774 | 766 | ||
775 | jmp rmpr0 |
767 | jmp rmpr0 |
776 | 768 | ||
777 | rmpr9: |
769 | rmpr9: |
778 | 770 | ||
779 | popa |
771 | popa |
780 | mov edi,esi ; do not run this process slot |
772 | mov edi,esi ; do not run this process slot |
781 | shl edi, 5 |
773 | shl edi, 5 |
782 | mov [edi+CURRENT_TASK + TASKDATA.state],byte 9 |
774 | mov [edi+CURRENT_TASK + TASKDATA.state],byte 9 |
783 | ; debugger test - terminate all debuggees |
775 | ; debugger test - terminate all debuggees |
784 | mov eax, 2 |
776 | mov eax, 2 |
785 | mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot |
777 | mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot |
786 | .xd0: |
778 | .xd0: |
787 | cmp eax, [TASK_COUNT] |
779 | cmp eax, [TASK_COUNT] |
788 | ja .xd1 |
780 | ja .xd1 |
789 | cmp dword [ecx], esi |
781 | cmp dword [ecx], esi |
790 | jnz @f |
782 | jnz @f |
791 | and dword [ecx], 0 |
783 | and dword [ecx], 0 |
792 | pushad |
784 | pushad |
793 | xchg eax, ecx |
785 | xchg eax, ecx |
794 | mov ebx, 2 |
786 | mov ebx, 2 |
795 | call sys_system |
787 | call sys_system |
796 | popad |
788 | popad |
797 | @@: |
789 | @@: |
798 | inc eax |
790 | inc eax |
799 | add ecx, 0x100 |
791 | add ecx, 0x100 |
800 | jmp .xd0 |
792 | jmp .xd0 |
801 | .xd1: |
793 | .xd1: |
802 | ; call systest |
794 | ; call systest |
803 | sti ; .. and life goes on |
795 | sti ; .. and life goes on |
804 | 796 | ||
805 | mov eax, [dlx] |
797 | mov eax, [dlx] |
806 | mov ebx, [dly] |
798 | mov ebx, [dly] |
807 | mov ecx, [dlxe] |
799 | mov ecx, [dlxe] |
808 | mov edx, [dlye] |
800 | mov edx, [dlye] |
809 | call calculatescreen |
801 | call calculatescreen |
810 | xor eax, eax |
802 | xor eax, eax |
811 | xor esi, esi |
803 | xor esi, esi |
812 | call redrawscreen |
804 | call redrawscreen |
813 | 805 | ||
814 | mov [application_table_status],0 |
806 | mov [application_table_status],0 |
815 | ;mov esi,process_terminated |
807 | ;mov esi,process_terminated |
816 | ;call sys_msg_board_str |
808 | ;call sys_msg_board_str |
817 | DEBUGF 1,"%s",process_terminated |
- | |
818 | add esp, 4 |
809 | add esp, 4 |
819 | ret |
810 | ret |
820 | restore .slot |
811 | restore .slot |
821 | 812 | ||
822 | iglobal |
813 | iglobal |
823 | boot_sched_1 db 'Building gdt tss pointer',0 |
814 | boot_sched_1 db 'Building gdt tss pointer',0 |
824 | boot_sched_2 db 'Building IDT table',0 |
815 | boot_sched_2 db 'Building IDT table',0 |
825 | endg |
816 | endg |
826 | 817 | ||
827 | 818 | ||
828 | build_scheduler: |
819 | build_scheduler: |
829 | 820 | ||
830 | mov esi,boot_sched_1 |
821 | mov esi,boot_sched_1 |
831 | call boot_log |
822 | call boot_log |
832 | ; call build_process_gdt_tss_pointer |
823 | ; call build_process_gdt_tss_pointer |
833 | 824 | ||
834 | ; mov esi,boot_sched_2 |
825 | ; mov esi,boot_sched_2 |
835 | ; call boot_log |
826 | ; call boot_log |
836 | 827 | ||
837 | ret |
828 | ret |