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