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