Subversion Repositories Kolibri OS

Rev

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

Rev 3774 Rev 3870
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: 3774 $
8
$Revision: 3870 $
9
 
9
 
10
 
10
 
Line 720... Line 720...
720
        call    save_hd_wait_timeout
720
        call    save_hd_wait_timeout
721
;--------------------------------------
721
;--------------------------------------
722
align 4
722
align 4
723
.wait:
723
.wait:
724
        call    change_task
724
        call    change_task
725
        cmp     [IDE_common_irq_param], irq14_num
725
        cmp     [IDE_common_irq_param], 0
726
        jnz     .done
726
        jz      .done
Line 727... Line 727...
727
 
727
 
728
        call    check_hd_wait_timeout
728
        call    check_hd_wait_timeout
729
        cmp     [hd_error], 0
729
        cmp     [hd_error], 0
Line -... Line 730...
-
 
730
        jz      .wait
-
 
731
 
730
        jz      .wait
732
        pushfd
731
 
733
        cli
732
        mov     [IDE_common_irq_param], 0
734
        mov     [IDE_common_irq_param], 0
733
        mov     dx, [IDEContrRegsBaseAddr]
735
        mov     dx, [IDEContrRegsBaseAddr]
-
 
736
        mov     al, 0
734
        mov     al, 0
737
        out     dx, al
735
        out     dx, al
738
        popfd
736
.done:
739
.done:
737
        pop     edx
740
        pop     edx
738
        pop     eax
741
        pop     eax
Line 745... Line 748...
745
        call    save_hd_wait_timeout
748
        call    save_hd_wait_timeout
746
;--------------------------------------
749
;--------------------------------------
747
align 4
750
align 4
748
.wait:
751
.wait:
749
        call    change_task
752
        call    change_task
750
        cmp     [IDE_common_irq_param], irq15_num
753
        cmp     [IDE_common_irq_param], 0
751
        jnz     .done
754
        jz      .done
Line 752... Line 755...
752
 
755
 
753
        call    check_hd_wait_timeout
756
        call    check_hd_wait_timeout
754
        cmp     [hd_error], 0
757
        cmp     [hd_error], 0
Line -... Line 758...
-
 
758
        jz      .wait
-
 
759
 
755
        jz      .wait
760
        pushfd
756
 
761
        cli
757
        mov     [IDE_common_irq_param], 0
762
        mov     [IDE_common_irq_param], 0
758
        mov     dx, [IDEContrRegsBaseAddr]
763
        mov     dx, [IDEContrRegsBaseAddr]
759
        add     dx, 8
764
        add     dx, 8
-
 
765
        mov     al, 0
760
        mov     al, 0
766
        out     dx, al
761
        out     dx, al
767
        popfd
762
.done:
768
.done:
763
        pop     edx
769
        pop     edx
764
        pop     eax
770
        pop     eax
Line 789... Line 795...
789
dma_hdd             db 0
795
dma_hdd             db 0
790
allow_dma_access    db 0
796
allow_dma_access    db 0
791
endg
797
endg
792
;-----------------------------------------------------------------------------
798
;-----------------------------------------------------------------------------
793
align 4
799
align 4
794
IDE_common_irq_handler:
800
IDE_irq_14_handler:
-
 
801
        cmp     [IDE_common_irq_param], irq14_num
-
 
802
        jne     .exit
-
 
803
 
795
        pushfd
804
        pushfd
796
        cli
805
        cli
797
        pushad
806
        pushad
Line 798... Line -...
798
 
-
 
799
        xor     ebx, ebx
807
 
800
        mov     eax, IDE_common_irq_param
-
 
801
        cmp     [eax], irq15_num
-
 
802
        mov     [eax], ebx
-
 
803
        je      @f
-
 
804
;--------------------------------------
808
        mov     [IDE_common_irq_param], 0
805
        mov     dx, [IDEContrRegsBaseAddr]
809
        mov     dx, [IDEContrRegsBaseAddr]
806
        mov     al, 0
810
        mov     al, 0
-
 
811
        out     dx, al
-
 
812
 
-
 
813
        popad
-
 
814
        popfd
807
        out     dx, al
815
.exit:
-
 
816
        mov     al, 1
808
        jmp     .end
817
        ret
809
;--------------------------------------
818
;-----------------------------------------------------------------------------
-
 
819
align 4
-
 
820
IDE_irq_15_handler:
-
 
821
        cmp     [IDE_common_irq_param], irq15_num
810
align 4
822
        jne     .exit
-
 
823
 
-
 
824
        pushfd
-
 
825
        cli
-
 
826
        pushad
-
 
827
 
811
@@:
828
        mov     [IDE_common_irq_param], 0
812
        mov     dx, [IDEContrRegsBaseAddr]
829
        mov     dx, [IDEContrRegsBaseAddr]
813
        add     dx, 8
830
        add     dx, 8
814
        mov     al, 0
831
        mov     al, 0
-
 
832
        out     dx, al
-
 
833
 
-
 
834
        popad
-
 
835
        popfd
-
 
836
.exit:
-
 
837
        mov     al, 1
-
 
838
        ret
-
 
839
;-----------------------------------------------------------------------------
-
 
840
align 4
-
 
841
IDE_common_irq_handler:
-
 
842
        cmp     [IDE_common_irq_param], 0
-
 
843
        je      .exit
-
 
844
 
-
 
845
        pushfd
-
 
846
        cli
-
 
847
        pushad
-
 
848
 
-
 
849
        xor     ebx, ebx
-
 
850
        mov     dx, [IDEContrRegsBaseAddr]
-
 
851
        mov     eax, IDE_common_irq_param
-
 
852
        cmp     [eax], irq14_num
-
 
