Subversion Repositories Kolibri OS

Rev

Rev 133 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
129 mikedld 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
 
35
        mov    edi, idts+8
36
        mov    esi, sys_int
37
        mov    ecx, 0x40
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
384 mikedld 49
 
129 mikedld 50
        ;mov    edi,8*0x40+idts+8
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
54
        mov    [edi + 6], word (i40 shr 16)
55
 
56
        ret
57
 
58
iglobal
59
  sys_int:
384 mikedld 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
129 mikedld 64
 
384 mikedld 65
    dd except_16, e17,e18, except_19
66
    times 12 dd unknown_interrupt
129 mikedld 67
 
384 mikedld 68
    dd   irq0  , irq_serv.irq_1, p_irq2 , p_irq3     ;irq_serv.irq_3
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
72
 
129 mikedld 73
    times 16 dd unknown_interrupt
74
 
75
    dd   i40
76
endg
77
 
78
macro save_ring3_context
79
{
80
    push    ds es
81
    pushad
82
}
83
macro restore_ring3_context
84
{
85
    popad
86
    pop    es ds
87
}
88
 
89
; simply return control to interrupted process
90
unknown_interrupt:
91
     iret
92
 
93
macro exc_wo_code [num]
94
{
95
  forward
96
  e#num :
97
      save_ring3_context
98
      mov bl, num
99
      jmp exc_c
100
}
101
 
102
macro exc_w_code [num]
103
{
104
  forward
105
  e#num :
106
      add esp, 4
107
      save_ring3_context
108
      mov bl, num
109
      jmp exc_c
110
}
111
 
384 mikedld 112
exc_wo_code 0, 1, 2, 3, 4, 5, 6, 9, 15, 18
129 mikedld 113
exc_w_code 8, 10, 11, 12, 13, 14, 17
114
 
115
exc_c:
116
        mov   ax, os_data
117
        mov   ds, ax
118
        mov   es, ax
119
 
120
; test if debugging
121
        cli
384 mikedld 122
        mov   eax, [CURRENT_TASK]
129 mikedld 123
        shl   eax, 8
384 mikedld 124
        mov   eax, [SLOT_BASE+eax+APPDATA.debugger_slot]
129 mikedld 125
        test  eax, eax
126
        jnz   .debug
127
        sti
128
; not debuggee => say error and terminate
129
        add   esp, 28h
384 mikedld 130
        movzx eax, bl
129 mikedld 131
        mov   [error_interrupt], eax
132
        call  show_error_parameters
384 mikedld 133
 
134
        mov   edx, [TASK_BASE]
129 mikedld 135
        mov   [edx + TASKDATA.state], byte 4
384 mikedld 136
 
129 mikedld 137
        jmp   change_task
138
 
139
.debug:
140
; we are debugged process, notify debugger and suspend ourself
141
; eax=debugger PID
142
        cld
143
        movzx ecx, bl
144
        push  ecx
384 mikedld 145
        mov   ecx, [TASK_BASE]
129 mikedld 146
        push  dword [ecx+TASKDATA.pid]    ; PID of current process
147
        push  12
148
        pop   ecx
149
        push  1        ; 1=exception
150
        call  debugger_notify
151
        pop   ecx
152
        pop   ecx
153
        pop   ecx
384 mikedld 154
        mov   edx, [TASK_BASE]
129 mikedld 155
        mov   byte [edx+TASKDATA.state], 1        ; suspended
156
        call  change_task
157
        restore_ring3_context
158
        iretd
159
 
160
writehex:
161
      pusha
384 mikedld 162
 
129 mikedld 163
      mov  edi, [write_error_to]
164
      mov  esi, 8
165
    @@:
166
      mov  ecx, eax
167
      and  ecx, 0xf
168
 
169
      mov  cl,[ecx+hexletters]
170
      mov  [edi],cl
171
      dec  edi
172
 
173
      shr  eax,4
174
      dec  esi
175
      jnz  @b
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:
384 mikedld 196
 
129 mikedld 197
        mov    [write_error_to],process_pid+43
384 mikedld 198
        mov    eax,[CURRENT_TASK]
129 mikedld 199
        shl    eax, 5
384 mikedld 200
        mov    eax,[CURRENT_TASK+TASKDATA.pid+eax]
