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