Subversion Repositories Kolibri OS

Rev

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

Rev 593 Rev 869
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2007. 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
;;  RTL8169.INC                                                    ;;
6
;;  RTL8169.INC                                                    ;;
Line 24... Line 24...
24
;;                                                                 ;;
24
;;                                                                 ;;
25
;;  See file COPYING for details                                   ;;
25
;;  See file COPYING for details                                   ;;
26
;;                                                                 ;;
26
;;                                                                 ;;
27
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 28... Line 28...
28
 
28
 
Line 29... Line 29...
29
$Revision: 593 $
29
$Revision: 869 $
30
 
30
 
31
 
31
 
Line 337... Line 337...
337
align 256
337
align 256
338
rtl8169_txb rb NUM_TX_DESC * RX_BUF_SIZE
338
rtl8169_txb rb NUM_TX_DESC * RX_BUF_SIZE
Line 339... Line 339...
339
 
339
 
340
; Define the RX Descriptor
340
; Define the RX Descriptor
341
align 256
341
align 256
Line 342... Line 342...
342
rtl8169_rx_ring rb NUM_RX_DESC * sizeof.rtl8169_TxDesc
342
rtl8169_rx_ring rb NUM_RX_DESC * sizeof.rtl8169_RxDesc
343
 
343
 
344
; Create a static buffer of size RX_BUF_SZ for each
344
; Create a static buffer of size RX_BUF_SZ for each
345
; RX Descriptor   All descriptors point to a
345
; RX Descriptor   All descriptors point to a
Line 714... Line 714...
714
;       ret
714
;       ret
715
;endp
715
;endp
Line 716... Line 716...
716
 
716
 
Line 717... Line 717...
717
proc RTL8169_WRITE_GMII_REG,RegAddr:byte,value:dword
717
proc RTL8169_WRITE_GMII_REG,RegAddr:byte,value:dword
Line 718... Line 718...
718
 
718
 
719
	DEBUGF	1,"K : RTL8169_WRITE_GMII_REG: 0x%x 0x%x\n",[RegAddr]:2,[value]
719
;;;	DEBUGF	1,"K : RTL8169_WRITE_GMII_REG: 0x%x 0x%x\n",[RegAddr]:2,[value]
720
 
720
 
721
	movzx	eax,[RegAddr]
721
	movzx	eax,[RegAddr]
722
	shl	eax,16
722
	shl	eax,16
723
	or	eax,[value]
723
	or	eax,[value]
Line 724... Line 724...
724
	or	eax,0x80000000
724
	or	eax,0x80000000
725
	RTL_W32 RTL8169_REG_PHYAR,eax
725
	RTL_W32 RTL8169_REG_PHYAR,eax
726
	stdcall udelay,1000
726
	stdcall udelay,1	;;;1000
727
 
727
 
728
	mov	ecx,2000
728
	mov	ecx,2000
729
	; Check if the RTL8169 has completed writing to the specified MII register
729
	; Check if the RTL8169 has completed writing to the specified MII register
730
    @@: RTL_R32 RTL8169_REG_PHYAR
730
    @@: RTL_R32 RTL8169_REG_PHYAR
731
	test	eax,0x80000000
731
	test	eax,0x80000000
732
	jz	.exit
732
	jz	.exit
733
	stdcall udelay,100
733
	stdcall udelay,1	;;;100
Line 734... Line 734...
734
	loop	@b
734
	loop	@b
Line 735... Line 735...
735
  .exit:
735
  .exit:
Line 736... Line 736...
736
	ret
736
	ret
737
endp
737
endp
738
 
738
 
739
proc RTL8169_READ_GMII_REG,RegAddr:byte
739
proc RTL8169_READ_GMII_REG,RegAddr:byte
740
 
740
 
741
	DEBUGF	1,"K : RTL8169_READ_GMII_REG: 0x%x\n",[RegAddr]:2
741
;;;	DEBUGF	1,"K : RTL8169_READ_GMII_REG: 0x%x\n",[RegAddr]:2
Line 742... Line 742...
742
 
742
 
743
	push	ecx
743
	push	ecx
744
	movzx	eax,[RegAddr]
744
	movzx	eax,[RegAddr]
745
	shl	eax,16
745
	shl	eax,16
746
;       or      eax,0x0
746
;       or      eax,0x0
747
	RTL_W32 RTL8169_REG_PHYAR,eax
747
	RTL_W32 RTL8169_REG_PHYAR,eax
748
	stdcall udelay,1000
748
	stdcall udelay,1	;;;1000
Line 749... Line 749...
749
 
749
 
750
	mov	ecx,2000
750
	mov	ecx,2000
751
	; Check if the RTL8169 has completed retrieving data from the specified MII register
751
	; Check if the RTL8169 has completed retrieving data from the specified MII register
Line 818... Line 818...
818
	mov	edi,[rtl8169_tpc.RxDescArray]
818
	mov	edi,[rtl8169_tpc.RxDescArray]
819
	mov	eax,rtl8169_rxb
819
	mov	eax,rtl8169_rxb
820
	mov	ecx,NUM_RX_DESC
820
	mov	ecx,NUM_RX_DESC
821
    @@: mov	[esi],eax
