Subversion Repositories Kolibri OS

Rev

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