Rev 888 | Rev 928 | 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: 889 $ |
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] |
||
860 | serge | 178 | mov eax, [error_interrupt] |
179 | cmp al, 0x08 |
||
180 | jne @f |
||
181 | DEBUGF 1, "K : Double fault\n" |
||
182 | jmp defined_error |
||
183 | @@: |
||
184 | cmp al, 0x0a |
||
185 | jne @f |
||
186 | DEBUGF 1, "K : Invalid TSS\n" |
||
187 | jmp defined_error |
||
188 | @@: |
||
189 | cmp al, 0x0b |
||
190 | jne @f |
||
191 | DEBUGF 1, "K : Segment not present\n" |
||
192 | jmp defined_error |
||
193 | @@: |
||
194 | cmp al, 0x0c |
||
195 | jne @f |
||
196 | DEBUGF 1, "K : Stack fault\n" |
||
197 | jmp defined_error |
||
198 | @@: |
||
199 | cmp al, 0x0d |
||
200 | jne @f |
||
201 | DEBUGF 1, "K : General protection fault\n" |
||
202 | jmp defined_error |
||
203 | @@: |
||
204 | cmp al, 0x0e |
||
205 | jne @f |
||
206 | DEBUGF 1, "K : Page fault\n" |
||
207 | jmp defined_error |
||
208 | @@: |
||
209 | DEBUGF 1, "K : Undefined Exception\n" |
||
210 | defined_error: |
||
656 | mikedld | 211 | DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [esp + 0x20], [esp - 12 + 0x20], [esp - 4 + 0x20] |
212 | DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [esp - 8 + 0x20], [esp - 24 + 0x20], [esp - 28 + 0x20] |
||
213 | DEBUGF 1, "K : EBP : %x EIP : %x ", [esp - 20 + 0x20], [esp + 4 + 0x20] |
||
164 | serge | 214 | |
656 | mikedld | 215 | mov eax, [esp + 8 + 0x20] |
216 | mov edi, msg_sel_app |
||
217 | mov ebx, [esp + 16 + 0x20] |
||
218 | cmp eax, app_code |
||
759 | Rus | 219 | je @f |
656 | mikedld | 220 | mov edi, msg_sel_ker |
221 | mov ebx, [esp - 16 + 0x20] |
||
222 | @@: |
||
658 | Ghost | 223 | DEBUGF 1, "ESP : %x\nK : Flags : %x CS : %x (%s)\n", ebx, [esp + 12 + 0x20], eax, edi |
224 | ret |
||
225 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
||
164 | serge | 226 | |
16 | poddubny | 227 | |
6 | poddubny | 228 | ; irq1 -> hid/keyboard.inc |
10 | poddubny | 229 | macro irqh [num] |
8 | poddubny | 230 | { |
231 | forward |
||
232 | p_irq#num : |
||
233 | mov edi, num |
||
788 | diamond | 234 | jmp irqhandler |
8 | poddubny | 235 | } |
1 | ha | 236 | |
769 | Rus | 237 | irqh 2,3,4,5,7,8,9,10,11 |
1 | ha | 238 | |
11 | poddubny | 239 | |
240 | p_irq6: |
||
40 | halyavin | 241 | save_ring3_context |
465 | serge | 242 | mov ax, app_data ;os_data |
11 | poddubny | 243 | mov ds, ax |
244 | mov es, ax |
||
245 | call fdc_irq |
||
33 | mario79 | 246 | call ready_for_next_irq |
40 | halyavin | 247 | restore_ring3_context |
33 | mario79 | 248 | iret |
15 | poddubny | 249 | |
250 | |||
160 | diamond | 251 | p_irq14: |
759 | Rus | 252 | save_ring3_context |
253 | mov ax, app_data ;os_data |
||
254 | mov ds, ax |
||
255 | mov es, ax |
||
256 | mov byte [BOOT_VAR + 0x48E], 0xFF |
||
257 | call [irq14_func] |
||
258 | call ready_for_next_irq_1 |
||
259 | restore_ring3_context |
||
260 | iret |
||
160 | diamond | 261 | p_irq15: |
759 | Rus | 262 | save_ring3_context |
263 | mov ax, app_data ;os_data |
||
264 | mov ds, ax |
||
265 | mov es, ax |
||
266 | mov byte [BOOT_VAR + 0x48E], 0xFF |
||
267 | call [irq15_func] |
||
268 | call ready_for_next_irq_1 |
||
269 | restore_ring3_context |
||
270 | iret |
||
160 | diamond | 271 | |
33 | mario79 | 272 | ready_for_next_irq: |
273 | mov [check_idle_semaphore],5 |
||
274 | mov al, 0x20 |
||
275 | out 0x20, al |
||
276 | ret |
||
277 | |||
278 | ready_for_next_irq_1: |
||
279 | mov [check_idle_semaphore],5 |
||
280 | mov al, 0x20 |
||
281 | out 0xa0,al |
||
282 | out 0x20, al |
||
283 | ret |
||
284 | |||
6 | poddubny | 285 | irqD: |
40 | halyavin | 286 | save_ring3_context |
465 | serge | 287 | mov ax, app_data ;os_data |
8 | poddubny | 288 | mov ds, ax |
289 | mov es, ax |
||
164 | serge | 290 | |
6 | poddubny | 291 | mov dx,0xf0 |
292 | mov al,0 |
||
293 | out dx,al |
||
1 | ha | 294 | |
6 | poddubny | 295 | mov dx,0xa0 |
296 | mov al,0x20 |
||
297 | out dx,al |
||
298 | mov dx,0x20 |
||
40 | halyavin | 299 | out dx,al |
300 | |||
301 | restore_ring3_context |
||
164 | serge | 302 | |
8 | poddubny | 303 | iret |
1 | ha | 304 | |
305 | |||
306 | irqhandler: |
||
307 | |||
759 | Rus | 308 | mov esi,edi ; 1 |
309 | shl esi,6 ; 1 |
||
1 | ha | 310 | add esi,irq00read ; 1 |
759 | Rus | 311 | shl edi,12 ; 1 |
381 | serge | 312 | add edi,IRQ_SAVE |
75 | diamond | 313 | mov ecx,16 |
1 | ha | 314 | |
315 | irqnewread: |
||
75 | diamond | 316 | dec ecx |
317 | js irqover |
||
1 | ha | 318 | |
759 | Rus | 319 | movzx edx, word [esi] ; 2+ |
1 | ha | 320 | |
759 | Rus | 321 | test edx, edx ; 1 |
1 | ha | 322 | jz irqover |
323 | |||
324 | |||
759 | Rus | 325 | mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size |
326 | mov eax, 4000 ; + 0x4 dword - data begin offset |
||
327 | cmp ebx, eax |
||
1 | ha | 328 | je irqfull |
759 | Rus | 329 | add ebx, [edi + 0x4] ; add data size to data begin offset |
330 | cmp ebx, eax ; if end of buffer, begin cycle again |
||
331 | jb @f |
||
1 | ha | 332 | |
759 | Rus | 333 | xor ebx, ebx |
1 | ha | 334 | |
759 | Rus | 335 | @@: |
336 | add ebx, edi |
||
337 | movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word |
||
338 | dec eax |
||
339 | jz irqbyte |
||
340 | dec eax |
||
341 | jnz noirqword |
||
1 | ha | 342 | |
759 | Rus | 343 | in ax,dx |
344 | cmp ebx, 3999 ; check for address odd in the end of buffer |
||
345 | jne .odd |
||
346 | mov [ebx + 0x10], ax |
||
347 | jmp .add_size |
||
348 | .odd: |
||
349 | mov [ebx + 0x10], al ; I could make mistake here :) |
||
350 | mov [edi + 0x10], ah |
||
351 | .add_size: |
||
352 | add dword [edi], 2 |
||
353 | jmp nextport |
||
1 | ha | 354 | |
355 | |||
759 | Rus | 356 | irqbyte: |
357 | in al,dx |
||
358 | mov [ebx + 0x10],al |
||
359 | inc dword [edi] |
||
360 | nextport: |
||
1 | ha | 361 | add esi,4 |
362 | jmp irqnewread |
||
363 | |||
759 | Rus | 364 | |
1 | ha | 365 | noirqword: |
366 | irqfull: |
||
367 | irqover: |
||
368 | |||
369 | ret |
||
370 | |||
371 | |||
372 | |||
373 | set_application_table_status: |
||
759 | Rus | 374 | push eax |
1 | ha | 375 | |
759 | Rus | 376 | mov eax,[CURRENT_TASK] |
377 | shl eax, 5 |
||
378 | add eax,CURRENT_TASK+TASKDATA.pid |
||
379 | mov eax,[eax] |
||
1 | ha | 380 | |
759 | Rus | 381 | mov [application_table_status],eax |
1 | ha | 382 | |
759 | Rus | 383 | pop eax |
1 | ha | 384 | |
759 | Rus | 385 | ret |
1 | ha | 386 | |
387 | |||
388 | clear_application_table_status: |
||
759 | Rus | 389 | push eax |
1 | ha | 390 | |
759 | Rus | 391 | mov eax,[CURRENT_TASK] |
392 | shl eax, 5 |
||
393 | add eax,CURRENT_TASK+TASKDATA.pid |
||
394 | mov eax,[eax] |
||
1 | ha | 395 | |
759 | Rus | 396 | cmp eax,[application_table_status] |
397 | jne apptsl1 |
||
398 | mov [application_table_status],0 |
||
1 | ha | 399 | apptsl1: |
400 | |||
759 | Rus | 401 | pop eax |
1 | ha | 402 | |
759 | Rus | 403 | ret |
1 | ha | 404 | |
405 | sys_resize_app_memory: |
||
759 | Rus | 406 | ; eax = 1 - resize |
407 | ; ebx = new amount of memory |
||
1 | ha | 408 | |
759 | Rus | 409 | cmp eax,1 |
410 | jne .no_application_mem_resize |
||
1 | ha | 411 | |
759 | Rus | 412 | stdcall new_mem_resize, ebx |
413 | mov [esp+36], eax |
||
414 | ret |
||
1 | ha | 415 | |
164 | serge | 416 | .no_application_mem_resize: |
759 | Rus | 417 | ret |
1 | ha | 418 | |
419 | sys_threads: |
||
420 | |||
421 | ; eax=1 create thread |
||
422 | ; |
||
423 | ; ebx=thread start |
||
424 | ; ecx=thread stack value |
||
425 | ; |
||
426 | ; on return : eax = pid |
||
427 | jmp new_sys_threads |
||
428 | |||
429 | iglobal |
||
759 | Rus | 430 | process_terminating db 'K : Process - terminating',13,10,0 |
431 | process_terminated db 'K : Process - done',13,10,0 |
||
432 | msg_obj_destroy db 'K : destroy app object',13,10,0 |
||
1 | ha | 433 | endg |
434 | |||
329 | serge | 435 | ; param |
436 | ; esi= slot |
||
1 | ha | 437 | |
438 | terminate: ; terminate application |
||
439 | |||
759 | Rus | 440 | .slot equ esp ;locals |
329 | serge | 441 | |
759 | Rus | 442 | push esi ;save .slot |
334 | serge | 443 | |
759 | Rus | 444 | shl esi, 8 |
445 | cmp [SLOT_BASE+esi+APPDATA.dir_table], 0 |
||
446 | jne @F |
||
447 | pop esi |
||
448 | shl esi, 5 |
||
449 | mov [CURRENT_TASK+esi+TASKDATA.state], 9 |
||
450 | ret |
||
334 | serge | 451 | @@: |
759 | Rus | 452 | ;mov esi,process_terminating |
453 | ;call sys_msg_board_str |
||
454 | DEBUGF 1,"%s",process_terminating |
||
40 | halyavin | 455 | @@: |
759 | Rus | 456 | cli |
457 | cmp [application_table_status],0 |
||
458 | je term9 |
||
459 | sti |
||
460 | call change_task |
||
461 | jmp @b |
||
329 | serge | 462 | term9: |
759 | Rus | 463 | call set_application_table_status |
1 | ha | 464 | |
709 | diamond | 465 | ; if the process is in V86 mode... |
759 | Rus | 466 | mov eax, [.slot] |
467 | shl eax, 8 |
||
468 | mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] |
||
469 | add esi, RING0_STACK_SIZE |
||
470 | cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi |
||
471 | jz .nov86 |
||
709 | diamond | 472 | ; ...it has page directory for V86 mode |
759 | Rus | 473 | mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0] |
474 | mov ecx, [esi+4] |
||
475 | mov [eax+SLOT_BASE+APPDATA.dir_table], ecx |
||
709 | diamond | 476 | ; ...and I/O permission map for V86 mode |
759 | Rus | 477 | mov ecx, [esi+12] |
478 | mov [eax+SLOT_BASE+APPDATA.io_map], ecx |
||
479 | mov ecx, [esi+8] |
||
480 | mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx |
||
709 | diamond | 481 | .nov86: |
482 | |||
759 | Rus | 483 | mov esi, [.slot] |
484 | shl esi,8 |
||
485 | add esi, SLOT_BASE+APP_OBJ_OFFSET |
||
329 | serge | 486 | @@: |
759 | Rus | 487 | mov eax, [esi+APPOBJ.fd] |
488 | test eax, eax |
||
489 | jz @F |
||
334 | serge | 490 | |
759 | Rus | 491 | cmp eax, esi |
492 | je @F |
||
164 | serge | 493 | |
759 | Rus | 494 | push esi |
495 | call [eax+APPOBJ.destroy] |
||
496 | DEBUGF 1,"%s",msg_obj_destroy |
||
497 | pop esi |
||
498 | jmp @B |
||
329 | serge | 499 | @@: |
759 | Rus | 500 | mov eax, [.slot] |
501 | shl eax, 8 |
||
502 | mov eax,[SLOT_BASE+eax+APPDATA.dir_table] |
||
888 | serge | 503 | stdcall destroy_app_space, eax |
1 | ha | 504 | |
759 | Rus | 505 | mov esi, [.slot] |
506 | cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 |
||
507 | jne @F |
||
164 | serge | 508 | |
759 | Rus | 509 | mov [fpu_owner],1 |
510 | mov eax, [256+SLOT_BASE+APPDATA.fpu_state] |
||
511 | clts |
||
512 | bt [cpu_caps], CAPS_SSE |
||
513 | jnc .no_SSE |
||
514 | fxrstor [eax] |
||
515 | jmp @F |
||
203 | serge | 516 | .no_SSE: |
759 | Rus | 517 | fnclex |
518 | frstor [eax] |
||
357 | serge | 519 | @@: |
203 | serge | 520 | |
759 | Rus | 521 | mov [KEY_COUNT],byte 0 ; empty keyboard buffer |
522 | mov [BTN_COUNT],byte 0 ; empty button buffer |
||
1 | ha | 523 | |
524 | |||
92 | diamond | 525 | ; remove defined hotkeys |
759 | Rus | 526 | mov eax, hotkey_list |
92 | diamond | 527 | .loop: |
759 | Rus | 528 | cmp [eax+8], esi |
529 | jnz .cont |
||
530 | mov ecx, [eax] |
||
531 | jecxz @f |
||
532 | push dword [eax+12] |
||
533 | pop dword [ecx+12] |
||
92 | diamond | 534 | @@: |
759 | Rus | 535 | mov ecx, [eax+12] |
536 | push dword [eax] |
||
537 | pop dword [ecx] |
||
538 | xor ecx, ecx |
||
539 | mov [eax], ecx |
||
540 | mov [eax+4], ecx |
||
541 | mov [eax+8], ecx |
||
542 | mov [eax+12], ecx |
||
92 | diamond | 543 | .cont: |
759 | Rus | 544 | add eax, 16 |
545 | cmp eax, hotkey_list+256*16 |
||
546 | jb .loop |
||
92 | diamond | 547 | ; remove hotkeys in buffer |
759 | Rus | 548 | mov eax, hotkey_buffer |
92 | diamond | 549 | .loop2: |
759 | Rus | 550 | cmp [eax], esi |
551 | jnz .cont2 |
||
552 | and dword [eax+4], 0 |
||
553 | and dword [eax], 0 |
||
92 | diamond | 554 | .cont2: |
759 | Rus | 555 | add eax, 8 |
556 | cmp eax, hotkey_buffer+120*8 |
||
557 | jb .loop2 |
||
92 | diamond | 558 | |
759 | Rus | 559 | mov ecx,esi ; remove buttons |
1 | ha | 560 | bnewba2: |
381 | serge | 561 | mov edi,[BTN_ADDR] |
1 | ha | 562 | mov eax,edi |
563 | cld |
||
564 | movzx ebx,word [edi] |
||
565 | inc bx |
||
566 | bnewba: |
||
567 | dec bx |
||
759 | Rus | 568 | jz bnmba |
1 | ha | 569 | add eax,0x10 |
570 | cmp cx,[eax] |
||
571 | jnz bnewba |
||
572 | pusha |
||
573 | mov ecx,ebx |
||
574 | inc ecx |
||
575 | shl ecx,4 |
||
576 | mov ebx,eax |
||
577 | add eax,0x10 |
||
578 | call memmove |
||
579 | dec dword [edi] |
||
580 | popa |
||
581 | jmp bnewba2 |
||
582 | bnmba: |
||
583 | |||
584 | pusha ; save window coordinates for window restoring |
||
585 | cld |
||
586 | shl esi,5 |
||
587 | add esi,window_data |
||
114 | mikedld | 588 | mov eax,[esi+WDATA.box.left] |
102 | poddubny | 589 | mov [dlx],eax |
114 | mikedld | 590 | add eax,[esi+WDATA.box.width] |
102 | poddubny | 591 | mov [dlxe],eax |
114 | mikedld | 592 | mov eax,[esi+WDATA.box.top] |
102 | poddubny | 593 | mov [dly],eax |
114 | mikedld | 594 | add eax,[esi+WDATA.box.height] |
102 | poddubny | 595 | mov [dlye],eax |
1 | ha | 596 | |
142 | diamond | 597 | xor eax, eax |
598 | mov [esi+WDATA.box.left],eax |
||
599 | mov [esi+WDATA.box.width],eax |
||
114 | mikedld | 600 | mov [esi+WDATA.box.top],eax |
142 | diamond | 601 | mov [esi+WDATA.box.height],eax |
115 | poddubny | 602 | mov [esi+WDATA.cl_workarea],eax |
603 | mov [esi+WDATA.cl_titlebar],eax |
||
604 | mov [esi+WDATA.cl_frames],eax |
||
605 | mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn |
||
102 | poddubny | 606 | lea edi, [esi-window_data+draw_data] |
1 | ha | 607 | mov ecx,32/4 |
608 | rep stosd |
||
609 | popa |
||
610 | |||
40 | halyavin | 611 | ; debuggee test |
612 | pushad |
||
613 | mov edi, esi |
||
614 | shl edi, 5 |
||
380 | serge | 615 | mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] |
40 | halyavin | 616 | test eax, eax |
759 | Rus | 617 | jz .nodebug |
40 | halyavin | 618 | push 8 |
619 | pop ecx |
||
759 | Rus | 620 | push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID |
40 | halyavin | 621 | push 2 |
622 | call debugger_notify |
||
623 | pop ecx |
||
624 | pop ecx |
||
625 | .nodebug: |
||
889 | serge | 626 | popad |
40 | halyavin | 627 | |
839 | serge | 628 | mov edi, [.slot] |
629 | shl edi, 8 |
||
889 | serge | 630 | add edi,SLOT_BASE |
1 | ha | 631 | |
888 | serge | 632 | mov ecx,[edi+APPDATA.pl0_stack] |
633 | sub ecx, OS_BASE |
||
634 | call @core_free@4 |
||
1 | ha | 635 | |
888 | serge | 636 | mov ecx,[edi+APPDATA.cur_dir] |
637 | sub ecx, OS_BASE |
||
638 | call @core_free@4 |
||
521 | diamond | 639 | |
888 | serge | 640 | mov ecx, [edi+APPDATA.io_map] |
641 | cmp ecx, (tss._io_map_0-OS_BASE+PG_MAP) |
||
889 | serge | 642 | je @F |
643 | |||
888 | serge | 644 | call @core_free@4 |
465 | serge | 645 | @@: |
888 | serge | 646 | mov ecx, [edi+APPDATA.io_map+4] |
647 | cmp ecx, (tss._io_map_1-OS_BASE+PG_MAP) |
||
889 | serge | 648 | je @F |
649 | |||
888 | serge | 650 | call @core_free@4 |
465 | serge | 651 | @@: |
759 | Rus | 652 | mov eax, 0x20202020 |
653 | stosd |
||
654 | stosd |
||
655 | stosd |
||
656 | mov ecx,244/4 |
||
657 | xor eax, eax |
||
658 | rep stosd |
||
1 | ha | 659 | |
102 | poddubny | 660 | ; activate window |
759 | Rus | 661 | movzx eax, word [WIN_STACK + esi*2] |
662 | cmp eax, [TASK_COUNT] |
||
663 | jne .dont_activate |
||
664 | pushad |
||
102 | poddubny | 665 | .check_next_window: |
759 | Rus | 666 | dec eax |
667 | cmp eax, 1 |
||
668 | jbe .nothing_to_activate |
||
669 | lea esi, [WIN_POS+eax*2] |
||
670 | movzx edi, word [esi] ; edi = process |
||
671 | shl edi, 5 |
||
672 | cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots |
||
673 | je .check_next_window |
||
674 | add edi, window_data |
||
154 | diamond | 675 | ; \begin{diamond}[19.09.2006] |
676 | ; skip minimized windows |
||
759 | Rus | 677 | test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
678 | jnz .check_next_window |
||
154 | diamond | 679 | ; \end{diamond} |
759 | Rus | 680 | call waredraw |
102 | poddubny | 681 | .nothing_to_activate: |
759 | Rus | 682 | popad |
102 | poddubny | 683 | .dont_activate: |
684 | |||
759 | Rus | 685 | push esi ; remove hd1 & cd & flp reservation |
686 | shl esi, 5 |
||
687 | mov esi, [esi+CURRENT_TASK+TASKDATA.pid] |
||
688 | cmp [hd1_status], esi |
||
689 | jnz @f |
||
690 | call free_hd_channel |
||
691 | mov [hd1_status], 0 |
||
92 | diamond | 692 | @@: |
759 | Rus | 693 | cmp [cd_status], esi |
694 | jnz @f |
||
695 | call free_cd_channel |
||
696 | mov [cd_status], 0 |
||
92 | diamond | 697 | @@: |
759 | Rus | 698 | cmp [flp_status], esi |
699 | jnz @f |
||
700 | mov [flp_status], 0 |
||
92 | diamond | 701 | @@: |
759 | Rus | 702 | pop esi |
703 | cmp [bgrlockpid], esi |
||
704 | jnz @f |
||
705 | and [bgrlockpid], 0 |
||
706 | mov [bgrlock], 0 |
||
546 | diamond | 707 | @@: |
1 | ha | 708 | |
709 | pusha ; remove all irq reservations |
||
92 | diamond | 710 | mov eax,esi |
115 | poddubny | 711 | shl eax, 5 |
379 | serge | 712 | mov eax,[eax+CURRENT_TASK+TASKDATA.pid] |
1 | ha | 713 | mov edi,irq_owner |
774 | Rus | 714 | xor ebx, ebx |
715 | xor edx, edx |
||
1 | ha | 716 | newirqfree: |
774 | Rus | 717 | cmp [edi + 4 * ebx], eax |
1 | ha | 718 | jne nofreeirq |
774 | Rus | 719 | mov [edi + 4 * ebx], edx ; remove irq reservation |
720 | mov [irq_tab + 4 * ebx], edx ; remove irq handler |
||
721 | mov [irq_rights + 4 * ebx], edx ; set access rights to full access |
||
1 | ha | 722 | nofreeirq: |
774 | Rus | 723 | inc ebx |
724 | cmp ebx, 16 |
||
725 | jb newirqfree |
||
1 | ha | 726 | popa |
727 | |||
759 | Rus | 728 | pusha ; remove all port reservations |
1 | ha | 729 | mov edx,esi |
115 | poddubny | 730 | shl edx, 5 |
379 | serge | 731 | add edx,CURRENT_TASK |
115 | poddubny | 732 | mov edx,[edx+TASKDATA.pid] |
1 | ha | 733 | |
734 | rmpr0: |
||
735 | |||
381 | serge | 736 | mov esi,[RESERVED_PORTS] |
1 | ha | 737 | |
738 | cmp esi,0 |
||
759 | Rus | 739 | je rmpr9 |
1 | ha | 740 | |
741 | rmpr3: |
||
742 | |||
743 | mov edi,esi |
||
744 | shl edi,4 |
||
381 | serge | 745 | add edi,RESERVED_PORTS |
1 | ha | 746 | |
747 | cmp edx,[edi] |
||
759 | Rus | 748 | je rmpr4 |
1 | ha | 749 | |
750 | dec esi |
||
751 | jnz rmpr3 |
||
752 | |||
753 | jmp rmpr9 |
||
754 | |||
755 | rmpr4: |
||
756 | |||
757 | mov ecx,256 |
||
758 | sub ecx,esi |
||
759 | shl ecx,4 |
||
760 | |||
761 | mov esi,edi |
||
762 | add esi,16 |
||
763 | cld |
||
764 | rep movsb |
||
765 | |||
381 | serge | 766 | dec dword [RESERVED_PORTS] |
1 | ha | 767 | |
768 | jmp rmpr0 |
||
769 | |||
770 | rmpr9: |
||
771 | |||
772 | popa |
||
759 | Rus | 773 | mov edi,esi ; do not run this process slot |
6 | poddubny | 774 | shl edi, 5 |
379 | serge | 775 | mov [edi+CURRENT_TASK + TASKDATA.state],byte 9 |
40 | halyavin | 776 | ; debugger test - terminate all debuggees |
777 | mov eax, 2 |
||
380 | serge | 778 | mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot |
40 | halyavin | 779 | .xd0: |
379 | serge | 780 | cmp eax, [TASK_COUNT] |
759 | Rus | 781 | ja .xd1 |
40 | halyavin | 782 | cmp dword [ecx], esi |
783 | jnz @f |
||
784 | and dword [ecx], 0 |
||
785 | pushad |
||
684 | diamond | 786 | xchg eax, ecx |
787 | mov ebx, 2 |
||
40 | halyavin | 788 | call sys_system |
789 | popad |
||
790 | @@: |
||
791 | inc eax |
||
792 | add ecx, 0x100 |
||
793 | jmp .xd0 |
||
794 | .xd1: |
||
1 | ha | 795 | ; call systest |
796 | sti ; .. and life goes on |
||
797 | |||
112 | poddubny | 798 | mov eax, [dlx] |
799 | mov ebx, [dly] |
||
800 | mov ecx, [dlxe] |
||
801 | mov edx, [dlye] |
||
1 | ha | 802 | call calculatescreen |
803 | xor eax, eax |
||
804 | xor esi, esi |
||
805 | call redrawscreen |
||
806 | |||
381 | serge | 807 | mov [MOUSE_BACKGROUND],byte 0 ; no mouse background |
808 | mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse |
||
1 | ha | 809 | |
810 | mov [application_table_status],0 |
||
506 | mikedld | 811 | ;mov esi,process_terminated |
812 | ;call sys_msg_board_str |
||
813 | DEBUGF 1,"%s",process_terminated |
||
357 | serge | 814 | add esp, 4 |
1 | ha | 815 | ret |
345 | serge | 816 | restore .slot |
1 | ha | 817 | |
818 | iglobal |
||
759 | Rus | 819 | boot_sched_1 db 'Building gdt tss pointer',0 |
820 | boot_sched_2 db 'Building IDT table',0 |
||
1 | ha | 821 | endg |
822 | |||
823 | |||
824 | build_scheduler: |
||
825 | |||
759 | Rus | 826 | mov esi,boot_sched_1 |
827 | call boot_log |
||
465 | serge | 828 | ; call build_process_gdt_tss_pointer |
1 | ha | 829 | |
465 | serge | 830 | ; mov esi,boot_sched_2 |
831 | ; call boot_log |
||
1 | ha | 832 | |
759 | Rus | 833 | ret |