Subversion Repositories Kolibri OS

Rev

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

Rev 8897 Rev 8898
Line 1014... Line 1014...
1014
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
1014
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
1015
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
1015
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
1016
        [eax+13]:2,[eax+12]:2
1016
        [eax+13]:2,[eax+12]:2
Line 1017... Line 1017...
1017
 
1017
 
1018
        cmp     [esi + NET_BUFF.length], 1514
1018
        cmp     [esi + NET_BUFF.length], 1514
1019
        ja      .fail
1019
        ja      .error
1020
        cmp     [esi + NET_BUFF.length], 60
1020
        cmp     [esi + NET_BUFF.length], 60
Line 1021... Line 1021...
1021
        jb      .fail
1021
        jb      .error
1022
 
1022
 
1023
; check descriptor
1023
; check descriptor
1024
        lea     edi, [ebx + device.tx_ring]
1024
        lea     edi, [ebx + device.tx_ring]
1025
        mov     ecx, [ebx + device.cur_tx]
1025
        mov     ecx, [ebx + device.cur_tx]
Line 1026... Line 1026...
1026
        shl     ecx, 4
1026
        shl     ecx, 4
1027
        add     edi, ecx
1027
        add     edi, ecx
1028
 
1028
 
1029
        test    [edi + descriptor.status], TXCTL_OWN
1029
        test    [edi + descriptor.status], TXCTL_OWN
1030
        jnz     .fail
1030
        jnz     .overrun
1031
; descriptor is free, use it
1031
; descriptor is free, use it
1032
        mov     [edi + descriptor.virtual], esi
1032
        mov     [edi + descriptor.virtual], esi
Line 1056... Line 1056...
1056
        inc     [ebx + device.packets_tx]
1056
        inc     [ebx + device.packets_tx]
1057
        mov     eax, [esi + NET_BUFF.length]
1057
        mov     eax, [esi + NET_BUFF.length]
1058
        add     dword[ebx + device.bytes_tx], eax
1058
        add     dword[ebx + device.bytes_tx], eax
1059
        adc     dword[ebx + device.bytes_tx + 4], 0
1059
        adc     dword[ebx + device.bytes_tx + 4], 0
Line 1060... Line -...
1060
 
-
 
1061
  .finish:
1060
 
1062
        popf
1061
        popf
1063
        xor     eax, eax
1062
        xor     eax, eax
Line 1064... Line 1063...
1064
        ret
1063
        ret
1065
 
1064
 
-
 
1065
  .error:
1066
  .fail:
1066
        DEBUGF  2, "TX packet error\n"
-
 
1067
        inc     [ebx + device.packets_tx_err]
-
 
1068
        invoke  NetFree, [bufferptr]
-
 
1069
 
-
 
1070
        popf
-
 
1071
        or      eax, -1
-
 
1072
        ret
-
 
1073
 
-
 
1074
  .overrun:
-
 
1075
        DEBUGF  2, "TX overrun\n"
-
 
1076
        inc     [ebx + device.packets_tx_ovr]
1067
        DEBUGF  2, "Send failed\n"
1077
        invoke  NetFree, [bufferptr]
1068
        invoke  NetFree, [bufferptr]
1078
 
1069
        popf
1079
        popf
Line 1070... Line 1080...
1070
        or      eax, -1
1080
        or      eax, -1
Line 1120... Line 1130...
1120
        jz      .not_receive
1130
        jz      .not_receive
Line 1121... Line 1131...
1121
 
1131
 
1122
        push    ebx
1132
        push    ebx
1123
  .rx_loop:
1133
  .rx_loop:
-
 
1134
        pop     ebx
1124
        pop     ebx
1135
        push    ebx
1125
        mov     eax, [ebx + device.cur_rx]
1136
        mov     eax, [ebx + device.cur_rx]
1126
        shl     eax, 4
1137
        shl     eax, 4
1127
        lea     edi, [ebx + device.rx_ring]
1138
        lea     edi, [ebx + device.rx_ring]
Line 1128... Line 1139...
1128
        add     edi, eax                        ; edi now points to current rx ring entry
1139
        add     edi, eax                        ; edi now points to current rx ring entry
1129
 
1140
 
Line 1130... Line 1141...
1130
        mov     ax, [edi + descriptor.status]
1141
        mov     ax, [edi + descriptor.status]
1131
        DEBUGF  1,"RX packet status: %x\n", eax:4
1142
        DEBUGF  1,"RX packet status: %x\n", eax:4
1132
 
-
 
-
 
1143
 
