Subversion Repositories Kolibri OS

Rev

Rev 3870 | Rev 4273 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3870 Rev 3881
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 3870 $
8
$Revision: 3881 $
9
 
9
 
10
 
10
 
Line 534... Line 534...
534
        add     al, 128+64+32
534
        add     al, 128+64+32
535
        out     dx, al ; номер головки/номер диска
535
        out     dx, al ; номер головки/номер диска
536
        inc     edx
536
        inc     edx
537
        mov     al, 30h ; WRITE SECTOR(S)
537
        mov     al, 30h ; WRITE SECTOR(S)
538
        out     dx, al ; ATACommand регистр команд
538
        out     dx, al ; ATACommand регистр команд
539
        popfd
-
 
540
        jmp     .continue
539
        jmp     .continue
541
;--------------------------------------
540
;--------------------------------------
542
.lba48:
541
.lba48:
543
        pushfd
542
        pushfd
544
        cli
543
        cli
Line 574... Line 573...
574
        add     al, 128+64+32
573
        add     al, 128+64+32
575
        out     dx, al ; номер головки/номер диска
574
        out     dx, al ; номер головки/номер диска
576
        inc     edx
575
        inc     edx
577
        mov     al, 34h ; WRITE SECTOR(S) EXT
576
        mov     al, 34h ; WRITE SECTOR(S) EXT
578
        out     dx, al ; ATACommand регистр команд
577
        out     dx, al ; ATACommand регистр команд
579
        popfd
-
 
580
;--------------------------------------
578
;--------------------------------------
581
.continue:
579
.continue:
-
 
580
        popfd
582
        call    wait_for_sector_buffer
581
        call    wait_for_sector_buffer
Line 583... Line 582...
583
 
582
 
584
        cmp     [hd_error], 0
583
        cmp     [hd_error], 0
Line 726... Line 725...
726
        jz      .done
725
        jz      .done
Line 727... Line 726...
727
 
726
 
728
        call    check_hd_wait_timeout
727
        call    check_hd_wait_timeout
729
        cmp     [hd_error], 0
728
        cmp     [hd_error], 0
730
        jz      .wait
-
 
-
 
729
        jz      .wait
731
 
730
; clear Bus Master IDE Command register
732
        pushfd
731
        pushfd
733
        cli
732
        cli
734
        mov     [IDE_common_irq_param], 0
733
        mov     [IDE_common_irq_param], 0
735
        mov     dx, [IDEContrRegsBaseAddr]
734
        mov     dx, [IDEContrRegsBaseAddr]
736
        mov     al, 0
735
        mov     al, 0
737
        out     dx, al
736
        out     dx, al
-
 
737
        popfd
-
 
738
;--------------------------------------
738
        popfd
739
align 4
739
.done:
740
.done:
740
        pop     edx
741
        pop     edx
741
        pop     eax
742
        pop     eax
742
        ret
743
        ret
Line 754... Line 755...
754
        jz      .done
755
        jz      .done
Line 755... Line 756...
755
 
756
 
756
        call    check_hd_wait_timeout
757
        call    check_hd_wait_timeout
757
        cmp     [hd_error], 0
758
        cmp     [hd_error], 0
758
        jz      .wait
-
 
-
 
759
        jz      .wait
759
 
760
; clear Bus Master IDE Command register
760
        pushfd
761
        pushfd
761
        cli
762
        cli
762
        mov     [IDE_common_irq_param], 0
763
        mov     [IDE_common_irq_param], 0
763
        mov     dx, [IDEContrRegsBaseAddr]
764
        mov     dx, [IDEContrRegsBaseAddr]
764
        add     dx, 8
765
        add     dx, 8
765
        mov     al, 0
766
        mov     al, 0
766
        out     dx, al
767
        out     dx, al
-
 
768
        popfd
-
 
769
;--------------------------------------
767
        popfd
770
align 4
768
.done:
771
.done:
769
        pop     edx