853
        mov     [eax], bl
-
 
854
        xor     eax, eax
-
 
855
        je      @f
-
 
856
 
815
        out     dx, al
857
        add     dx, 8
816
;--------------------------------------
858
;--------------------------------------
817
align 4
859
align 4
-
 
860
@@:
-
 
861
        out     dx, al
818
.end:
862
 
819
        popad
863
        popad
-
 
864
        popfd
820
        popfd
865
.exit:
821
        mov     al, 1
866
        mov     al, 1
822
        ret
867
        ret
823
;-----------------------------------------------------------------------------
868
;-----------------------------------------------------------------------------
824
align 4
869
align 4
Line 847... Line 892...
847
        pop     esi ecx
892
        pop     esi ecx
848
        pop     edx
893
        pop     edx
849
        pop     eax
894
        pop     eax
850
        ret
895
        ret
851
.notread:
896
.notread:
-
 
897
; set data for PRD Table
852
        mov     eax, IDE_descriptor_table
898
        mov     eax, IDE_descriptor_table
853
        mov     dword [eax], IDE_DMA
899
        mov     dword [eax], IDE_DMA
854
        mov     word [eax+4], 0x2000
900
        mov     word [eax+4], 0x2000
855
        sub     eax, OS_BASE
901
        sub     eax, OS_BASE
-
 
902
; select controller Primary or Secondary
856
        mov     dx, [IDEContrRegsBaseAddr]
903
        mov     dx, [IDEContrRegsBaseAddr]
857
        push    eax
904
        push    eax
858
        mov     eax, [hd_address_table]
905
        mov     eax, [hd_address_table]
859
        cmp     [hdbase], eax ; 0x1F0
906
        cmp     [hdbase], eax ; 0x1F0
860
        pop     eax
907
        pop     eax
861
        jz      @f
908
        jz      @f
862
        add     edx, 8
909
        add     edx, 8
863
@@:
910
@@:
864
        push    edx
911
        push    edx
-
 
912
; Bus Master IDE PRD Table Address
865
        add     edx, 4
913
        add     edx, 4
-
 
914
; save IDE_descriptor_table
866
        out     dx, eax
915
        out     dx, eax
867
        pop     edx
916
        pop     edx
-
 
917
; clear Bus Master IDE Command register
868
        mov     al, 0
918
        mov     al, 0
869
        out     dx, al
919
        out     dx, al
-
 
920
; set write to memory
-
 
921
;        mov     al, 8 ; 1000b
-
 
922
;        out     dx, al
-
 
923
; clear Bus Master IDE Status register
-
 
924
; clear Error bit and Interrupt bit
870
        add     edx, 2
925
        add     edx, 2
871
        mov     al, 6
926
        mov     al, 6 ; 110b
872
        out     dx, al
927
        out     dx, al
Line 873... Line 928...
873
 
928
 
874
; Select the desired drive
929
; Select the desired drive
875
        mov     edx, [hdbase]
930
        mov     edx, [hdbase]
Line 956... Line 1011...
956
        inc     edx
1011
        inc     edx
957
        mov     al, 25h ; READ DMA EXT
1012
        mov     al, 25h ; READ DMA EXT
958
        out     dx, al ; ATACommand регистр команд
1013
        out     dx, al ; ATACommand регистр команд
959
;--------------------------------------
1014
;--------------------------------------
960
.continue:
1015
.continue:
-
 
1016
; select controller Primary or Secondary
961
        mov     dx, [IDEContrRegsBaseAddr]
1017
        mov     dx, [IDEContrRegsBaseAddr]
962
        mov     eax, [hd_address_table]
1018
        mov     eax, [hd_address_table]
963
        cmp     [hdbase], eax ; 0x1F0
1019
        cmp     [hdbase], eax ; 0x1F0
964
        jz      @f
1020
        jz      @f
965
        add     dx, 8
1021
        add     dx, 8
966
@@:
1022
@@:
-
 
1023
; set write to memory and Start Bus Master
967
        mov     al, 9
1024
        mov     al, 9
968
        out     dx, al
1025
        out     dx, al
-
 
1026
 
969
        mov     eax, [CURRENT_TASK]
1027
        mov     eax, [CURRENT_TASK]
970
        mov     [dma_process], eax
1028
        mov     [dma_process], eax
-
 
1029
 
971
        mov     eax, [TASK_BASE]
1030
        mov     eax, [TASK_BASE]
972
        mov     [dma_slot_ptr], eax
1031
        mov     [dma_slot_ptr], eax
-
 
1032
 
973
        mov     eax, [hd_address_table]
1033
        mov     eax, [hd_address_table]
974
        cmp     [hdbase], eax ; 0x1F0
1034
        cmp     [hdbase], eax ; 0x1F0
975
        jnz     .ide1
1035
        jnz     .ide1
Line 976... Line 1036...
976
 
1036
 
977
        mov     [IDE_common_irq_param], irq14_num
1037
        mov     [IDE_common_irq_param], irq14_num
978
        jmp     @f
1038
        jmp     @f
979
.ide1:
1039
.ide1:
980
        mov     [IDE_common_irq_param], irq15_num
1040
        mov     [IDE_common_irq_param], irq15_num
981
@@:
1041
@@:
-
 
1042
        popfd
982
        popfd
1043
; wait for interrupt
983
        mov     eax, [hd_address_table]
1044
        mov     eax, [hd_address_table]
984
        cmp     [hdbase], eax ; 0x1F0
1045
        cmp     [hdbase], eax ; 0x1F0
985
        jnz     .wait_ide1
1046
        jnz     .wait_ide1
986
        call    wait_for_sector_dma_ide0
1047
        call    wait_for_sector_dma_ide0