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