Subversion Repositories Kolibri OS

Rev

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

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