129 mikedld 201
        call   writehex
384 mikedld 202
 
129 mikedld 203
        mov    [write_error_to],process_error+43
204
        mov    eax,[error_interrupt]
205
        call   writehex
206
 
207
        cmp    dword [esp+4+4], os_code ; CS
208
        jnz    @f
209
        mov    esi,system_error
210
        call   sys_msg_board_str
211
      @@:
212
        mov    eax, [esp+4] ; EIP
213
 
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
 
230
; irq1  ->  hid/keyboard.inc
231
 
232
 
233
macro irqh [num]
234
{
235
  forward
236
  p_irq#num :
237
     save_ring3_context
238
     mov   edi, num
239
     jmp   irq_c
240
}
241
 
384 mikedld 242
irqh 2,5,7,8,9,10,11
129 mikedld 243
 
244
 irq_c:
245
     mov   ax, os_data
246
     mov   ds, ax
247
     mov   es, ax
248
     call  irqhandler
249
     restore_ring3_context
250
     iret
251
 
252
p_irq6:
253
     save_ring3_context
254
     mov   ax, os_data
255
     mov   ds, ax
256
     mov   es, ax
257
     call  fdc_irq
258
     call  ready_for_next_irq
259
     restore_ring3_context
260
     iret
261
 
262
p_irq3:
263
     save_ring3_context
264
     mov   ax, os_data
265
     mov   ds, ax
266
     mov   es, ax
267
     cmp   [com2_mouse_detected],0
268
     je    old_irq3_handler
269
     call  check_mouse_data_com2
270
     jmp   p_irq3_1
271
 old_irq3_handler:
272
     mov   edi,3
273
     call  irqhandler
384 mikedld 274
  p_irq3_1:
129 mikedld 275
     restore_ring3_context
276
     iret
277
 
278
p_irq4:
279
     save_ring3_context
280
     mov   ax, os_data
281
     mov   ds, ax
282
     mov   es, ax
283
     cmp   [com1_mouse_detected],0
284
     je    old_irq4_handler
285
     call  check_mouse_data_com1
286
     jmp   p_irq4_1
287
 old_irq4_handler:
288
     mov   edi,4
289
     call  irqhandler
384 mikedld 290
  p_irq4_1:
129 mikedld 291
     restore_ring3_context
292
     iret
293
 
294
p_irq12:
295
     save_ring3_context
296
     mov   ax, os_data
297
     mov   ds, ax
298
     mov   es, ax
299
     call  check_mouse_data_ps2
300
     restore_ring3_context
301
     iret
302
 
384 mikedld 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
 
129 mikedld 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
 
335
irqD:
336
     save_ring3_context
337
     mov   ax, os_data
338
     mov   ds, ax
339
     mov   es, ax
384 mikedld 340
 
129 mikedld 341
     mov   dx,0xf0
342
     mov   al,0
343
     out   dx,al
344
 
345
     mov   dx,0xa0
346
     mov   al,0x20
347
     out   dx,al
348
     mov   dx,0x20
349
     out   dx,al
350
 
351
     restore_ring3_context
384 mikedld 352
 
129 mikedld 353
     iret
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
384 mikedld 364
     add    edi,IRQ_SAVE
129 mikedld 365
     mov    ecx,16
366
 
367
     mov    [check_idle_semaphore],5
368
 
369
   irqnewread:
370
     dec    ecx
371
     js     irqover
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
 
384 mikedld 435
        mov  eax,[CURRENT_TASK]
129 mikedld 436
        shl  eax, 5
384 mikedld 437
        add  eax,CURRENT_TASK+TASKDATA.pid
129 mikedld 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
 
384 mikedld 450
        mov  eax,[CURRENT_TASK]
129 mikedld 451
        shl  eax, 5
384 mikedld 452
        add  eax,CURRENT_TASK+TASKDATA.pid
129 mikedld 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
sys_resize_app_memory:
465
        ; eax = 1 - resize
466
        ;     ebx = new amount of memory
467
 
468
        cmp    eax,1
469
        jne    .no_application_mem_resize
470
 
384 mikedld 471
        stdcall new_mem_resize, ebx
472
        mov [esp+36], eax
473
        ret
129 mikedld 474
 