772
        pop     edx
770
        pop     eax
773
        pop     eax
771
        ret
774
        ret
Line 802... Line 805...
802
        jne     .exit
805
        jne     .exit
Line 803... Line 806...
803
 
806
 
804
        pushfd
807
        pushfd
805
        cli
808
        cli
806
        pushad
-
 
-
 
809
        pushad
807
 
810
; clear Bus Master IDE Command register
808
        mov     [IDE_common_irq_param], 0
811
        mov     [IDE_common_irq_param], 0
809
        mov     dx, [IDEContrRegsBaseAddr]
812
        mov     dx, [IDEContrRegsBaseAddr]
810
        mov     al, 0
813
        mov     al, 0
-
 
814
        out     dx, al
-
 
815
; clear Bus Master IDE Status register
-
 
816
; clear Interrupt bit
-
 
817
        add     edx, 2
-
 
818
        mov     al, 4 ; 100b
Line 811... Line 819...
811
        out     dx, al
819
        out     dx, al
812
 
820
 
-
 
821
        popad
-
 
822
        popfd
813
        popad
823
;--------------------------------------
814
        popfd
824
align 4
815
.exit:
825
.exit:
816
        mov     al, 1
826
        mov     al, 1
817
        ret
827
        ret
Line 822... Line 832...
822
        jne     .exit
832
        jne     .exit
Line 823... Line 833...
823
 
833
 
824
        pushfd
834
        pushfd
825
        cli
835
        cli
826
        pushad
-
 
-
 
836
        pushad
827
 
837
; clear Bus Master IDE Command register
828
        mov     [IDE_common_irq_param], 0
838
        mov     [IDE_common_irq_param], 0
829
        mov     dx, [IDEContrRegsBaseAddr]
839
        mov     dx, [IDEContrRegsBaseAddr]
830
        add     dx, 8
840
        add     dx, 8
831
        mov     al, 0
841
        mov     al, 0
-
 
842
        out     dx, al
-
 
843
; clear Bus Master IDE Status register
-
 
844
; clear Interrupt bit
-
 
845
        add     edx, 2
-
 
846
        mov     al, 4 ; 100b
Line 832... Line 847...
832
        out     dx, al
847
        out     dx, al
833
 
848
 
-
 
849
        popad
-
 
850
        popfd
834
        popad
851
;--------------------------------------
835
        popfd
852
align 4
836
.exit:
853
.exit:
837
        mov     al, 1
854
        mov     al, 1
838
        ret
855
        ret
Line 843... Line 860...
843
        je      .exit
860
        je      .exit
Line 844... Line 861...
844
 
861
 
845
        pushfd
862
        pushfd
846
        cli
863
        cli
847
        pushad
-
 
-
 
864
        pushad
848
 
865
; clear Bus Master IDE Command register
849
        xor     ebx, ebx
866
        xor     ebx, ebx
850
        mov     dx, [IDEContrRegsBaseAddr]
867
        mov     dx, [IDEContrRegsBaseAddr]
851
        mov     eax, IDE_common_irq_param
868
        mov     eax, IDE_common_irq_param
852
        cmp     [eax], irq14_num
869
        cmp     [eax], irq14_num
Line 857... Line 874...
857
        add     dx, 8
874
        add     dx, 8
858
;--------------------------------------
875
;--------------------------------------
859
align 4
876
align 4
860
@@:
877
@@:
861
        out     dx, al
878
        out     dx, al
-
 
879
; clear Bus Master IDE Status register
-
 
880
; clear Interrupt bit
-
 
881
        add     edx, 2
-
 
882
        mov     al, 4 ; 100b
-
 
883
        out     dx, al
Line 862... Line 884...
862
 
884
 
863
        popad
885
        popad
-
 
886
        popfd
-
 
887
;--------------------------------------
864
        popfd
888
align 4
865
.exit:
889
.exit:
866
        mov     al, 1
890
        mov     al, 1
867
        ret
