Subversion Repositories Kolibri OS

Rev

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

Rev 3856 Rev 3857
Line 21... Line 21...
21
        DRIVER_VERSION          = 5
21
        DRIVER_VERSION          = 5
Line 22... Line 22...
22
 
22
 
Line 23... Line 23...
23
        MAX_DEVICES             = 16
23
        MAX_DEVICES             = 16
-
 
24
 
24
 
25
        RBLEN                   = 3 ; Receive buffer size: 0==8K 1==16k 2==32k 3==64k
-
 
26
 
-
 
27
        TXRR                    = 8 ; total retries = 16+(TXRR*16)
-
 
28
        TX_MXDMA                = 6 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=2048
-
 
29
        ERTXTH                  = 8 ; in unit of 32 bytes e.g:(8*32)=256
Line 25... Line 30...
25
        RBLEN                   = 3 ; Receive buffer size: 0==8K 1==16k 2==32k 3==64k
30
        RX_MXDMA                = 7 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=unlimited
26
        NUM_TX_DESC             = 4
31
        RXFTH                   = 7 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=no threshold
27
 
32
 
Line 117... Line 122...
117
        BIT_SELECTOR            = 0 ; binary encoded selector CSMA/CD=00001
122
        BIT_SELECTOR            = 0 ; binary encoded selector CSMA/CD=00001
Line 118... Line 123...
118
 
123
 
119
        BIT_IFG1                = 25
124
        BIT_IFG1                = 25
Line 120... Line -...
120
        BIT_IFG0                = 24
-
 
121
 
-
 
122
        TXRR                    = 8 ; total retries = 16+(TXRR*16)
-
 
123
        TX_MXDMA                = 6 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=2048
-
 
124
        ERTXTH                  = 8 ; in unit of 32 bytes e.g:(8*32)=256
-
 
125
        RX_MXDMA                = 7 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=unlimited
-
 
126
        RXFTH                   = 7 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=no threshold
125
        BIT_IFG0                = 24
127
 
126
 
128
        RX_CONFIG               = (RBLEN shl BIT_RBLEN) or \
127
        RX_CONFIG               = (RBLEN shl BIT_RBLEN) or \
129
                                  (RX_MXDMA shl BIT_RX_MXDMA) or \
128
                                  (RX_MXDMA shl BIT_RX_MXDMA) or \
130
                                  (1 shl BIT_NOWRAP) or \
129
                                  (1 shl BIT_NOWRAP) or \
131
                                  (RXFTH shl BIT_RXFTH) or\
130
                                  (RXFTH shl BIT_RXFTH) or\
132
                                  (1 shl BIT_AB) or \                 ; Accept broadcast packets
131
                                  (1 shl BIT_AB) or \                   ; Accept broadcast packets
133
                                  (1 shl BIT_APM) or \                ; Accept physical match packets
132
                                  (1 shl BIT_APM) or \                  ; Accept physical match packets
134
                                  (1 shl BIT_AER) or \                ; Accept error packets
133
                                  (1 shl BIT_AER) or \                  ; Accept error packets
Line 135... Line 134...
135
                                  (1 shl BIT_AR) or \                 ; Accept Runt packets (smaller then 64 bytes)
134
                                  (1 shl BIT_AR) or \                   ; Accept Runt packets (smaller then 64 bytes)
136
                                  (1 shl BIT_AM)                      ; Accept multicast packets
135
                                  (1 shl BIT_AM)                        ; Accept multicast packets
-
 
136
 
Line 137... Line 137...
137
 
137
        RX_BUFFER_SIZE          = (8192 shl RBLEN);+16+1500
138
        RX_BUFFER_SIZE          = (8192 shl RBLEN);+16
138
        MAX_ETH_FRAME_SIZE      = 1514
139
        MAX_ETH_FRAME_SIZE      = 1514
139
        NUM_TX_DESC             = 4                                     ; not user selectable
140
 
140
 
Line 175... Line 175...
175
        ISR_TOK                 = 1 shl 2
175
        ISR_TOK                 = 1 shl 2
176
        ISR_RER                 = 1 shl 1
176
        ISR_RER                 = 1 shl 1
177
        ISR_ROK                 = 1 shl 0
177
        ISR_ROK                 = 1 shl 0
Line 178... Line 178...
178
 