384 mikedld 475
.no_application_mem_resize:
129 mikedld 476
        ret
477
 
478
sys_threads:
479
 
480
; eax=1 create thread
481
;
482
;   ebx=thread start
483
;   ecx=thread stack value
484
;
485
; on return : eax = pid
486
jmp new_sys_threads
487
 
488
iglobal
489
  process_terminating   db 'K : Process - terminating',13,10,0
490
  process_terminated    db 'K : Process - done',13,10,0
384 mikedld 491
  msg_obj_destroy       db 'K : destroy app object',13,10,0
129 mikedld 492
endg
493
 
384 mikedld 494
; param
495
;  esi= slot
129 mikedld 496
 
497
terminate: ; terminate application
498
 
384 mikedld 499
           .slot equ esp   ;locals
500
 
501
           push   esi      ;save .slot
502
 
503
           shl esi, 8
504
           cmp [SLOT_BASE+esi+APPDATA.dir_table], 0
505
           jne @F
506
           add esp, 4
507
           ret
129 mikedld 508
@@:
384 mikedld 509
           mov    esi,process_terminating
510
           call   sys_msg_board_str
511
@@:
512
           cli
513
           cmp   [application_table_status],0
514
           je    term9
515
           sti
516
           call  change_task
517
           jmp   @b
518
term9:
519
           call  set_application_table_status
129 mikedld 520
 
384 mikedld 521
           mov esi, [.slot]
522
           shl esi,8
523
           add esi, SLOT_BASE+APP_OBJ_OFFSET
524
@@:
525
           mov eax, [esi+APPOBJ.fd]
526
           test eax, eax
527
           jz @F
129 mikedld 528
 
384 mikedld 529
           cmp eax, esi
530
           je @F
129 mikedld 531
 
384 mikedld 532
           push esi
533
           call [eax+APPOBJ.destroy]
534
           mov  esi, msg_obj_destroy
535
           call sys_msg_board_str
536
           pop esi
537
           jmp @B
538
@@:
539
           mov eax, [.slot]
540
           shl eax, 8
541
           mov eax,[SLOT_BASE+eax+APPDATA.dir_table]
542
           stdcall destroy_app_space, eax
129 mikedld 543
 
384 mikedld 544
           mov esi, [.slot]
545
           cmp [fpu_owner],esi   ; if user fpu last -> fpu user = 1
546
           jne @F
129 mikedld 547
 
384 mikedld 548
           mov [fpu_owner],1
549
           mov eax, [256+SLOT_BASE+APPDATA.fpu_state]
550
           clts
551
           bt [cpu_caps], CAPS_SSE
552
           jnc .no_SSE
553
           fxrstor [eax]
554
           jmp @F
555
.no_SSE:
556
           fnclex
557
           frstor [eax]
558
@@:
559
 
560
    mov   [KEY_COUNT],byte 0           ; empty keyboard buffer
561
    mov   [BTN_COUNT],byte 0           ; empty button buffer
562
 
563
 
129 mikedld 564
; remove defined hotkeys
565
        mov     eax, hotkey_list
566
.loop:
567
        cmp     [eax+8], esi
568
        jnz     .cont
569
        mov     ecx, [eax]
570
        jecxz   @f
571
        push    dword [eax+12]
572
        pop     dword [ecx+12]
573
@@:
574
        mov     ecx, [eax+12]
575
        push    dword [eax]
576
        pop     dword [ecx]
577
        xor     ecx, ecx
578
        mov     [eax], ecx
579
        mov     [eax+4], ecx
580
        mov     [eax+8], ecx
581
        mov     [eax+12], ecx
582
.cont:
583
        add     eax, 16
584
        cmp     eax, hotkey_list+256*16
585
        jb      .loop
586
; remove hotkeys in buffer
587
        mov     eax, hotkey_buffer
588
.loop2:
589
        cmp     [eax], esi
590
        jnz     .cont2
591
        and     dword [eax+4], 0
592
        and     dword [eax], 0
593
.cont2:
594
        add     eax, 8
595
        cmp     eax, hotkey_buffer+120*8
596
        jb      .loop2
597
 
598
    mov   ecx,esi                 ; remove buttons
599
  bnewba2:
384 mikedld 600
    mov   edi,[BTN_ADDR]
