Subversion Repositories Kolibri OS

Rev

Rev 1989 | Rev 2104 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1989 Rev 2089
Line 66... Line 66...
66
;;
66
;;
67
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
67
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 68... Line 68...
68
 
68
 
Line 69... Line 69...
69
include 'macros.inc'
69
include 'macros.inc'
Line 70... Line 70...
70
 
70
 
Line 71... Line 71...
71
$Revision: 1989 $
71
$Revision: 2089 $
Line 1019... Line 1019...
1019
        sti
1019
        sti
1020
        call change_task
1020
        call change_task
Line 1021... Line 1021...
1021
 
1021
 
Line 1022... Line -...
1022
        jmp osloop
-
 
Line 1023... Line 1022...
1023
 
1022
        jmp osloop
Line 1024... Line 1023...
1024
;        jmp   $                      ; wait here for timer to take control
1023
 
1025
 
1024
 
Line 1054... Line 1053...
1054
;                                                                    ;
1053
;                                                                    ;
1055
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1054
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1056
align 32
1055
align 32
1057
osloop:
1056
osloop:
1058
        call   [draw_pointer]
1057
        call   [draw_pointer]
1059
        call    window_check_events
1058
        call    window_check_events
1060
        call    mouse_check_events
1059
        call    mouse_check_events
1061
        call   checkmisc
1060
        call   checkmisc
1062
        call   checkVga_N13
1061
        call   checkVga_N13
1063
        call   stack_handler
1062
        call   stack_handler
1064
        call   checkidle
1063
        call   checkidle
1065
        call   check_fdd_motor_status
1064
        call   check_fdd_motor_status
Line 1119... Line 1118...
1119
;                                                                      ;
1118
;                                                                      ;
1120
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1119
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 1121... Line 1120...
1121
 
1120
 
Line 1122... Line -...
1122
reserve_irqs_ports:
-
 
1123
 
-
 
1124
        push eax
-
 
1125
        xor	eax,eax
-
 
1126
		inc	eax
-
 
1127
        mov  byte [irq_owner+4*0],al		;1    ; timer
-
 
1128
        ;mov  [irq_owner+4*1], 1    ; keyboard
-
 
1129
        mov  byte [irq_owner+4*6],al		;1    ; floppy diskette
-
 
1130
        mov  byte [irq_owner+4*13],al	;1   ; math co-pros
-
 
1131
        mov  byte [irq_owner+4*14],al	;1   ; ide I
-
 
Line 1132... Line 1121...
1132
        mov  byte [irq_owner+4*15],al	;1   ; ide II
1121
reserve_irqs_ports:
1133
        pop  eax
-
 
1134
 
1122
 
1135
; RESERVE PORTS
-
 
1136
	push  4
1123
 
1137
        pop   dword [RESERVED_PORTS]	;,edi
-
 
1138
 
-
 
1139
	push  1
-
 
Line 1140... Line -...
1140
        pop   dword [RESERVED_PORTS+16+0]	;,dword 1
-
 
1141
        and   dword [RESERVED_PORTS+16+4],0	;,dword 0x0
-
 
1142
        mov   dword [RESERVED_PORTS+16+8],0x2d	;,dword 0x2d
1124
; RESERVE PORTS
1143
 
-
 
1144
	push  1
-
 
1145
        pop   dword [RESERVED_PORTS+32+0]	;,dword 1
-
 
Line 1146... Line 1125...
1146
        push  0x30
1125
        mov eax, RESERVED_PORTS
1147
        pop   dword [RESERVED_PORTS+32+4]	;,dword 0x30
1126
        mov ecx, 1
-
 
1127
 
-
 
1128
        mov [eax], dword 4
1148
	push  0x4d
1129
 
1149
        pop   dword [RESERVED_PORTS+32+8]	;,dword 0x4d
1130
        mov [eax+16], ecx
1150
 
1131
        mov [eax+16+4], dword 0
1151
	push  1
1132
        mov [eax+16+4], dword 0x2D