821
    @@: mov	[esi],eax
822
	mov	[edi+rtl8169_RxDesc.buf_addr],eax
822
	mov	[edi+rtl8169_RxDesc.buf_addr],eax
-
 
823
	sub	[edi+rtl8169_RxDesc.buf_addr],OS_BASE				; shurf 28.09.2008
823
	mov	[edi+rtl8169_RxDesc.status],RTL8169_DSB_OWNbit or RX_BUF_SIZE
824
	mov	[edi+rtl8169_RxDesc.status],RTL8169_DSB_OWNbit or RX_BUF_SIZE
824
	add	esi,4
825
	add	esi,4
825
	add	edi,sizeof.rtl8169_RxDesc
826
	add	edi,sizeof.rtl8169_RxDesc
826
	add	eax,RX_BUF_SIZE
827
	add	eax,RX_BUF_SIZE
827
	loop	@b
828
	loop	@b
Line 877... Line 878...
877
;       RTL_W16 0xE2,0x152a
878
;       RTL_W16 0xE2,0x152a
878
;       RTL_W16 0xE2,0x282a
879
;       RTL_W16 0xE2,0x282a
879
	RTL_W16 0xE2,0x0000
880
	RTL_W16 0xE2,0x0000
Line 880... Line 881...
880
 
881
 
-
 
882
	MOV	[rtl8169_tpc.cur_rx],0
-
 
883
	push	eax								; shurf 28.09.2008
-
 
884
	mov	eax, [rtl8169_tpc.TxDescArray]					; shurf 28.09.2008
881
	MOV	[rtl8169_tpc.cur_rx],0
885
	sub	eax, OS_BASE							; shurf 28.09.2008
-
 
886
	RTL_W32 RTL8169_REG_TxDescStartAddr,eax ;[rtl8169_tpc.TxDescArray]	; shurf 28.09.2008
-
 
887
	mov	eax, [rtl8169_tpc.RxDescArray]					; shurf 28.09.2008
882
	RTL_W32 RTL8169_REG_TxDescStartAddr,[rtl8169_tpc.TxDescArray]
888
	sub	eax, OS_BASE							; shurf 28.09.2008
-
 
889
	RTL_W32 RTL8169_REG_RxDescStartAddr,eax ;[rtl8169_tpc.RxDescArray]	; shurf 28.09.2008
883
	RTL_W32 RTL8169_REG_RxDescStartAddr,[rtl8169_tpc.RxDescArray]
890
	pop	eax								; shurf 28.09.2008
884
	RTL_W8	RTL8169_REG_Cfg9346,RTL8169_CFG_9346_Lock
891
	RTL_W8	RTL8169_REG_Cfg9346,RTL8169_CFG_9346_Lock
885
	stdcall udelay,10
892
	stdcall udelay,10
886
	RTL_W32 RTL8169_REG_RxMissed,0
893
	RTL_W32 RTL8169_REG_RxMissed,0
887
	call	rtl8169_set_rx_mode
894
	call	rtl8169_set_rx_mode
Line 1085... Line 1092...
1085
	mov	eax,sizeof.rtl8169_TxDesc
1092
	mov	eax,sizeof.rtl8169_TxDesc
1086
	mul	[rtl8169_tpc.cur_tx]
1093
	mul	[rtl8169_tpc.cur_tx]
1087
	add	eax,[rtl8169_tpc.TxDescArray]
1094
	add	eax,[rtl8169_tpc.TxDescArray]
1088
	xchg	eax,ebx
1095
	xchg	eax,ebx
1089
	mov	[ebx + rtl8169_TxDesc.buf_addr],eax
1096
	mov	[ebx + rtl8169_TxDesc.buf_addr],eax
-
 
1097
	sub	[ebx + rtl8169_TxDesc.buf_addr],OS_BASE					; shurf 28.09.2008
Line 1090... Line 1098...
1090
 
1098
 
1091
	mov	eax,ecx
1099
	mov	eax,ecx
1092
	cmp	eax,ETH_ZLEN
1100
	cmp	eax,ETH_ZLEN
1093
	jae	@f
1101
	jae	@f
Line 1188... Line 1196...
1188
	jne	@f
1196
	jne	@f
1189
	or	eax,RTL8169_DSB_EORbit
1197
	or	eax,RTL8169_DSB_EORbit
1190
    @@: mov	[ebx + rtl8169_RxDesc.status],eax
1198
    @@: mov	[ebx + rtl8169_RxDesc.status],eax
Line 1191... Line 1199...
1191
 
1199
 
-
 
1200
	mov	[ebx + rtl8169_RxDesc.buf_addr],edx
1192
	mov	[ebx + rtl8169_RxDesc.buf_addr],edx
1201
	sub	[ebx + rtl8169_RxDesc.buf_addr],OS_BASE					; shurf 28.09.2008
1193
	jmp	@f
1202
	jmp	@f
1194
  .else:
1203
  .else:
1195
	DEBUGF	1,"K : rtl8169_poll: Rx Error\n"
1204
	DEBUGF	1,"K : rtl8169_poll: Rx Error\n"
1196
	; FIXME: shouldn't I reset the status on an error
1205
	; FIXME: shouldn't I reset the status on an error