891
        ret
868
;-----------------------------------------------------------------------------
892
;-----------------------------------------------------------------------------
Line 915... Line 939...
915
        out     dx, eax
939
        out     dx, eax
916
        pop     edx
940
        pop     edx
917
; clear Bus Master IDE Command register
941
; clear Bus Master IDE Command register
918
        mov     al, 0
942
        mov     al, 0
919
        out     dx, al
943
        out     dx, al
920
; set write to memory
-
 
921
;        mov     al, 8 ; 1000b
-
 
922
;        out     dx, al
-
 
923
; clear Bus Master IDE Status register
944
; clear Bus Master IDE Status register
924
; clear Error bit and Interrupt bit
945
; clear Error bit and Interrupt bit
925
        add     edx, 2
946
        add     edx, 2
926
        mov     al, 6 ; 110b
947
        mov     al, 6 ; 110b
927
        out     dx, al
948
        out     dx, al
928
 
-
 
929
; Select the desired drive
949
; Select the desired drive
930
        mov     edx, [hdbase]
950
        mov     edx, [hdbase]
931
        add     edx, 6   ; адрес регистра головок
951
        add     edx, 6   ; адрес регистра головок
932
        mov     al, byte [hdid]
952
        mov     al, byte [hdid]
933
        add     al, 128+64+32
953
        add     al, 128+64+32
Line 1057... Line 1077...
1057
        pop     eax
1077
        pop     eax
1058
        mov     [dma_cur_sector], eax
1078
        mov     [dma_cur_sector], eax
1059
        jmp     hd_read_dma
1079
        jmp     hd_read_dma
1060
;-----------------------------------------------------------------------------
1080
;-----------------------------------------------------------------------------
1061
cache_write_dma:
1081
cache_write_dma:
1062
        mov     eax, [cache_chain_ptr]
1082
        mov     eax, [cache_chain_ptr] ; for what?
1063
        push    esi
1083
        push    esi
-
 
1084
; set data for PRD Table
1064
        mov     eax, IDE_descriptor_table
1085
        mov     eax, IDE_descriptor_table
1065
        mov     edx, eax
1086
        mov     edx, eax
1066
        pusha
1087
        pusha
1067
        mov     edi, (OS_BASE+IDE_DMA)
1088
        mov     edi, (OS_BASE+IDE_DMA)
1068
        mov     dword [edx], IDE_DMA
1089
        mov     dword [edx], IDE_DMA
Line 1072... Line 1093...
1072
        shr     ecx, 2
1093
        shr     ecx, 2
1073
        cld
1094
        cld
1074
        rep movsd
1095
        rep movsd
1075
        popa
1096
        popa
1076
        sub     eax, OS_BASE
1097
        sub     eax, OS_BASE
-
 
1098
; select controller Primary or Secondary
1077
        mov     dx, [IDEContrRegsBaseAddr]
1099
        mov     dx, [IDEContrRegsBaseAddr]
1078
        push    eax
1100
        push    eax
1079
        mov     eax, [hd_address_table]
1101
        mov     eax, [hd_address_table]
1080
        cmp     [hdbase], eax ; 0x1F0
1102
        cmp     [hdbase], eax ; 0x1F0
1081
        pop     eax
1103
        pop     eax
1082
        jz      @f
1104
        jz      @f
1083
        add     edx, 8
1105
        add     edx, 8
1084
@@:
1106
@@:
1085
        push    edx
1107
        push    edx
-
 
1108
; Bus Master IDE PRD Table Address
1086
        add     edx, 4
1109
        add     edx, 4
-
 
1110
; save IDE_descriptor_table
1087
        out     dx, eax
1111
        out     dx, eax
1088
        pop     edx
1112
        pop     edx
-
 
1113
; clear Bus Master IDE Command register
1089
        mov     al, 0
1114
        mov     al, 0
1090
        out     dx, al
1115
        out     dx, al
-
 