129 mikedld 601
    mov   eax,edi
602
    cld
603
    movzx ebx,word [edi]
604
    inc   bx
605
  bnewba:
606
    dec   bx
607
    jz    bnmba
608
    add   eax,0x10
609
    cmp   cx,[eax]
610
    jnz   bnewba
611
    pusha
612
    mov   ecx,ebx
613
    inc   ecx
614
    shl   ecx,4
615
    mov   ebx,eax
616
    add   eax,0x10
617
    call  memmove
618
    dec   dword [edi]
619
    popa
620
    jmp   bnewba2
621
  bnmba:
622
 
623
    pusha     ; save window coordinates for window restoring
624
    cld
625
    shl   esi,5
626
    add   esi,window_data
627
    mov   eax,[esi+WDATA.box.left]
628
    mov   [dlx],eax
629
    add   eax,[esi+WDATA.box.width]
630
    mov   [dlxe],eax
631
    mov   eax,[esi+WDATA.box.top]
632
    mov   [dly],eax
633
    add   eax,[esi+WDATA.box.height]
634
    mov   [dlye],eax
635
 
384 mikedld 636
    xor   eax, eax
637
    mov   [esi+WDATA.box.left],eax
638
    mov   [esi+WDATA.box.width],eax
129 mikedld 639
    mov   [esi+WDATA.box.top],eax
384 mikedld 640
    mov   [esi+WDATA.box.height],eax
129 mikedld 641
    mov   [esi+WDATA.cl_workarea],eax
642
    mov   [esi+WDATA.cl_titlebar],eax
643
    mov   [esi+WDATA.cl_frames],eax
644
    mov   dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn
645
    lea   edi, [esi-window_data+draw_data]
646
    mov   ecx,32/4
647
    rep   stosd
648
    popa
649
 
650
; debuggee test
651
    pushad
652
    mov  edi, esi
653
    shl  edi, 5
384 mikedld 654
    mov  eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot]
129 mikedld 655
    test eax, eax
656
    jz   .nodebug
657
    push 8
658
    pop  ecx
384 mikedld 659
    push dword [CURRENT_TASK+edi+TASKDATA.pid]   ; PID
129 mikedld 660
    push 2
661
    call debugger_notify
662
    pop  ecx
663
    pop  ecx
664
.nodebug:
665
    popad
666
 
384 mikedld 667
           mov ebx, [.slot]
668
           shl ebx, 8
669
           mov ebx,[SLOT_BASE+ebx+APPDATA.pl0_stack]
129 mikedld 670
 
384 mikedld 671
           stdcall kernel_free, ebx
129 mikedld 672
 
384 mikedld 673
           mov edi, [.slot]
674
           shl edi,8
675
           add edi,SLOT_BASE
676
           mov eax, 0x20202020
677
           stosd
678
           stosd
679
           stosd
680
           mov ecx,244/4
681
           xor eax, eax
682
           rep stosd
129 mikedld 683
 
684
  ; activate window
384 mikedld 685
        movzx  eax, word [WIN_STACK + esi*2]
686
        cmp    eax, [TASK_COUNT]
129 mikedld 687
        jne    .dont_activate
688
        pushad
689
 .check_next_window:
690
        dec    eax
691
        cmp    eax, 1
692
        jbe    .nothing_to_activate
384 mikedld 693
        lea    esi, [WIN_POS+eax*2]
129 mikedld 694
        movzx  edi, word [esi]               ; edi = process
695
        shl    edi, 5
384 mikedld 696
        cmp    [CURRENT_TASK + edi + TASKDATA.state], byte 9  ; skip dead slots
129 mikedld 697
        je     .check_next_window
698
        add    edi, window_data