1152
        pop   dword [RESERVED_PORTS+48+0]	;,dword 1
1133
 
-
 
1134
        mov [eax+32], ecx
1153
	push  0x50
1135
        mov [eax+32+4], dword 0x30
1154
        pop   dword [RESERVED_PORTS+48+4]	;,dword 0x50
1136
        mov [eax+32+8], dword 0x4D
-
 
1137
 
1155
        mov   dword [RESERVED_PORTS+48+8],0xdf	;,dword 0xdf
1138
        mov [eax+48], ecx
1156
 
1139
        mov [eax+48+4], dword 0x50
Line 1157... Line 1140...
1157
	push  1
1140
        mov [eax+28+8], dword 0xDF
Line 1158... Line -...
1158
        pop   dword [RESERVED_PORTS+64+0]	;,dword 1
-
 
1159
 
-
 
1160
        mov   dword [RESERVED_PORTS+64+4],0xe5	;,dword 0xe5
-
 
1161
        mov   dword [RESERVED_PORTS+64+8],0xff	;,dword 0xff
-
 
1162
 
-
 
1163
        ret
-
 
1164
 
-
 
1165
setirqreadports:
-
 
1166
 
-
 
1167
        mov   [irq12read+0],dword 0x60 + 0x01000000  ; read port 0x60 , byte
-
 
1168
	    and   dword [irq12read+4],0                   ; end of port list
-
 
Line 1169... Line 1141...
1169
;        mov   [irq12read+4],dword 0                  ; end of port list
1141
 