1116
; clear Bus Master IDE Status register
-
 
1117
; clear Error bit and Interrupt bit
1091
        add     edx, 2
1118
        add     edx, 2
1092
        mov     al, 6
1119
        mov     al, 6
1093
        out     dx, al
1120
        out     dx, al
1094
 
-
 
1095
; Select the desired drive
1121
; Select the desired drive
1096
        mov     edx, [hdbase]
1122
        mov     edx, [hdbase]
1097
        add     edx, 6   ; адрес регистра головок
1123
        add     edx, 6   ; адрес регистра головок
1098
        mov     al, byte [hdid]
1124
        mov     al, byte [hdid]
1099
        add     al, 128+64+32
1125
        add     al, 128+64+32
Line 1178... Line 1204...
1178
        inc     edx
1204
        inc     edx
1179
        mov     al, 35h ; WRITE DMA EXT
1205
        mov     al, 35h ; WRITE DMA EXT
1180
        out     dx, al ; ATACommand регистр команд
1206
        out     dx, al ; ATACommand регистр команд
1181
;--------------------------------------
1207
;--------------------------------------
1182
.continue:
1208
.continue:
-
 
1209
; select controller Primary or Secondary
1183
        mov     dx, [IDEContrRegsBaseAddr]
1210
        mov     dx, [IDEContrRegsBaseAddr]
1184
        mov     eax, [hd_address_table]
1211
        mov     eax, [hd_address_table]
1185
        cmp     [hdbase], eax ; 0x1F0
1212
        cmp     [hdbase], eax ; 0x1F0
1186
        jz      @f
1213
        jz      @f
1187
        add     dx, 8
1214
        add     dx, 8
1188
@@:
1215
@@:
-
 
1216
; set write to device and Start Bus Master
1189
        mov     al, 1
1217
        mov     al, 1
1190
        out     dx, al
1218
        out     dx, al
1191
        mov     eax, [CURRENT_TASK]
1219
        mov     eax, [CURRENT_TASK]
1192
        mov     [dma_process], eax
1220
        mov     [dma_process], eax
1193
        mov     eax, [TASK_BASE]
1221
        mov     eax, [TASK_BASE]
Line 1200... Line 1228...
1200
        jmp     @f
1228
        jmp     @f
1201
.ide1:
1229
.ide1:
1202
        mov     [IDE_common_irq_param], irq15_num
1230
        mov     [IDE_common_irq_param], irq15_num
1203
@@:
1231
@@:
1204
        popfd
1232
        popfd
-
 
1233
; wait for interrupt
1205
        mov     [dma_cur_sector], not 0x40
1234
        mov     [dma_cur_sector], not 0x40
1206
        mov     eax, [hd_address_table]
1235
        mov     eax, [hd_address_table]
1207
        cmp     [hdbase], eax ; 0x1F0
1236
        cmp     [hdbase], eax ; 0x1F0
1208
        jnz     .wait_ide1
1237
        jnz     .wait_ide1
1209
        call    wait_for_sector_dma_ide0
1238
        call    wait_for_sector_dma_ide0
Line 1215... Line 1244...
1215
        jnz     hd_write_error_dma
1244
        jnz     hd_write_error_dma
1216
        pop     esi
1245
        pop     esi
1217
        ret
1246
        ret
1218
;-----------------------------------------------------------------------------
1247
;-----------------------------------------------------------------------------
1219
uglobal
1248
uglobal
-
 
1249
align 4
1220
IDE_Interrupt   dw ?
1250
IDE_Interrupt   dw ?
1221
IDEContrRegsBaseAddr         dw ?
1251
IDEContrRegsBaseAddr         dw ?
1222
IDEContrProgrammingInterface dw ?
1252
IDEContrProgrammingInterface dw ?
1223
IDE_BAR0_val    dw ?
1253
IDE_BAR0_val    dw ?
1224
IDE_BAR1_val    dw ?
1254
IDE_BAR1_val    dw ?