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