178
 
-
 
179
        INTERRUPT_MASK          = ISR_ROK or \
-
 
180
                                  ISR_RER or \
-
 
181
                                  ISR_TOK or \
179
        INTERRUPT_MASK          = ISR_ROK or \
182
                                  ISR_TER or \
180
                                  ISR_RXOVW or \
183
                                  ISR_RXOVW or \
181
                                  ISR_PUN or \
184
                                  ISR_PUN or \
182
                                  ISR_FIFOOVW or \
185
                                  ISR_FIFOOVW or \
183
                                  ISR_LENCHG or \
186
                                  ISR_LENCHG or \
184
                                  ISR_TOK or \
187
                                  ISR_TIMEOUT or \
-
 
188
                                  ISR_SERR
-
 
189
 
Line 185... Line 190...
185
                                  ISR_TER
190
 
186
 
191
 
187
        TSR_OWN                 = 1 shl 13
192
        TSR_OWN                 = 1 shl 13
Line 606... Line 611...
606
; set RxBuffer address, init RX buffer offset
611
; set RxBuffer address, init RX buffer offset
607
        mov     eax, [device.rx_buffer]
612
        mov     eax, [device.rx_buffer]
608
        mov     dword[eax], 0                   ; clear receive flags for first packet (really needed??)
613
        mov     dword[eax], 0                   ; clear receive flags for first packet (really needed??)
609
        DEBUGF  1, "RX buffer virtual addr=0x%x\n", eax
614
        DEBUGF  1, "RX buffer virtual addr=0x%x\n", eax
610
        GetRealAddr
615
        GetRealAddr
611
        DEBUGF  1, "RX buffer real addr=0x%x\n", eax
616
        DEBUGF  1, "RX buffer physical addr=0x%x\n", eax
612
        set_io  REG_RBSTART
617
        set_io  REG_RBSTART
613
        out     dx, eax
618
        out     dx, eax
Line 614... Line 619...
614
 
619
 
615
; Read MAC address
620
; Read MAC address
Line 875... Line 880...
875
; Transmit ok / Transmit error
880
; Transmit ok / Transmit error
876
  @@:
881
  @@:
877
        test    ax, ISR_TOK + ISR_TER
882
        test    ax, ISR_TOK + ISR_TER
878
        jz      @f
883
        jz      @f
Line -... Line 884...
-
 
884
 
-
 
885
        DEBUGF  1, "Transmit done!\n"
879
 
886
 
880
        push    ax
887
        push    ax
881
        mov     ecx, (NUM_TX_DESC-1)*4
888
        mov     ecx, (NUM_TX_DESC-1)*4
882
  .txdescloop:
889
  .txdescloop:
883
        set_io  0
890
        set_io  0
Line 889... Line 896...
889
        jz      .notthisone
896
        jz      .notthisone
Line 890... Line 897...
890
 
897
 
891
        cmp     [device.TX_DESC+ecx], 0
898
        cmp     [device.TX_DESC+ecx], 0
Line 892... Line 899...
892
        je      .notthisone
899
        je      .notthisone
-
 
900
 
893
 
901
        DEBUGF  1, "TSD: 0x%x\n", eax
894
;  .notxd:
902
 
895
;        test    eax, TSR_TUN
903
        test    eax, TSR_TUN
896
;        jz      .nobun
904
        jz      .no_bun
897
;        DEBUGF  2, "TX: FIFO Buffer underrun!\n"
905
        DEBUGF  2, "TX: FIFO Buffer underrun!\n"
898
;
906
 
899
;  .nobun:
907
  .no_bun:
900
;        test    eax, TSR_OWC
908
        test    eax, TSR_OWC
901
;        jz      .noowc
909
        jz      .no_owc
902
;        DEBUGF  2, "TX: OWC!\n"
910
        DEBUGF  2, "TX: OWC!\n"
903
;
911
 
904
;  .noowc:
912
  .no_owc:
905
;        test    eax, TSR_TABT
913
        test    eax, TSR_TABT
906
;        jz      .notabt
914
        jz      .no_tabt
907
;        DEBUGF  2, "TX: TABT!\n"
915
        DEBUGF  2, "TX: TABT!\n"
908
;
916
 
909
;  .notabt:
917
  .no_tabt:
910
;        test    eax, TSR_CRS
918
        test    eax, TSR_CRS
911
;        jz      .nocsl
919
        jz      .no_csl
912
;        DEBUGF  2, "TX: Carrier Sense Lost!\n"
920
        DEBUGF  2, "TX: Carrier Sense Lost!\n"
-
 
921
 
-
 
922
  .no_csl:
-
 
923
        test    eax, TSR_TOK
Line -... Line 924...
-
 
924
        jz      .no_tok
913
;
925
        DEBUGF  1, "TX: Transmit OK!\n"
914
;  .nocsl:
926
 
915
 
927
  .no_tok:
916
        DEBUGF  1, "TX OK: free buffer %x\n", [device.TX_DESC+ecx]:8
928
        DEBUGF  1, "free transmit buffer 0x%x\n", [device.TX_DESC+ecx]:8
917
        push    ecx ebx
929
        push    ecx ebx
Line 918... Line 930...
918
        stdcall KernelFree, [device.TX_DESC+ecx]
930
        stdcall KernelFree, [device.TX_DESC+ecx]
919
        pop     ebx ecx
931
        pop     ebx ecx
920
        mov     [device.TX_DESC+ecx], 0
932
        mov     [device.TX_DESC+ecx], 0
921
 
933
 
Line 922... Line 934...
922
  .notthisone:
934
  .notthisone:
923
        sub     ecx, 4
935
        sub     ecx, 4
924
        ja      .txdescloop
936
        jae     .txdescloop
Line 986... Line 998...
986
;;                     ;;
998
;;                     ;;
987
;;;;;;;;;;;;;;;;;;;;;;;;;
999
;;;;;;;;;;;;;;;;;;;;;;;;;
Line 988... Line 1000...
988
 
1000
 
989
align 4
1001
align 4
990
cable:
1002
cable:
Line 991... Line 1003...
991
        DEBUGF  1, "Updating Cable status\n"
1003
        DEBUGF  1, "Checking link status:\n"
992
 
1004
 
993
        set_io  0
1005
        set_io  0
Line 1001... Line 1013...
1001
        jnz     .10mbps
1013
        jnz     .10mbps
Line 1002... Line 1014...
1002
 
1014
 
1003
  .100mbps:
1015
  .100mbps:
1004
        mov     [device.state], ETH_LINK_100M
1016
        mov     [device.state], ETH_LINK_100M
-
 
1017
        call    NetLinkChanged
Line 1005... Line 1018...
1005
        call    NetLinkChanged
1018
        DEBUGF  1, "100 mbit\n"
Line 1006... Line 1019...
1006
 
1019
 
1007
        ret
1020
        ret
1008
 
1021
 
-
 
1022
  .10mbps:
Line 1009... Line 1023...
1009
  .10mbps:
1023
        mov     [device.state], ETH_LINK_10M
Line 1010... Line 1024...
1010
        mov     [device.state], ETH_LINK_10M
1024
        call    NetLinkChanged
1011
        call    NetLinkChanged
1025
        DEBUGF  1, "10 mbit\n"
1012
 
1026
 
-
 
1027
        ret
Line 1013... Line 1028...
1013
        ret
1028
 
Line 1075... Line 1090...
1075
;; Read MAC address ;;
1090
;; Read MAC address ;;
1076
;;                  ;;
1091
;;                  ;;
1077
;;;;;;;;;;;;;;;;;;;;;;
1092
;;;;;;;;;;;;;;;;;;;;;;
Line 1078... Line 1093...
1078
 
1093
 
1079
read_mac:
1094
read_mac:
Line 1080... Line 1095...
1080
        DEBUGF  2, "Reading MAC:\n"
1095
        DEBUGF  1, "Reading MAC:\n"
1081
 
1096
 
1082
        set_io  0
1097
        set_io  0
1083
        lea     edi, [device.mac]
1098
        lea     edi, [device.mac]
1084
        in      eax, dx
1099
        in      eax, dx
1085
        stosd
1100
        stosd
1086
        add     edx, 4
1101
        add     edx, 4
Line 1087... Line 1102...
1087
        in      ax, dx
1102
        in      ax, dx
Line 1088... Line 1103...
1088
        stosw
1103
        stosw
Line 1089... Line 1104...
1089
 
1104