1170
        ;mov   [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte
1142
        mov [eax+64], ecx
1171
        ;mov   [irq04read+4],dword 0                  ; end of port list
1143
        mov [eax+64+4], dword 0xE5
Line 1252... Line 1224...
1252
    jnz   .sopl1
1224
    jnz   .sopl1
1253
	inc	  eax
1225
	inc	  eax
1254
    mov   [esp+32],eax
1226
    mov   [esp+32],eax
1255
    ret
1227
    ret
Line 1256... Line 1228...
1256
 
1228
 
1257
  
1229
 
Line 1258... Line 1230...
1258
  .sopl4:
1230
  .sopl4:
1259
 
1231
 
1260
    mov   dx,cx          ; read
1232
    mov   dx,cx          ; read
Line 1561... Line 1533...
1561
iglobal
1533
iglobal
1562
cd_base db 0
1534
cd_base db 0
Line 1563... Line 1535...
1563
 
1535
 
1564
endg
1536
endg
1565
   nsyse4:
1537
   nsyse4:
1566
                 
1538
 
1567
     	sub  ebx,2		 ; SYSTEM LANGUAGE
1539
     	sub  ebx,2		 ; SYSTEM LANGUAGE
1568
     	jnz  nsyse5
1540
     	jnz  nsyse5
1569
     	mov  [syslang],ecx
1541
     	mov  [syslang],ecx
1570
     	ret
1542
     	ret
1571
   nsyse5:
1543
   nsyse5:
1572
         
1544
 
1573
     	sub  ebx,2		; HD BASE
1545
     	sub  ebx,2		; HD BASE
Line 1574... Line 1546...
1574
     	jnz  nsyse7
1546
     	jnz  nsyse7
1575
 
1547
 
Line 1774... Line 1746...
1774
     	ret
1746
     	ret
1775
ngsyse12:
1747
ngsyse12:
1776
     	mov  [esp+32],dword 1
1748
     	mov  [esp+32],dword 1
1777
     	ret
1749
     	ret
Line 1778... Line 1750...
1778
 
1750
 
1779
	
1751
 
1780
get_timer_ticks:
1752
get_timer_ticks:
1781
    	mov eax,[timer_ticks]
1753
    	mov eax,[timer_ticks]
Line 1782... Line 1754...
1782
    	ret
1754
    	ret
Line 2948... Line 2920...
2948
	dd	change_task
2920
	dd	change_task
2949
	dd	sys_sheduler.02
2921
	dd	sys_sheduler.02
2950
	dd	sys_sheduler.03
2922
	dd	sys_sheduler.03
2951
	dd	sys_sheduler.04
2923
	dd	sys_sheduler.04
2952
endg
2924
endg
2953
sys_sheduler:   
2925
sys_sheduler:
2954
;rewritten by   29.12.2009
2926
;rewritten by   29.12.2009
2955
	jmp	dword [sheduler+ebx*4]
2927
	jmp	dword [sheduler+ebx*4]
2956
;.shed_counter:
2928
;.shed_counter:
2957
.00:
2929
.00:
2958
	mov eax,[context_counter]
2930
	mov eax,[context_counter]
Line 2961... Line 2933...
2961
 
2933
 
2962
.02:
2934
.02:
2963
;.perf_control:
2935
;.perf_control:
2964
	inc	ebx			;before ebx=2, ebx=3
2936
	inc	ebx			;before ebx=2, ebx=3
2965
        cmp	ebx,ecx			;if ecx=3, ebx=3
2937
        cmp	ebx,ecx			;if ecx=3, ebx=3
Line 2966... Line 2938...
2966
        jz 	cache_disable		
2938
        jz 	cache_disable
2967
 
2939
 
2968
	dec	ebx                     ;ebx=2
2940
	dec	ebx                     ;ebx=2
Line 2977... Line 2949...
2977
	test	ebx,ecx                 ;ebx=0 and ecx=0
2949
	test	ebx,ecx                 ;ebx=0 and ecx=0
2978
	jz 	modify_pce		;if ecx=0
2950
	jz 	modify_pce		;if ecx=0
Line 2979... Line 2951...
2979
 
2951
 
Line 2980... Line 2952...
2980
	ret
2952
	ret
2981
 
2953
 
2982
.03:	
2954
.03:
2983
;.rdmsr_instr:
2955
;.rdmsr_instr:
2984
;now counter in ecx
2956
;now counter in ecx
2985
;(edx:eax) esi:edi => edx:esi
2957
;(edx:eax) esi:edi => edx:esi
Line 3478... Line 3450...
3478
;     ret
3450
;     ret
Line 3479... Line 3451...
3479
 
3451
 
3480
 
-
 
3481
 
-
 
3482
align 4
-
 
3483
 
-
 
3484
sys_programirq:
-
 
3485
 
-
 
3486
    mov   eax, [TASK_BASE]
-
 
3487
    add   ebx, [eax + TASKDATA.mem_start]
-
 
3488
 
-
 
3489
    cmp   ecx, 16
-
 
3490
    jae   .not_owner
-
 
3491
    mov   edi, [eax + TASKDATA.pid]
-
 
3492
    cmp   edi, [irq_owner + 4 * ecx]
-
 
3493
    je    .spril1
-
 
3494
.not_owner:
-
 
3495
    xor   ecx, ecx
-
 
3496
    inc   ecx
-
 
3497
    jmp   .end
-
 
3498
  .spril1:
-
 
3499
 
-
 
3500
    shl   ecx, 6
-
 
3501
    mov   esi, ebx
-
 
3502
    lea   edi, [irq00read + ecx]
-
 
3503
    push  16
-
 
3504
    pop   ecx
-
 
3505
 
-
 
3506
    cld
-
 
3507
    rep   movsd
-
 
3508
  .end:
-
 
3509
    mov   [esp+32], ecx
-
 
3510
    ret
-
 
3511
 
-
 
3512
 
-
 
3513
align 4
-
 
3514
 
-
 
3515
get_irq_data:
-
 
3516
     movzx esi, bh                       ; save number of subfunction, if bh = 1, return data size, otherwise, read data
-
 
3517
     xor   bh, bh
-
 
3518
     cmp   ebx, 16
-
 
3519
     jae   .not_owner
-
 
3520
     mov   edx, [4 * ebx + irq_owner]    ; check for irq owner
-
 
3521
 
-
 
3522
     mov   eax,[TASK_BASE]
-
 
3523
 
-
 
3524
     cmp   edx,[eax+TASKDATA.pid]
-
 
3525
     je    gidril1
-
 
3526
.not_owner:
-
 
3527
     xor   edx, edx
-
 
3528
     dec   edx
-
 
3529
     jmp   gid1
-
 
3530
 
-
 
3531
  gidril1:
-
 
3532
 
-
 
3533
     shl   ebx, 12
-
 
3534
     lea   eax, [ebx + IRQ_SAVE]         ; calculate address of the beginning of buffer + 0x0 - data size
-
 
3535
     mov   edx, [eax]                    ;                                              + 0x4 - data offset
-
 
3536
     dec   esi
-
 
3537
     jz    gid1
-
 
3538
     test  edx, edx                      ; check if buffer is empty
-
 
3539
     jz    gid1
-
 
3540
 
-
 
3541
     mov   ebx, [eax + 0x4]
-
 
3542
     mov   edi, ecx
-
 
3543
 
-
 
3544
     mov   ecx, 4000                     ; buffer size, used frequently
-
 
3545
 
-
 
3546
     cmp   ebx, ecx                      ; check for the end of buffer, if end of buffer, begin cycle again
-
 
3547
     jb    @f
-
 
3548
 
-
 
3549
     xor   ebx, ebx
-
 
3550
 
-
 
3551
   @@:
-
 
3552
 
-
 
3553
     lea   esi, [ebx + edx]              ; calculate data size and offset
-
 
3554
     cld
-
 
3555
     cmp   esi, ecx                      ; if greater than the buffer size, begin cycle again
-
 
3556
     jbe   @f
-
 
3557
 
-
 
3558
     sub   ecx, ebx
-
 
3559
     sub   edx, ecx
-
 
3560
 
-
 
3561
     lea   esi, [eax + ebx + 0x10]
-
 
3562
     rep   movsb
-
 
3563
 
-
 
3564
     xor   ebx, ebx
-
 
3565
   @@:
-
 
3566
     lea   esi, [eax + ebx + 0x10]
-
 
3567
     mov   ecx, edx
-
 
3568
     add   ebx, edx
-
 
3569
 
-
 
3570
     rep   movsb
-
 
3571
     mov   edx, [eax]
-
 
3572
     mov   [eax], ecx                    ; set data size to zero
-
 
3573
     mov   [eax + 0x4], ebx              ; set data offset
-
 
3574
 
-
 
3575
   gid1:
-
 
3576
     mov   [esp+32], edx                 ; eax
-
 
3577
     ret
3452
 
3578
 
3453
 
3579
 
3454
align 4
3580
set_io_access_rights:
3455
set_io_access_rights:
3581
      push edi eax
3456
      push edi eax
Line 3586... Line 3461...
3586
;     add   edi,eax
3461
;     add   edi,eax
3587
;     mov   ebx,1
3462
;     mov   ebx,1
3588
;     shl   ebx,cl
3463
;     shl   ebx,cl
3589
     test  ebp,ebp
3464
     test  ebp,ebp
3590
;     cmp   ebp,0                ; enable access - ebp = 0
3465
;     cmp   ebp,0                ; enable access - ebp = 0
3591
     jnz   siar1
3466
     jnz   .siar1
3592
;     not   ebx
3467
;     not   ebx
3593
;     and   [edi],byte bl
3468
;     and   [edi],byte bl
3594
     btr [edi], eax
3469
     btr [edi], eax
3595
     pop eax edi
3470
     pop eax edi
3596
     ret
3471
     ret
3597
siar1:
3472
.siar1:
3598
     bts [edi], eax
3473
     bts [edi], eax
3599
  ;  or    [edi],byte bl        ; disable access - ebp = 1
3474
  ;  or    [edi],byte bl        ; disable access - ebp = 1
3600
     pop eax edi
3475
     pop eax edi
3601
     ret
3476
     ret
3602
;reserve/free group of ports
3477
;reserve/free group of ports
3603
;  * eax = 46 - number function
3478
;  * eax = 46 - number function
3604
;  * ebx = 0 - reserve, 1 - free
3479
;  * ebx = 0 - reserve, 1 - free
3605
;  * ecx = number start arrea of ports
3480
;  * ecx = number start arrea of ports
3606
;  * edx = number end arrea of ports (include last number of port)
3481
;  * edx = number end arrea of ports (include last number of port)
3607
;Return value:
3482
;Return value:
3608
;  * eax = 0 - succesful 
3483
;  * eax = 0 - succesful
3609
;  * eax = 1 - error
3484
;  * eax = 1 - error
3610
;  * The system has reserve this ports:
3485
;  * The system has reserve this ports:
3611
;    0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port).
3486
;    0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port).
3612
;destroys eax,ebx, ebp
3487
;destroys eax,ebx, ebp
3613
r_f_port_area:
3488
r_f_port_area:
Line 3747... Line 3622...
3747
;     popad                         ; end disable io map
3622
;     popad                         ; end disable io map
3748
     xor   eax, eax
