Subversion Repositories Kolibri OS

Rev

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

Rev 3908 Rev 3910
Line 19... Line 19...
19
;;                                                              ;;
19
;;                                                              ;;
20
;;  See file COPYING for details                                ;;
20
;;  See file COPYING for details                                ;;
21
;;                                                              ;;
21
;;                                                              ;;
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 23... Line 23...
23
 
23
 
Line 24... Line 24...
24
$Revision: 3908 $
24
$Revision: 3910 $
25
 
25
 
26
;***************************************************************************
26
;***************************************************************************
27
;   Function
27
;   Function
Line 855... Line 855...
855
				shl		ecx, 5
855
				shl		ecx, 5
856
				lea   edx, [0xC000+edx+ecx]
856
				lea   edx, [0xC000+edx+ecx]
857
				in		eax, dx
857
				in		eax, dx
858
				ret
858
				ret
Line 859... Line -...
859
 
-
 
860
;proc pci_read8   stdcall, bus:dword, devfn:dword, reg:dword
-
 
861
;proc pci_read16  stdcall, bus:dword, devfn:dword, reg:dword
-
 
862
;proc pci_read32  stdcall, bus:dword, devfn:dword, reg:dword
-
 
863
 
-
 
864
;proc pci_write8  stdcall, bus:dword, devfn:dword, reg:dword, val:dword
-
 
865
;proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
-
 
Line 866... Line 859...
866
;proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
859
 
867
 
860
 
868
PCI_R8	equ 0
861
PCI_R8	equ 0
Line 869... Line 862...
869
PCI_R16	equ 4
862
PCI_R16	equ 4
870
PCI_R32 equ 8
863
PCI_R32 equ 8
871
 
864
 
Line 872... Line -...
872
PCI_W8	equ 12
-
 
873
PCI_W16	equ 16
-
 
874
PCI_W32 equ 20
-
 
875
 
-
 
876
align 8
-
 
877
pci_fn_table:
-
 
878
pci_bus_read8		dd pci_bus.conf1_read8           ;0
-
 
879
pci_bus_read16	dd pci_bus.conf1_read16          ;4
-
 
Line 880... Line 865...
880
pci_bus_read32	dd pci_bus.conf1_read32          ;8
865
PCI_W8	equ 12
881
pci_bus_write8	dd pci_bus.conf1_write8          ;12
866
PCI_W16	equ 16
-
 
867
PCI_W32 equ 20
-
 
868
 
-
 
869
 
-
 
870
align 4
-
 
871
pci_conf1_rw:
-
 
872
;internal function
-
 
873
;eax accessor
-
 
874
;ecx (bus << 8)|devfn
-
 
875
 
-
 
876
.val      equ esp+4
-
 
877
 
-
 
878
; dword CF8 = (0x80000000 | ((reg & 0xF00) << 16) | (bus << 16) | (devfn << 8) | (reg & 0xFC))
-
 
879
 
-
 
880
				pushfd
-
 
881
				cli
-
 
882
 
-
 
883
				push  edx
-
 
884
				push  eax
-
 
885
				mov		eax, edx                	; eax = reg
882
pci_bus_write16	dd pci_bus.conf1_write16         ;16
886
				shl		eax, 16                 	; eax = reg << 16
-
 
887
				shl   ecx, 8                  	; ecx = (bus << 16)|(devfn<<8)
883
pci_bus_write32 dd pci_bus.conf1_write32         ;20
888
				mov		al, dl                  	; eax = (reg << 16)|reg
-
 
889
				and		eax, 0x0F0000FC           ; eax = ((reg & 0xF00) << 16)|(reg & 0xFC)
-
 
890
				lea		eax, [0x80000000+eax+ecx]
-
 
891
				mov 	dx, 0xCF8
-
 
892
				out		dx, eax
-
 
893
				pop		eax
-
 
894
				pop   edx
-
 
895
				jmp   dword [.fntab+eax]
-
 
896
.r32:
-
 
