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