3623
     xor   eax, eax
3749
     ret
3624
     ret
Line 3750... Line -...
3750
 
-
 
3751
 
-
 
3752
reserve_free_irq:
-
 
3753
 
-
 
3754
     xor   esi, esi
-
 
3755
     inc   esi
-
 
3756
     cmp   ecx, 16
-
 
3757
     jae   ril1
-
 
3758
 
-
 
3759
     push  ecx
-
 
3760
     lea   ecx, [irq_owner + 4 * ecx]
-
 
3761
     mov   edx, [ecx]
-
 
3762
     mov   eax, [TASK_BASE]
-
 
3763
     mov   edi, [eax + TASKDATA.pid]
-
 
3764
     pop   eax
-
 
3765
     dec   ebx
-
 
3766
     jnz   reserve_irq
-
 
3767
 
-
 
3768
     cmp   edx, edi
-
 
3769
     jne   ril1
-
 
3770
     dec   esi
-
 
3771
     mov   [ecx], esi
-
 
3772
 
-
 
3773
     jmp   ril1
-
 
3774
 
-
 
3775
  reserve_irq:
-
 
3776
 
-
 
3777
     cmp   dword [ecx], 0
-
 
3778
     jne   ril1
-
 
3779
 
-
 
3780
     mov   ebx, [f_irqs + 4 * eax]