897
				mov  	dx, 0xCFC
-
 
898
				in		eax, dx
-
 
899
.rdone:
-
 
900
				popfd
-
 
901
				ret
-
 
902
.r16:
-
 
903
				and 	dx, 2
-
 
904
				add		dx, 0xCFC
-
 
905
				in		al, dx
-
 
906
				jmp   .rdone
-
 
907
.r8:
-
 
908
				and 	dx, 3
-
 
909
				add		dx, 0xCFC
-
 
910
				in		al, dx
-
 
911
				jmp   .rdone
-
 
912
.w32:
-
 
913
				mov		eax, [esp+8]
-
 
914
				mov		dx, 0xCFC
-
 
915
				out   dx, eax
-
 
916
.wdone:
-
 
917
				popfd
-
 
918
				ret   4
-
 
919
.w16:
-
 
920
				mov		eax, [esp+8]
-
 
921
				and 	dx, 2
-
 
922
				add		dx, 0xCFC
-
 
923
				out		dx, ax
-
 
924
				jmp   .wdone
-
 
925
.w8:
Line 884... Line 926...
884
 
926
				mov		eax, [esp+8]
-
 
927
				and 	dx, 3
-
 
928
				add		dx, 0xCFC
-
 
929
				out		dx, al
-
 
930
				jmp   .wdone
-
 
931
 
-
 
932
align 4
-
 
933
.fntab:
-
 
934
				dd .r8
-
 
935
				dd .r16
-
 
936
				dd .r32
-
 
937
				dd .w8
-
 
938
				dd .w16
-
 
939
				dd .w32
-
 
940
 
-
 
941
align 4
-
 
942
pci_fn_rw	dd pci_conf1_rw
-
 
943
 
-
 
944
;proc pci_bus_read8   fastcall, busaddr:dword, reg:dword
-
 
945
;proc pci_bus_read16  fastcall, busaddr:dword, reg:dword
-
 
946
;proc pci_bus_read32  fastcall, busaddr:dword, reg:dword
-
 
947
 
885
align 4
948
align 4
886
pci_read8:
949
pci_bus_read8:
887
				mov		eax, PCI_R8
950
				xor	eax, eax
Line 888... Line 951...
888
				jmp		@F
951
				jmp	dword [pci_fn_rw]
889
 
952
 
890
align 4
953
align 4
-
 
954
pci_bus_read16:
-
 
955
				mov		eax, PCI_R16
-
 
956
				jmp	dword [pci_fn_rw]
-
 
957
 
-
 
958
align 4
Line 891... Line 959...
891
pci_read16:
959
pci_bus_read32:
-
 
960
				mov		eax, PCI_R32
-
 
961
				jmp	dword [pci_fn_rw]
-
 
962
 
892
				mov		eax, PCI_R16
963
;proc pci_bus_write8  fastcall, busaddr:dword, reg:dword, val: dword
-
 
964
;proc pci_bus_write16 fastcall, busaddr:dword, reg:dword, val: dword
-
 
965
;proc pci_bus_write32 fastcall, busaddr:dword, reg:dword, val: dword
-
 
966
 
-
 
967
align 4
-
 
968
pci_bus_write8:
-
 
969
				mov	  eax, PCI_W8
-
 
970
				jmp	dword [pci_fn_rw]
-
 
971
 
-
 
972
align 4
-
 
973
pci_bus_write16:
-
 
974
				mov		eax, PCI_W16
-
 
975
				jmp	dword [pci_fn_rw]
-
 
976
 
-
 
977
align 4
-
 
978
pci_bus_write32:
-
 
979
				mov		eax, PCI_W32
893
				jmp		@F
980
				jmp	dword [pci_fn_rw]
894
 
981
 
895
align 4
982
;deprecated proc pci_read8   stdcall, bus:dword, devfn:dword, reg:dword
-
 
983
;deprecated proc pci_read16  stdcall, bus:dword, devfn:dword, reg:dword
Line 896... Line 984...
896
pci_read32:
984
;deprecated proc pci_read32  stdcall, bus:dword, devfn:dword, reg:dword
897
				mov		eax, PCI_R32