1133
        test    ax, RXSTAT_OWN                  ; If this bit is set, the controller OWN's the packet, if not, we do
1144
        test    ax, RXSTAT_OWN                  ; If this bit is set, the controller OWN's the packet, if not, we do
1134
        jnz     .not_receive
1145
        jnz     .rx_done
1135
 
-
 
1136
        test    ax, RXSTAT_ENP
1146
; Both Start of packet and End of packet bits should be set, we dont support multi frame packets
1137
        jz      .not_receive
1147
        test    ax, RXSTAT_ENP
Line 1138... Line 1148...
1138
 
1148
        jz      .rx_drop
1139
        test    ax, RXSTAT_STP
1149
        test    ax, RXSTAT_STP
1140
        jz      .not_receive
1150
        jz      .rx_drop
Line 1141... Line 1151...
1141
 
1151
 
1142
        movzx   ecx, [edi + descriptor.msg_length]      ; get packet length in ecx
-
 
1143
        sub     ecx, 4                                  ; We dont need the CRC
-
 
1144
        DEBUGF  1,"Got %u bytes\n", ecx
1152
        movzx   ecx, [edi + descriptor.msg_length]      ; get packet length in ecx
1145
 
1153
        sub     ecx, 4                                  ; We dont need the CRC
1146
; Set pointers for ETH_input
1154
        DEBUGF  1,"Got %u bytes\n", ecx
1147
        push    ebx
1155
 
1148
 
1156
; Set pointers for ETH_input
Line 1159... Line 1167...
1159
        inc     [ebx + device.packets_rx]
1167
        inc     [ebx + device.packets_rx]
Line 1160... Line 1168...
1160
 
1168
 
1161
; now allocate a new buffer
1169
; now allocate a new buffer
1162
        invoke  NetAlloc, PKT_BUF_SZ+NET_BUFF.data      ; Allocate a buffer for the next packet
1170
        invoke  NetAlloc, PKT_BUF_SZ+NET_BUFF.data      ; Allocate a buffer for the next packet
1163
        test    eax, eax
1171
        test    eax, eax
1164
        jz      .out_of_mem
1172
        jz      .rx_overrun
1165
        mov     [edi + descriptor.virtual], eax         ; set virtual address
1173
        mov     [edi + descriptor.virtual], eax         ; set virtual address
1166
        invoke  GetPhysAddr
1174
        invoke  GetPhysAddr
1167
        add     eax, NET_BUFF.data
1175
        add     eax, NET_BUFF.data
1168
        mov     [edi + descriptor.base], eax            ; and physical address
1176
        mov     [edi + descriptor.base], eax            ; and physical address
Line 1171... Line 1179...
1171
        inc     [ebx + device.cur_rx]                   ; set next receive descriptor
1179
        inc     [ebx + device.cur_rx]                   ; set next receive descriptor
1172
        and     [ebx + device.cur_rx], RX_RING_SIZE - 1
1180
        and     [ebx + device.cur_rx], RX_RING_SIZE - 1
Line 1173... Line 1181...
1173
 
1181
 
Line 1174... Line 1182...
1174
        jmp     [EthInput]
1182
        jmp     [EthInput]
-
 
1183
 
1175
 
1184
  .rx_overrun:
-
 
1185
        add     esp, 4+4
-
 
1186
        DEBUGF  2,"RX FIFO overrun\n"
-
 
1187
        inc     [ebx + device.packets_rx_ovr]
-
 
1188
        jmp     .rx_next
-
 
1189
 
-
 
1190
  .rx_drop:
-
 
1191
        DEBUGF  2,"Dropping incoming packet\n"
-
 
1192
        inc     [ebx + device.packets_rx_drop]
-
 
1193
 
Line 1176... Line 1194...
1176
  .out_of_mem:
1194
  .rx_next:
1177
        DEBUGF  2,"Out of memory!\n"
1195
        mov     [edi + descriptor.status], RXSTAT_OWN   ; give it back to PCnet controller
-
 
1196
 
Line -... Line 1197...
-
 
1197
        inc     [ebx + device.cur_rx]                   ; set next receive descriptor
1178
 
1198
        and     [ebx + device.cur_rx], RX_RING_SIZE - 1
Line 1179... Line 1199...
1179
        inc     [ebx + device.cur_rx]                   ; set next receive descriptor
1199
        jmp     .rx_loop
1180
        and     [ebx + device.cur_rx], RX_RING_SIZE - 1
1200
 
Line 1181... Line 1201...
1181
 
1201
  .rx_done: