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