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