985
 
898
 
-
 
899
align 4
986
align 4
-
 
987
pci_read8:
-
 
988
.bus			equ esp+4
Line -... Line 989...
-
 
989
.devfn 		equ esp+8
-
 
990
.pci_reg 	equ esp+12
900
@@:
991
.val      equ esp+16
901
.bus			equ esp+4
992
 
-
 
993
				movzx ecx, byte [.devfn]
-
 
994
				mov   ch, [.bus]
Line -... Line 995...
-
 
995
				movzx edx, word [.pci_reg]
-
 
996
				call	pci_bus_read8
-
 
997
				ret 	12
902
.devfn 		equ esp+8
998
 
-
 
999
align 4
Line -... Line 1000...
-
 
1000
pci_read16:
-
 
1001
.bus			equ esp+4
903
.pci_reg 	equ esp+12
1002
.devfn 		equ esp+8
-
 
1003
.pci_reg 	equ esp+12
-
 
1004
.val      equ esp+16
-
 
1005
 
Line -... Line 1006...
-
 
1006
				movzx ecx, byte [.devfn]
-
 
1007
				mov   ch, [.bus]
-
 
1008
				movzx edx, word [.pci_reg]
-
 
1009
				call	pci_bus_read16
904
 
1010
				ret 	12
Line -... Line 1011...
-
 
1011
 
-
 
1012
align 4
-
 
1013
pci_read32:
-
 
1014
.bus			equ esp+4
905
				xor		ecx, ecx
1015
.devfn 		equ esp+8
906
				mov   ch, [.bus]
1016
.pci_reg 	equ esp+12
-
 
1017
.val      equ esp+16
-
 
1018
 
-
 
1019
				movzx ecx, byte [.devfn]
-
 
1020
				mov   ch, [.bus]
-
 
1021
				movzx edx, word [.pci_reg]
-
 
1022
				call	pci_bus_read32
907
				mov   cl, [.devfn]
1023
				ret 	12
-
 
1024
 
-
 
1025
;deprecated proc pci_write8  stdcall, bus:dword, devfn:dword, reg:dword, val:dword
-
 
1026
;deprecated proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
908
				movzx edx, word [.pci_reg]
1027
;deprecated proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
Line 909... Line 1028...
909
 
1028
 
910
				pushfd
1029
align 4
911
				cli
1030
pci_write8:
912
 
1031
.bus			equ esp+4
-
 
1032
.devfn 		equ esp+8
-
 
1033
.pci_reg 	equ esp+12
Line -... Line 1034...
-
 
1034
.val      equ esp+16
913
				call	dword [pci_fn_table+eax]
1035
 
-
 
1036
				movzx ecx, byte [.devfn]
-
 
1037
				mov   ch, [.bus]
914
 
1038
				movzx edx, word [.pci_reg]
915
				popfd
1039
				push	dword [esp+16]
Line 916... Line 1040...
916
 
1040
				call	pci_bus_write8
917
				ret 	12
1041
				ret 	16
918
 
1042
 
919
align 4
1043
align 4
920
pci_write8:
1044
pci_write16:
921
				mov		eax, PCI_W8
1045
.bus			equ esp+4
Line 922... Line 1046...
922
				jmp		@F
1046
.devfn 		equ esp+8
923
 
1047
.pci_reg 	equ esp+12
924
align 4
-
 
925
pci_write16:
1048
.val      equ esp+16
-
 
1049
 
-
 
1050
				movzx ecx, byte [.devfn]
-
 
1051
				mov   ch, [.bus]
Line 926... Line -...
926
				mov		eax, PCI_W16
-
 
927
				jmp		@F
-
 
928
 
-
 
929
align 4
-
 
930
pci_write32:
-
 
Line 931... Line -...
931
				mov		eax, PCI_W32
-
 
Line 932... Line -...
932
 
-