-
 
3781
 
-
 
3782
     stdcall attach_int_handler, eax, ebx, dword 0
-
 
3783
 
-
 
3784
     mov   [ecx], edi
-
 
3785
 
-
 
3786
     dec   esi
-
 
3787
   ril1:
-
 
3788
     mov   [esp+32], esi ; return in eax
-
 
3789
     ret
-
 
3790
 
3625
 
3791
iglobal
-
 
3792
f_irqs:
-
 
3793
     dd 0x0
-
 
3794
     dd 0x0
-
 
3795
     dd p_irq2
-
 
3796
     dd p_irq3
-
 
3797
     dd p_irq4
-
 
3798
     dd p_irq5
-
 
3799
     dd p_irq6
-
 
3800
     dd p_irq7
-
 
3801
     dd p_irq8
-
 
3802
     dd p_irq9
-
 
3803
     dd p_irq10
-
 
3804
     dd p_irq11
-
 
3805
     dd 0x0
-
 
3806
     dd 0x0
-
 
3807
     dd 0x0
-
 
3808
     dd 0x0
-
 
3809
 
-
 
3810
endg
3626
 
3811
 
3627
align 4
3812
drawbackground:
3628
drawbackground:
3813
       inc   [mouse_pause]
3629
       inc   [mouse_pause]
3814
       cmp   [SCR_MODE],word 0x12
3630
       cmp   [SCR_MODE],word 0x12
