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