Rev 2231 | Rev 2455 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License ;; |
||
5 | ;; ;; |
||
6 | ;; ;; |
||
7 | ;; MenuetOS process management, protected ring3 ;; |
||
8 | ;; ;; |
||
9 | ;; Distributed under GPL. See file COPYING for details. ;; |
||
10 | ;; Copyright 2003 Ville Turjanmaa ;; |
||
11 | ;; ;; |
||
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
13 | |||
14 | $Revision: 2288 $ |
||
15 | |||
16 | |||
17 | align 4 ;3A08 |
||
18 | build_interrupt_table: |
||
19 | mov edi, idts |
||
20 | mov esi, sys_int |
||
21 | mov ecx, 0x40 |
||
22 | mov eax, (10001110b shl 24) + os_code |
||
23 | @@: |
||
24 | movsw ;low word of code-entry |
||
25 | stosd ;interrupt gate type : os_code selector |
||
26 | movsw ;high word of code-entry |
||
27 | loop @b |
||
28 | movsd ;copy low dword of trap gate for int 0x40 |
||
29 | movsd ;copy high dword of trap gate for int 0x40 |
||
30 | lidt [esi] |
||
31 | ret |
||
32 | |||
33 | iglobal |
||
34 | align 4 |
||
35 | sys_int: |
||
36 | ;exception handlers addresses (for interrupt gate construction) |
||
37 | dd e0,e1,e2,e3,e4,e5,e6,except_7 ; SEE: core/fpu.inc |
||
38 | dd e8,e9,e10,e11,e12,e13,page_fault_exc,e15 |
||
39 | dd e16, e17,e18, e19 |
||
40 | times 12 dd unknown_interrupt ;int_20..int_31 |
||
41 | |||
42 | ;interrupt handlers addresses (for interrupt gate construction) |
||
43 | ; 0x20 .. 0x2F - IRQ handlers |
||
44 | dd irq0, irq_serv.irq_1, irq_serv.irq_2 |
||
45 | dd irq_serv.irq_3, irq_serv.irq_4 |
||
46 | dd irq_serv.irq_5, irq_serv.irq_6, irq_serv.irq_7 |
||
47 | dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 |
||
48 | dd irq_serv.irq_11, irq_serv.irq_12, irqD, irq_serv.irq_14, irq_serv.irq_15 |
||
49 | dd irq_serv.irq_16 |
||
50 | dd irq_serv.irq_17 |
||
51 | dd irq_serv.irq_18 |
||
52 | dd irq_serv.irq_19 |
||
53 | dd irq_serv.irq_20 |
||
54 | dd irq_serv.irq_21 |
||
55 | dd irq_serv.irq_22 |
||
56 | dd irq_serv.irq_23 |
||
57 | |||
58 | times 32 - IRQ_RESERVED dd unknown_interrupt |
||
59 | ;int_0x40 gate trap (for directly copied) |
||
60 | dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16 |
||
61 | |||
62 | idtreg: ; data for LIDT instruction (!!! must be immediately below sys_int data) |
||
63 | dw 2*($-sys_int-4)-1 |
||
64 | dd idts ;0x8000B100 |
||
65 | dw 0 ;просто выравнивание |
||
66 | |||
67 | msg_fault_sel dd msg_exc_8,msg_exc_u,msg_exc_a,msg_exc_b |
||
68 | dd msg_exc_c,msg_exc_d,msg_exc_e |
||
69 | |||
70 | msg_exc_8 db "Double fault", 0 |
||
71 | msg_exc_u db "Undefined Exception", 0 |
||
72 | msg_exc_a db "Invalid TSS", 0 |
||
73 | msg_exc_b db "Segment not present", 0 |
||
74 | msg_exc_c db "Stack fault", 0 |
||
75 | msg_exc_d db "General protection fault", 0 |
||
76 | msg_exc_e db "Page fault", 0 |
||
77 | |||
78 | msg_sel_ker db "kernel", 0 |
||
79 | msg_sel_app db "application", 0 |
||
80 | |||
81 | endg |
||
82 | |||
83 | macro save_ring3_context { |
||
84 | pushad |
||
85 | } |
||
86 | macro restore_ring3_context { |
||
87 | popad |
||
88 | } |
||
89 | macro exc_wo_code [num] { |
||
90 | e#num : |
||
91 | save_ring3_context |
||
92 | mov bl, num |
||
93 | jmp exc_c |
||
94 | } exc_wo_code 0,1,2,3,4,5,6,15,16,19 |
||
95 | |||
96 | macro exc_w_code [num] { |
||
97 | e#num : |
||
98 | add esp, 4 |
||
99 | save_ring3_context |
||
100 | mov bl, num |
||
101 | jmp exc_c |
||
102 | } exc_w_code 8,9,10,11,12,13,17,18 |
||
103 | |||
104 | |||
105 | uglobal |
||
106 | pf_err_code dd ? |
||
107 | endg |
||
108 | |||
109 | page_fault_exc: ; дуракоусточивость: селекторы испорчены... |
||
110 | pop [ss:pf_err_code]; действительно до следующего #PF |
||
111 | save_ring3_context |
||
112 | mov bl, 14 |
||
113 | |||
114 | exc_c: ; исключения (все, кроме 7-го - #NM) |
||
115 | ; Фрэйм стека при исключении/прерывании из 3-го кольца + pushad (т.е., именно здесь) |
||
116 | reg_ss equ esp+0x30 |
||
117 | reg_esp3 equ esp+0x2C |
||
118 | reg_eflags equ esp+0x28 |
||
119 | reg_cs3 equ esp+0x24 |
||
120 | reg_eip equ esp+0x20 |
||
121 | ; это фрэйм от pushad |
||
122 | reg_eax equ esp+0x1C |
||
123 | reg_ecx equ esp+0x18 |
||
124 | reg_edx equ esp+0x14 |
||
125 | reg_ebx equ esp+0x10 |
||
126 | reg_esp0 equ esp+0x0C |
||
127 | reg_ebp equ esp+0x08 |
||
128 | reg_esi equ esp+0x04 |
||
129 | reg_edi equ esp+0x00 |
||
130 | |||
131 | mov ax, app_data ;исключение |
||
132 | mov ds, ax ;загрузим правильные значения |
||
133 | mov es, ax ;в регистры |
||
134 | cld ; и приводим DF к стандарту |
||
135 | movzx ebx, bl |
||
136 | ; redirect to V86 manager? (EFLAGS & 0x20000) != 0? |
||
137 | test byte[reg_eflags+2], 2 |
||
138 | jnz v86_exc_c |
||
139 | cmp bl, 14 ; #PF |
||
140 | jne @f |
||
141 | call page_fault_handler ; SEE: core/memory.inc |
||
142 | @@: |
||
143 | mov esi, [current_slot] |
||
144 | btr [esi+APPDATA.except_mask], ebx |
||
145 | jnc @f |
||
146 | mov eax, [esi+APPDATA.exc_handler] |
||
147 | test eax, eax |
||
148 | jnz IRetToUserHook |
||
149 | @@: |
||
150 | cli |
||
151 | mov eax, [esi+APPDATA.debugger_slot] |
||
152 | test eax, eax |
||
153 | jnz .debug |
||
154 | sti |
||
155 | ; not debuggee => say error and terminate |
||
156 | call show_error_parameters ;; only ONE using, inline ??? |
||
157 | ;mov edx, [TASK_BASE] |
||
158 | mov [edx + TASKDATA.state], byte 4 ; terminate |
||
159 | jmp change_task ; stack - here it does not matter at all, SEE: core/shed.inc |
||
160 | .debug: |
||
161 | ; we are debugged process, notify debugger and suspend ourself |
||
162 | ; eax=debugger PID |
||
163 | mov ecx, 1 ; debug_message code=other_exception |
||
164 | cmp bl, 1 ; #DB |
||
165 | jne .notify ; notify debugger and suspend ourself |
||
166 | mov ebx, dr6 ; debug_message data=DR6_image |
||
167 | xor edx, edx |
||
168 | mov dr6, edx |
||
169 | mov edx, dr7 |
||
170 | mov cl, not 8 |
||
171 | .l1: |
||
172 | shl dl, 2 |
||
173 | jc @f |
||
174 | and bl, cl |
||
175 | @@: |
||
176 | sar cl, 1 |
||
177 | jc .l1 |
||
178 | mov cl, 3 ; debug_message code=debug_exception |
||
179 | .notify: |
||
180 | push ebx ; debug_message data |
||
181 | mov ebx, [TASK_BASE] |
||
182 | push [ebx+TASKDATA.pid] ; PID |
||
183 | push ecx ; debug_message code ((here: ecx==1/3)) |
||
184 | mov cl, 12 ; debug_message size |
||
185 | call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc |
||
186 | add esp, 12 |
||
187 | mov edx, [TASK_BASE] |
||
188 | mov byte [edx+TASKDATA.state], 1 ; suspended |
||
189 | call change_task ; SEE: core/shed.inc |
||
190 | restore_ring3_context |
||
191 | iretd |
||
192 | |||
193 | IRetToUserHook: |
||
194 | xchg eax, [reg_eip] |
||
195 | sub dword[reg_esp3], 8 |
||
196 | mov edi, [reg_esp3] |
||
197 | stosd |
||
198 | mov [edi], ebx |
||
199 | restore_ring3_context |
||
200 | ; simply return control to interrupted process |
||
201 | unknown_interrupt: |
||
202 | iretd |
||
203 | |||
204 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
||
205 | ; bl - error vector |
||
206 | show_error_parameters: |
||
207 | cmp bl, 0x06 |
||
208 | jnz .no_ud |
||
209 | push ebx |
||
210 | mov ebx, ud_user_message |
||
211 | mov ebp, notifyapp |
||
212 | call fs_execute_from_sysdir_param |
||
213 | pop ebx |
||
214 | .no_ud: |
||
215 | mov edx, [TASK_BASE];not scratched below |
||
216 | DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] |
||
217 | cmp bl, 0x08 |
||
218 | jb .l0 |
||
219 | cmp bl, 0x0e |
||
220 | jbe .l1 |
||
221 | .l0: |
||
222 | mov bl, 0x09 |
||
223 | .l1: |
||
224 | mov eax, [msg_fault_sel+ebx*4 - 0x08*4] |
||
225 | DEBUGF 1, "K : %s\n", eax |
||
226 | mov eax, [reg_cs3+4] |
||
227 | mov edi, msg_sel_app |
||
228 | mov ebx, [reg_esp3+4] |
||
229 | cmp eax, app_code |
||
230 | je @f |
||
231 | mov edi, msg_sel_ker |
||
232 | mov ebx, [reg_esp0+4] |
||
233 | @@: |
||
234 | DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4] |
||
235 | DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [reg_edx+4], [reg_esi+4], [reg_edi+4] |
||
236 | DEBUGF 1, "K : EBP : %x EIP : %x ESP : %x\n", [reg_ebp+4], [reg_eip+4], ebx |
||
237 | DEBUGF 1, "K : Flags : %x CS : %x (%s)\n", [reg_eflags+4], eax, edi |
||
238 | ret |
||
239 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
||
240 | |||
241 | restore reg_ss |
||
242 | restore reg_esp3 |
||
243 | restore reg_eflags |
||
244 | restore reg_cs |
||
245 | restore reg_eip |
||
246 | restore reg_eax |
||
247 | restore reg_ecx |
||
248 | restore reg_edx |
||
249 | restore reg_ebx |
||
250 | restore reg_esp0 |
||
251 | restore reg_ebp |
||
252 | restore reg_esi |
||
253 | restore reg_edi |
||
254 | |||
255 | |||
256 | align 4 |
||
257 | set_application_table_status: |
||
258 | push eax |
||
259 | |||
260 | mov eax, [CURRENT_TASK] |
||
261 | shl eax, 5 |
||
262 | add eax, CURRENT_TASK+TASKDATA.pid |
||
263 | mov eax, [eax] |
||
264 | |||
265 | mov [application_table_status], eax |
||
266 | |||
267 | pop eax |
||
268 | |||
269 | ret |
||
270 | |||
271 | align 4 |
||
272 | clear_application_table_status: |
||
273 | push eax |
||
274 | |||
275 | mov eax, [CURRENT_TASK] |
||
276 | shl eax, 5 |
||
277 | add eax, CURRENT_TASK+TASKDATA.pid |
||
278 | mov eax, [eax] |
||
279 | |||
280 | cmp eax, [application_table_status] |
||
281 | jne apptsl1 |
||
282 | xor eax, eax |
||
283 | mov [application_table_status], eax |
||
284 | apptsl1: |
||
285 | |||
286 | pop eax |
||
287 | |||
288 | ret |
||
289 | |||
290 | ; * eax = 64 - номер функции |
||
291 | ; * ebx = 1 - единственная подфункция |
||
292 | ; * ecx = новый размер памяти |
||
293 | ;Возвращаемое значение: |
||
294 | ; * eax = 0 - успешно |
||
295 | ; * eax = 1 - недостаточно памяти |
||
296 | |||
297 | align 4 |
||
298 | sys_resize_app_memory: |
||
299 | ; ebx = 1 - resize |
||
300 | ; ecx = new amount of memory |
||
301 | |||
302 | ; cmp eax,1 |
||
303 | dec ebx |
||
304 | jnz .no_application_mem_resize |
||
305 | stdcall new_mem_resize, ecx |
||
306 | mov [esp+32], eax |
||
307 | .no_application_mem_resize: |
||
308 | ret |
||
309 | |||
310 | iglobal |
||
311 | ; process_terminating db 'K : Process - terminating',13,10,0 |
||
312 | ; process_terminated db 'K : Process - done',13,10,0 |
||
313 | msg_obj_destroy db 'K : destroy app object',13,10,0 |
||
314 | endg |
||
315 | |||
316 | ; param |
||
317 | ; esi= slot |
||
318 | |||
319 | align 4 |
||
320 | terminate: ; terminate application |
||
321 | |||
322 | .slot equ esp ;locals |
||
323 | |||
324 | push esi ;save .slot |
||
325 | |||
326 | shl esi, 8 |
||
327 | cmp [SLOT_BASE+esi+APPDATA.dir_table], 0 |
||
328 | jne @F |
||
329 | pop esi |
||
330 | shl esi, 5 |
||
331 | mov [CURRENT_TASK+esi+TASKDATA.state], 9 |
||
332 | ret |
||
333 | @@: |
||
334 | ;mov esi,process_terminating |
||
335 | ;call sys_msg_board_str |
||
336 | @@: |
||
337 | cli |
||
338 | cmp [application_table_status], 0 |
||
339 | je term9 |
||
340 | sti |
||
341 | call change_task |
||
342 | jmp @b |
||
343 | term9: |
||
344 | call set_application_table_status |
||
345 | |||
346 | ; if the process is in V86 mode... |
||
347 | mov eax, [.slot] |
||
348 | shl eax, 8 |
||
349 | mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] |
||
350 | add esi, RING0_STACK_SIZE |
||
351 | cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi |
||
352 | jz .nov86 |
||
353 | ; ...it has page directory for V86 mode |
||
354 | mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0] |
||
355 | mov ecx, [esi+4] |
||
356 | mov [eax+SLOT_BASE+APPDATA.dir_table], ecx |
||
357 | ; ...and I/O permission map for V86 mode |
||
358 | mov ecx, [esi+12] |
||
359 | mov [eax+SLOT_BASE+APPDATA.io_map], ecx |
||
360 | mov ecx, [esi+8] |
||
361 | mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx |
||
362 | .nov86: |
||
363 | |||
364 | mov esi, [.slot] |
||
365 | shl esi, 8 |
||
366 | add esi, SLOT_BASE+APP_OBJ_OFFSET |
||
367 | @@: |
||
368 | mov eax, [esi+APPOBJ.fd] |
||
369 | test eax, eax |
||
370 | jz @F |
||
371 | |||
372 | cmp eax, esi |
||
373 | je @F |
||
374 | |||
375 | push esi |
||
376 | call [eax+APPOBJ.destroy] |
||
377 | DEBUGF 1,"%s",msg_obj_destroy |
||
378 | pop esi |
||
379 | jmp @B |
||
380 | @@: |
||
381 | |||
382 | mov eax, [.slot] |
||
383 | shl eax, 8 |
||
384 | stdcall destroy_app_space, [SLOT_BASE+eax+APPDATA.dir_table], [SLOT_BASE+eax+APPDATA.dlls_list_ptr] |
||
385 | |||
386 | mov esi, [.slot] |
||
387 | cmp [fpu_owner], esi ; if user fpu last -> fpu user = 1 |
||
388 | jne @F |
||
389 | |||
390 | mov [fpu_owner], 1 |
||
391 | mov eax, [256+SLOT_BASE+APPDATA.fpu_state] |
||
392 | clts |
||
393 | bt [cpu_caps], CAPS_SSE |
||
394 | jnc .no_SSE |
||
395 | fxrstor [eax] |
||
396 | jmp @F |
||
397 | .no_SSE: |
||
398 | fnclex |
||
399 | frstor [eax] |
||
400 | @@: |
||
401 | |||
402 | mov [KEY_COUNT], byte 0 ; empty keyboard buffer |
||
403 | mov [BTN_COUNT], byte 0 ; empty button buffer |
||
404 | |||
405 | |||
406 | ; remove defined hotkeys |
||
407 | mov eax, hotkey_list |
||
408 | .loop: |
||
409 | cmp [eax+8], esi |
||
410 | jnz .cont |
||
411 | mov ecx, [eax] |
||
412 | jecxz @f |
||
413 | push dword [eax+12] |
||
414 | pop dword [ecx+12] |
||
415 | @@: |
||
416 | mov ecx, [eax+12] |
||
417 | push dword [eax] |
||
418 | pop dword [ecx] |
||
419 | xor ecx, ecx |
||
420 | mov [eax], ecx |
||
421 | mov [eax+4], ecx |
||
422 | mov [eax+8], ecx |
||
423 | mov [eax+12], ecx |
||
424 | .cont: |
||
425 | add eax, 16 |
||
426 | cmp eax, hotkey_list+256*16 |
||
427 | jb .loop |
||
428 | ; remove hotkeys in buffer |
||
429 | mov eax, hotkey_buffer |
||
430 | .loop2: |
||
431 | cmp [eax], esi |
||
432 | jnz .cont2 |
||
433 | and dword [eax+4], 0 |
||
434 | and dword [eax], 0 |
||
435 | .cont2: |
||
436 | add eax, 8 |
||
437 | cmp eax, hotkey_buffer+120*8 |
||
438 | jb .loop2 |
||
439 | |||
440 | mov ecx, esi ; remove buttons |
||
441 | bnewba2: |
||
442 | mov edi, [BTN_ADDR] |
||
443 | mov eax, edi |
||
444 | cld |
||
445 | movzx ebx, word [edi] |
||
446 | inc bx |
||
447 | bnewba: |
||
448 | dec bx |
||
449 | jz bnmba |
||
450 | add eax, 0x10 |
||
451 | cmp cx, [eax] |
||
452 | jnz bnewba |
||
453 | pusha |
||
454 | mov ecx, ebx |
||
455 | inc ecx |
||
456 | shl ecx, 4 |
||
457 | mov ebx, eax |
||
458 | add eax, 0x10 |
||
459 | call memmove |
||
460 | dec dword [edi] |
||
461 | popa |
||
462 | jmp bnewba2 |
||
463 | bnmba: |
||
464 | |||
465 | pusha ; save window coordinates for window restoring |
||
466 | cld |
||
467 | shl esi, 5 |
||
468 | add esi, window_data |
||
469 | mov eax, [esi+WDATA.box.left] |
||
470 | mov [draw_limits.left], eax |
||
471 | add eax, [esi+WDATA.box.width] |
||
472 | mov [draw_limits.right], eax |
||
473 | mov eax, [esi+WDATA.box.top] |
||
474 | mov [draw_limits.top], eax |
||
475 | add eax, [esi+WDATA.box.height] |
||
476 | mov [draw_limits.bottom], eax |
||
477 | |||
478 | xor eax, eax |
||
479 | mov [esi+WDATA.box.left], eax |
||
480 | mov [esi+WDATA.box.width], eax |
||
481 | mov [esi+WDATA.box.top], eax |
||
482 | mov [esi+WDATA.box.height], eax |
||
483 | mov [esi+WDATA.cl_workarea], eax |
||
484 | mov [esi+WDATA.cl_titlebar], eax |
||
485 | mov [esi+WDATA.cl_frames], eax |
||
486 | mov dword [esi+WDATA.reserved], eax; clear all flags: wstate, redraw, wdrawn |
||
487 | lea edi, [esi-window_data+draw_data] |
||
488 | mov ecx, 32/4 |
||
489 | rep stosd |
||
490 | popa |
||
491 | |||
492 | ; debuggee test |
||
493 | pushad |
||
494 | mov edi, esi |
||
495 | shl edi, 5 |
||
496 | mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] |
||
497 | test eax, eax |
||
498 | jz .nodebug |
||
499 | push 8 |
||
500 | pop ecx |
||
501 | push dword [CURRENT_TASK+edi+TASKDATA.pid]; PID |
||
502 | push 2 |
||
503 | call debugger_notify |
||
504 | pop ecx |
||
505 | pop ecx |
||
506 | .nodebug: |
||
507 | popad |
||
508 | |||
509 | mov ebx, [.slot] |
||
510 | shl ebx, 8 |
||
511 | push ebx |
||
512 | mov ebx, [SLOT_BASE+ebx+APPDATA.pl0_stack] |
||
513 | |||
514 | stdcall kernel_free, ebx |
||
515 | |||
516 | pop ebx |
||
517 | mov ebx, [SLOT_BASE+ebx+APPDATA.cur_dir] |
||
518 | stdcall kernel_free, ebx |
||
519 | |||
520 | mov edi, [.slot] |
||
521 | shl edi, 8 |
||
522 | add edi, SLOT_BASE |
||
523 | |||
524 | mov eax, [edi+APPDATA.io_map] |
||
525 | cmp eax, [SLOT_BASE+256+APPDATA.io_map] |
||
526 | je @F |
||
527 | call free_page |
||
528 | @@: |
||
529 | mov eax, [edi+APPDATA.io_map+4] |
||
530 | cmp eax, [SLOT_BASE+256+APPDATA.io_map+4] |
||
531 | je @F |
||
532 | call free_page |
||
533 | @@: |
||
534 | mov eax, 0x20202020 |
||
535 | stosd |
||
536 | stosd |
||
537 | stosd |
||
538 | mov ecx, 244/4 |
||
539 | xor eax, eax |
||
540 | rep stosd |
||
541 | |||
542 | ; activate window |
||
543 | movzx eax, word [WIN_STACK + esi*2] |
||
544 | cmp eax, [TASK_COUNT] |
||
545 | jne .dont_activate |
||
546 | pushad |
||
547 | .check_next_window: |
||
548 | dec eax |
||
549 | cmp eax, 1 |
||
550 | jbe .nothing_to_activate |
||
551 | lea esi, [WIN_POS+eax*2] |
||
552 | movzx edi, word [esi] ; edi = process |
||
553 | shl edi, 5 |
||
554 | cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots |
||
555 | je .check_next_window |
||
556 | add edi, window_data |
||
557 | ; \begin{diamond}[19.09.2006] |
||
558 | ; skip minimized windows |
||
559 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
||
560 | jnz .check_next_window |
||
561 | ; \end{diamond} |
||
562 | call waredraw |
||
563 | .nothing_to_activate: |
||
564 | popad |
||
565 | .dont_activate: |
||
566 | |||
567 | push esi ; remove hd1 & cd & flp reservation |
||
568 | shl esi, 5 |
||
569 | mov esi, [esi+CURRENT_TASK+TASKDATA.pid] |
||
570 | cmp [hd1_status], esi |
||
571 | jnz @f |
||
572 | call free_hd_channel |
||
573 | and [hd1_status], 0 |
||
574 | @@: |
||
575 | cmp [cd_status], esi |
||
576 | jnz @f |
||
577 | call free_cd_channel |
||
578 | and [cd_status], 0 |
||
579 | @@: |
||
580 | cmp [flp_status], esi |
||
581 | jnz @f |
||
582 | and [flp_status], 0 |
||
583 | @@: |
||
584 | pop esi |
||
585 | cmp [bgrlockpid], esi |
||
586 | jnz @f |
||
587 | and [bgrlockpid], 0 |
||
588 | and [bgrlock], 0 |
||
589 | @@: |
||
590 | |||
591 | pusha ; remove all port reservations |
||
592 | mov edx, esi |
||
593 | shl edx, 5 |
||
594 | add edx, CURRENT_TASK |
||
595 | mov edx, [edx+TASKDATA.pid] |
||
596 | |||
597 | rmpr0: |
||
598 | |||
599 | mov esi, [RESERVED_PORTS] |
||
600 | |||
601 | test esi, esi |
||
602 | jz rmpr9 |
||
603 | |||
604 | rmpr3: |
||
605 | |||
606 | mov edi, esi |
||
607 | shl edi, 4 |
||
608 | add edi, RESERVED_PORTS |
||
609 | |||
610 | cmp edx, [edi] |
||
611 | je rmpr4 |
||
612 | |||
613 | dec esi |
||
614 | jnz rmpr3 |
||
615 | |||
616 | jmp rmpr9 |
||
617 | |||
618 | rmpr4: |
||
619 | |||
620 | mov ecx, 256 |
||
621 | sub ecx, esi |
||
622 | shl ecx, 4 |
||
623 | |||
624 | mov esi, edi |
||
625 | add esi, 16 |
||
626 | cld |
||
627 | rep movsb |
||
628 | |||
629 | dec dword [RESERVED_PORTS] |
||
630 | |||
631 | jmp rmpr0 |
||
632 | |||
633 | rmpr9: |
||
634 | |||
635 | popa |
||
636 | mov edi, esi ; do not run this process slot |
||
637 | shl edi, 5 |
||
638 | mov [edi+CURRENT_TASK + TASKDATA.state], byte 9 |
||
639 | ; debugger test - terminate all debuggees |
||
640 | mov eax, 2 |
||
641 | mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot |
||
642 | .xd0: |
||
643 | cmp eax, [TASK_COUNT] |
||
644 | ja .xd1 |
||
645 | cmp dword [ecx], esi |
||
646 | jnz @f |
||
647 | and dword [ecx], 0 |
||
648 | pushad |
||
649 | xchg eax, ecx |
||
650 | mov ebx, 2 |
||
651 | call sys_system |
||
652 | popad |
||
653 | @@: |
||
654 | inc eax |
||
655 | add ecx, 0x100 |
||
656 | jmp .xd0 |
||
657 | .xd1: |
||
658 | ; call systest |
||
659 | sti ; .. and life goes on |
||
660 | |||
661 | mov eax, [draw_limits.left] |
||
662 | mov ebx, [draw_limits.top] |
||
663 | mov ecx, [draw_limits.right] |
||
664 | mov edx, [draw_limits.bottom] |
||
665 | call calculatescreen |
||
666 | xor eax, eax |
||
667 | xor esi, esi |
||
668 | call redrawscreen |
||
669 | |||
670 | mov [MOUSE_BACKGROUND], byte 0; no mouse background |
||
671 | mov [DONT_DRAW_MOUSE], byte 0; draw mouse |
||
672 | |||
673 | and [application_table_status], 0 |
||
674 | ;mov esi,process_terminated |
||
675 | ;call sys_msg_board_str |
||
676 | add esp, 4 |
||
677 | ret |
||
678 | restore .slot |
||
679 | |||
680 | iglobal |
||
681 | if lang eq ru |
||
682 | boot_sched_1 db '‘®§¤ ЁҐ GDT TSS гЄ § ⥫п',0 |
||
683 | boot_sched_2 db '‘®§¤ ЁҐ IDT в Ў«Ёжл',0 |
||
684 | else |
||
685 | boot_sched_1 db 'Building gdt tss pointer',0 |
||
686 | boot_sched_2 db 'Building IDT table',0 |
||
687 | end if |
||
688 | endg |
||
689 | |||
690 | |||
691 | build_scheduler: |
||
692 | |||
693 | mov esi, boot_sched_1 |
||
694 | call boot_log |
||
695 | ; call build_process_gdt_tss_pointer |
||
696 | |||
697 | ; mov esi,boot_sched_2 |
||
698 | ; call boot_log |
||
699 | |||
700 | ret |