384 mikedld 699
; \begin{diamond}[19.09.2006]
700
; skip minimized windows
701
        test   [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
702
        jnz    .check_next_window
703
; \end{diamond}
129 mikedld 704
        call   waredraw
705
 .nothing_to_activate:
706
        popad
707
 .dont_activate:
708
 
709
        push    esi     ; remove hd1 & cd & flp reservation
710
        shl     esi, 5
384 mikedld 711
        mov     esi, [esi+CURRENT_TASK+TASKDATA.pid]
129 mikedld 712
        cmp     [hd1_status], esi
713
        jnz     @f
384 mikedld 714
        call    free_hd_channel
129 mikedld 715
        mov     [hd1_status], 0
716
@@:
717
        cmp     [cd_status], esi
718
        jnz     @f
384 mikedld 719
        call    free_cd_channel
129 mikedld 720
        mov     [cd_status], 0
721
@@:
722
        cmp     [flp_status], esi
723
        jnz     @f
724
        mov     [flp_status], 0
725
@@:
726
        pop     esi
727
 
728
    pusha ; remove all irq reservations
729
    mov   eax,esi
730
    shl   eax, 5
384 mikedld 731
    mov   eax,[eax+CURRENT_TASK+TASKDATA.pid]
129 mikedld 732
    mov   edi,irq_owner
733
    mov   ecx,16
734
  newirqfree:
735
    scasd
736
    jne   nofreeirq
737
    mov   [edi-4],dword 0
738
  nofreeirq:
739
    loop   newirqfree
740
    popa
741
 
742
    pusha                     ; remove all port reservations
743
    mov   edx,esi
744
    shl   edx, 5
384 mikedld 745
    add   edx,CURRENT_TASK
129 mikedld 746
    mov   edx,[edx+TASKDATA.pid]
747
 
748
  rmpr0:
749
 
384 mikedld 750
    mov   esi,[RESERVED_PORTS]
129 mikedld 751
 
752
    cmp   esi,0
753
    je    rmpr9
754
 
755
  rmpr3:
756
 
757
    mov   edi,esi
758
    shl   edi,4
384 mikedld 759
    add   edi,RESERVED_PORTS
129 mikedld 760
 
761
    cmp   edx,[edi]
762
    je    rmpr4
763
 
764
    dec   esi
765
    jnz   rmpr3
766
 
767
    jmp   rmpr9
768
 
769
  rmpr4:
770
 
771
    mov   ecx,256
772
    sub   ecx,esi
773
    shl   ecx,4
774
 
775
    mov   esi,edi
776
    add   esi,16
777
    cld
778
    rep   movsb
779
 
384 mikedld 780
    dec   dword [RESERVED_PORTS]
129 mikedld 781
 
782
    jmp   rmpr0
783
 
784
  rmpr9:
785
 
786
    popa
787
    mov  edi,esi         ; do not run this process slot
788
    shl  edi, 5
384 mikedld 789
    mov  [edi+CURRENT_TASK + TASKDATA.state],byte 9
129 mikedld 790
; debugger test - terminate all debuggees
791
    mov  eax, 2
384 mikedld 792
    mov  ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot
129 mikedld 793
.xd0:
384 mikedld 794
    cmp  eax, [TASK_COUNT]
129 mikedld 795
    ja   .xd1
796
    cmp  dword [ecx], esi
797
    jnz  @f
798
    and  dword [ecx], 0
799
    pushad
800
    xchg eax, ebx
801
    mov  eax, 2
802
    call sys_system
803
    popad
804
@@:
805
    inc  eax
806
    add  ecx, 0x100
807
    jmp  .xd0
808
.xd1:
809
;    call  systest
810
    sti  ; .. and life goes on
811
 
812
    mov   eax, [dlx]
813
    mov   ebx, [dly]
814
    mov   ecx, [dlxe]
815
    mov   edx, [dlye]
816
    call  [calculatescreen]
817
    xor   eax, eax
818
    xor   esi, esi
819
    call  redrawscreen
820
 
384 mikedld 821
    mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
822
    mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
129 mikedld 823
 
824
    mov   [application_table_status],0
825
    mov   esi,process_terminated
826
    call  sys_msg_board_str
384 mikedld 827
    add esp, 4
129 mikedld 828
    ret
384 mikedld 829
restore .slot
129 mikedld 830
 
831
iglobal
832
  boot_sched_1    db   'Building gdt tss pointer',0
833
  boot_sched_2    db   'Building IDT table',0
834
endg
835
 
836
 
837
build_scheduler:
838
 
839
        mov    esi,boot_sched_1
840
        call   boot_log
841
        call   build_process_gdt_tss_pointer
842
 
843
        mov    esi,boot_sched_2
844
        call   boot_log
845
        call   build_interrupt_table
846
 
847
        ret
848