Line 4818... Line 4634...
4818
     and   ebx,0xffff
4634
     and   ebx,0xffff
4819
     dec   eax
4635
     dec   eax
4820
           dec   ebx
4636
           dec   ebx
4821
     ; eax - x, ebx - y
4637
     ; eax - x, ebx - y
4822
     mov   edx,ecx
4638
     mov   edx,ecx
4823
     
4639
 
4824
     shr   ecx,16
4640
     shr   ecx,16
4825
     and   edx,0xffff
4641
     and   edx,0xffff
4826
     mov   esi,ecx
4642
     mov   esi,ecx
4827
     ; ecx - size x, edx - size y
4643
     ; ecx - size x, edx - size y
4828
         
4644
 
4829
         mov   ebp,edx
4645
         mov   ebp,edx
4830
         dec   ebp
4646
         dec   ebp
4831
     lea   ebp,[ebp*3]
4647
     lea   ebp,[ebp*3]
4832
         
4648
 
4833
         imul  ebp,esi
4649
         imul  ebp,esi
4834
         
4650
 
4835
         mov   esi,ecx
4651
         mov   esi,ecx
4836
         dec   esi
4652
         dec   esi
4837
         lea   esi,[esi*3]
4653
         lea   esi,[esi*3]
4838
         
4654
 
4839
     add   ebp,esi
4655
     add   ebp,esi
4840
     add   ebp,edi
4656
     add   ebp,edi
Line 4841... Line 4657...
4841
 
4657
 
4842
     add   ebx,edx
4658
     add   ebx,edx
4843
         
4659
 
4844
.start_y:
4660
.start_y:
4845
     push  ecx edx
4661
     push  ecx edx
4846
.start_x:
4662
.start_x:
4847
     push  eax ebx ecx
4663
     push  eax ebx ecx
Line 4848... Line 4664...
4848
     add   eax,ecx
4664
     add   eax,ecx
4849
 
4665
 
4850
     call  dword [GETPIXEL] ; eax - x, ebx - y
4666
     call  dword [GETPIXEL] ; eax - x, ebx - y
4851
     
4667
 
4852
     mov   [ebp],cx
4668
     mov   [ebp],cx
Line 4853... Line 4669...
4853
     shr   ecx,16
4669
     shr   ecx,16
Line 4892... Line 4708...
4892
        xor     edi, edi
4708
        xor     edi, edi
4893
        add     ebx, ebp
4709
        add     ebx, ebp
4894
        mov     ecx, edx
4710
        mov     ecx, edx
4895
        jmp     [draw_line]
4711
        jmp     [draw_line]
Line 4896... Line -...
4896
 
-
 
4897
align 4
-
 
4898
 
-
 
4899
syscall_getirqowner:                    ; GetIrqOwner
-
 
4900
 
-
 
4901
     cmp   ebx,16
-
 
4902
     jae   .err
-
 
4903
 
-
 
4904
     cmp   [irq_rights + 4 * ebx], dword 2
-
 
4905
     je    .err
-
 
4906
 
-
 
4907
     mov   eax,[4 * ebx + irq_owner]
-
 
Line 4908... Line -...
4908
     mov   [esp+32],eax
-
 
4909
 
-
 
4910
     ret
-
 
4911
.err:
-
 
Line 4912... Line 4712...
4912
     or    dword [esp+32], -1
4712
 
4913
     ret
-
 
4914
 
4713
 
Line 4915... Line 4714...
4915
align 4
4714
 
4916
 
4715
align 4
4917
syscall_reserveportarea:                ; ReservePortArea and FreePortArea
4716
syscall_reserveportarea:                ; ReservePortArea and FreePortArea
Line 4918... Line 4717...
4918
 
4717
 
4919
     call  r_f_port_area
-
 
4920
     mov   [esp+32],eax
4718
     call  r_f_port_area
4921
     ret
4719
     mov   [esp+32],eax
4922
 
4720
     ret
4923
align 4
4721
 
4924
 
4722
align 4