Rev 5363 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5363 | Rev 5522 | ||
---|---|---|---|
Line 592... | Line 592... | ||
592 | DEBUGF 1, "21040 compatibility mode\n" |
592 | DEBUGF 1, "21040 compatibility mode\n" |
593 | mov [ebx + device.id], DC21040 |
593 | mov [ebx + device.id], DC21040 |
594 | @@: |
594 | @@: |
Line 595... | Line -... | ||
595 | - | ||
596 | - | ||
597 | ;;; Find connected mii xceivers? 993-1043 |
595 | |
598 | 596 | ||
599 | ; Reset the xcvr interface and turn on heartbeat. |
597 | ; Reset the xcvr interface and turn on heartbeat. |
600 | cmp [ebx + device.id], DC21041 |
598 | cmp [ebx + device.id], DC21041 |
601 | jne @f |
599 | jne @f |
Line 867... | Line 865... | ||
867 | mov ecx, RX_RING_SIZE |
865 | mov ecx, RX_RING_SIZE |
868 | .loop_rx_des: |
866 | .loop_rx_des: |
869 | DEBUGF 1,"RX descriptor 0x%x\n", edi |
867 | DEBUGF 1,"RX descriptor 0x%x\n", edi |
870 | add edx, sizeof.desc |
868 | add edx, sizeof.desc |
871 | mov [edi + desc.status], DES0_OWN |
869 | mov [edi + desc.status], DES0_OWN |
872 | mov [edi + desc.length], 1536 |
870 | mov [edi + desc.length], 1514 |
873 | push edx edi ecx |
871 | push edx edi ecx |
874 | invoke KernelAlloc, 1536 |
872 | invoke NetAlloc, 1514+NET_BUFF.data |
875 | pop ecx edi edx |
873 | pop ecx edi edx |
876 | test eax, eax |
874 | test eax, eax |
877 | jz .out_of_mem |
875 | jz .out_of_mem |
878 | mov [edi + RX_RING_SIZE*sizeof.desc], eax |
876 | mov [edi + RX_RING_SIZE*sizeof.desc], eax |
- | 877 | push edx |
|
879 | invoke GetPhysAddr |
878 | invoke GetPhysAddr |
- | 879 | add eax, NET_BUFF.data |
|
- | 880 | pop edx |
|
880 | mov [edi + desc.buffer1], eax |
881 | mov [edi + desc.buffer1], eax |
881 | mov [edi + desc.buffer2], edx |
882 | mov [edi + desc.buffer2], edx |
882 | add edi, sizeof.desc |
883 | add edi, sizeof.desc |
883 | dec ecx |
884 | dec ecx |
884 | jnz .loop_rx_des |
885 | jnz .loop_rx_des |
- | 886 | ||
885 | ; set last descriptor as LAST |
887 | ; set last descriptor as LAST |
886 | or [edi - sizeof.desc + desc.length], RDES1_RER ; EndOfRing |
888 | or [edi - sizeof.desc + desc.length], RDES1_RER ; EndOfRing |
887 | pop [edi - sizeof.desc + desc.buffer2] ; point it to the first descriptor |
889 | pop [edi - sizeof.desc + desc.buffer2] ; point it to the first descriptor |
Line 888... | Line 890... | ||
888 | 890 | ||
Line 915... | Line 917... | ||
915 | xor eax, eax |
917 | xor eax, eax |
916 | mov [ebx + device.cur_tx], eax |
918 | mov [ebx + device.cur_tx], eax |
917 | mov [ebx + device.last_tx], eax |
919 | mov [ebx + device.last_tx], eax |
918 | mov [ebx + device.cur_rx], eax |
920 | mov [ebx + device.cur_rx], eax |
Line -... | Line 921... | ||
- | 921 | ||
919 | 922 | ; xor eax, eax |
|
Line 920... | Line 923... | ||
920 | ret |
923 | ret |
921 | 924 | ||
922 | .out_of_mem: |
925 | .out_of_mem: |
Line 1041... | Line 1044... | ||
1041 | align 4 |
1044 | align 4 |
1042 | create_setup_frame: |
1045 | create_setup_frame: |
Line 1043... | Line 1046... | ||
1043 | 1046 | ||
Line 1044... | Line 1047... | ||
1044 | DEBUGF 1,"Creating setup packet\n" |
1047 | DEBUGF 1,"Creating setup packet\n" |
1045 | 1048 | ||
1046 | invoke KernelAlloc, 192 |
1049 | invoke NetAlloc, 192 + NET_BUFF.data |
- | 1050 | test eax, eax |
|
- | 1051 | jz .err |
|
Line 1047... | Line 1052... | ||
1047 | test eax, eax |
1052 | mov [eax + NET_BUFF.device], ebx |
Line 1048... | Line 1053... | ||
1048 | jz .err |
1053 | mov [eax + NET_BUFF.length], 192 |
1049 | 1054 | ||
1050 | push eax |
1055 | push eax |
1051 | 1056 | ||
1052 | mov edi, eax |
1057 | lea edi, [eax + NET_BUFF.data] |
1053 | xor eax, eax |
1058 | xor eax, eax |
Line 1069... | Line 1074... | ||
1069 | ; setup descriptor |
1074 | ; setup descriptor |
1070 | lea edi, [ebx + device.tx_ring] |
1075 | lea edi, [ebx + device.tx_ring] |
1071 | DEBUGF 1, "attaching setup packet 0x%x to descriptor 0x%x\n", eax, edi |
1076 | DEBUGF 1, "attaching setup packet 0x%x to descriptor 0x%x\n", eax, edi |
1072 | mov [edi + TX_RING_SIZE*sizeof.desc], eax |
1077 | mov [edi + TX_RING_SIZE*sizeof.desc], eax |
1073 | invoke GetPhysAddr |
1078 | invoke GetPhysAddr |
- | 1079 | add eax, NET_BUFF.data |
|
1074 | mov [edi + desc.buffer1], eax |
1080 | mov [edi + desc.buffer1], eax |
1075 | mov [edi + desc.length], TDES1_SET + 192 ; size must be EXACTLY 192 bytes + TDES1_IC |
1081 | mov [edi + desc.length], TDES1_SET or 192 ; size must be EXACTLY 192 bytes + TDES1_IC |
1076 | mov [edi + desc.status], DES0_OWN |
1082 | mov [edi + desc.status], DES0_OWN |
1077 | DEBUGF 1, "descriptor 0x%x\n", edi |
1083 | DEBUGF 1, "descriptor 0x%x\n", edi |
Line 1078... | Line 1084... | ||
1078 | 1084 | ||
1079 | ; go to next descriptor |
1085 | ; go to next descriptor |
- | 1086 | inc [ebx + device.cur_tx] |
|
Line -... | Line 1087... | ||
- | 1087 | and [ebx + device.cur_tx], TX_RING_SIZE-1 |
|
1080 | inc [ebx + device.cur_tx] |
1088 | |
Line 1081... | Line 1089... | ||
1081 | 1089 | xor eax, eax |
|
1082 | ret |
1090 | ret |
- | 1091 | ||
1083 | 1092 | .err: |
|
Line 1084... | Line 1093... | ||
1084 | .err: |
1093 | DEBUGF 2, "Out of memory!\n" |
1085 | DEBUGF 2, "Out of memory!\n" |
1094 | or eax, -1 |
1086 | ret |
1095 | ret |
1087 | 1096 | ||
1088 | 1097 | ||
1089 | 1098 | ||
1090 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
- | |
1091 | ;; ;; |
1099 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1092 | ;; Transmit ;; |
1100 | ;; ;; |
Line 1093... | Line 1101... | ||
1093 | ;; ;; |
1101 | ;; Transmit ;; |
Line 1094... | Line 1102... | ||
1094 | ;; In: buffer pointer in [esp+4] ;; |
1102 | ;; ;; |
1095 | ;; size of buffer in [esp+8] ;; |
1103 | ;; In: ebx = pointer to device structure ;; |
Line -... | Line 1104... | ||
- | 1104 | ;; Out: eax = 0 on success ;; |
|
1096 | ;; pointer to device structure in ebx ;; |
1105 | ;; ;; |
1097 | ;; ;; |
1106 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1098 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1107 | |
1099 | 1108 | proc transmit stdcall bufferptr |
|
1100 | proc transmit stdcall bufferptr, buffersize |
1109 | |
1101 | 1110 | pushf |
|
Line 1102... | Line 1111... | ||
1102 | pushf |
1111 | cli |
1103 | cli |
1112 | |
- | 1113 | mov esi, [bufferptr] |
|
- | 1114 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length] |
|
Line 1104... | Line 1115... | ||
1104 | 1115 | lea eax, [esi + NET_BUFF.data] |
|
1105 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize] |
1116 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
1106 | mov eax, [bufferptr] |
1117 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
1107 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
1118 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
1108 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
1119 | [eax+13]:2,[eax+12]:2 |
1109 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
1120 | |
Line 1110... | Line -... | ||
1110 | [eax+13]:2,[eax+12]:2 |
- | |
1111 | - | ||
1112 | cmp [buffersize], 1514 |
1121 | cmp [esi + NET_BUFF.length], 1514 |
1113 | ja .fail |
1122 | ja .fail |
- | 1123 | cmp [esi + NET_BUFF.length], 60 |
|
1114 | 1124 | jb .fail |
|
1115 | mov eax, [ebx + device.cur_tx] |
1125 | |
Line 1116... | Line 1126... | ||
1116 | mov edx, sizeof.desc |
1126 | mov eax, [ebx + device.cur_tx] |
1117 | mul edx |
1127 | mov edx, sizeof.desc |
1118 | lea esi, [ebx + device.tx_ring + eax] |
1128 | mul edx |
1119 | test [esi + desc.status], DES0_OWN |
1129 | lea edi, [ebx + device.tx_ring + eax] |
1120 | jnz .fail |
1130 | test [edi + desc.status], DES0_OWN |
1121 | 1131 | jnz .fail |
|
Line 1122... | Line 1132... | ||
1122 | DEBUGF 1, "Descriptor is free\n" |
1132 | |
1123 | 1133 | mov eax, [bufferptr] |
|
Line 1124... | Line 1134... | ||
1124 | mov eax, [bufferptr] |
1134 | mov [edi + TX_RING_SIZE*sizeof.desc], eax |
1125 | mov [esi + TX_RING_SIZE*sizeof.desc], eax |
1135 | add eax, [eax + NET_BUFF.offset] |
1126 | invoke GetPhysAddr |
1136 | invoke GetPhysAddr |
1127 | mov [esi + desc.buffer1], eax |
1137 | mov [edi + desc.buffer1], eax |
Line 1153... | Line 1163... | ||
1153 | .do_it: |
1163 | .do_it: |
1154 | out dx, eax |
1164 | out dx, eax |
Line 1155... | Line 1165... | ||
1155 | 1165 | ||
1156 | ; Update stats |
1166 | ; Update stats |
1157 | inc [ebx + device.packets_tx] |
1167 | inc [ebx + device.packets_tx] |
1158 | mov eax, [buffersize] |
1168 | mov ecx, [esi + NET_BUFF.length] |
1159 | add dword [ebx + device.bytes_tx], eax |
1169 | add dword [ebx + device.bytes_tx], ecx |
Line 1160... | Line 1170... | ||
1160 | adc dword [ebx + device.bytes_tx + 4], 0 |
1170 | adc dword [ebx + device.bytes_tx + 4], 0 |
1161 | 1171 | ||
1162 | ; go to next descriptor |
1172 | ; go to next descriptor |
Line 1167... | Line 1177... | ||
1167 | popf |
1177 | popf |
1168 | xor eax, eax |
1178 | xor eax, eax |
1169 | ret |
1179 | ret |
Line 1170... | Line 1180... | ||
1170 | 1180 | ||
1171 | .fail: |
1181 | .fail: |
1172 | DEBUGF 2,"Transmit failed\n" |
1182 | DEBUGF 1,"Transmit failed\n" |
1173 | invoke KernelFree, [bufferptr] |
1183 | invoke NetFree, [bufferptr] |
1174 | popf |
1184 | popf |
1175 | or eax, -1 |
1185 | or eax, -1 |
Line 1176... | Line 1186... | ||
1176 | ret |
1186 | ret |
Line 1239... | Line 1249... | ||
1239 | cmp [eax + desc.buffer1], 0 ; empty descriptor? |
1249 | cmp [eax + desc.buffer1], 0 ; empty descriptor? |
1240 | je .end_tx |
1250 | je .end_tx |
Line 1241... | Line 1251... | ||
1241 | 1251 | ||
1242 | mov [eax + desc.buffer1], 0 |
1252 | mov [eax + desc.buffer1], 0 |
1243 | DEBUGF 1,"Free buffer 0x%x\n", [eax + TX_RING_SIZE*sizeof.desc] |
1253 | DEBUGF 1, "Free buffer 0x%x\n", [eax + TX_RING_SIZE*sizeof.desc] |
Line 1244... | Line 1254... | ||
1244 | invoke KernelFree, [eax + TX_RING_SIZE*sizeof.desc] |
1254 | invoke NetFree, [eax + TX_RING_SIZE*sizeof.desc] |
1245 | 1255 | ||
1246 | ; advance to next descriptor |
1256 | ; advance to next descriptor |
Line 1252... | Line 1262... | ||
1252 | pop ecx esi eax |
1262 | pop ecx esi eax |
1253 | .not_tx: |
1263 | .not_tx: |
Line 1254... | Line 1264... | ||
1254 | 1264 | ||
1255 | ;---------------------------------- |
1265 | ;---------------------------------- |
1256 | ; RX irq |
- | |
1257 | 1266 | ; RX irq |
|
1258 | test eax, CSR5_RI |
1267 | test eax, CSR5_RI |
1259 | jz .not_rx |
1268 | jz .not_rx |
Line 1260... | Line 1269... | ||
1260 | push eax esi ecx |
1269 | push eax esi ecx |
Line 1269... | Line 1278... | ||
1269 | mov eax, [ebx + device.cur_rx] |
1278 | mov eax, [ebx + device.cur_rx] |
1270 | mov edx, sizeof.desc |
1279 | mov edx, sizeof.desc |
1271 | mul edx |
1280 | mul edx |
1272 | lea edi, [ebx + device.rx_ring + eax] |
1281 | lea edi, [ebx + device.rx_ring + eax] |
Line 1273... | Line 1282... | ||
1273 | 1282 | ||
1274 | ; Check current RX descriptor status |
1283 | ; now check status |
Line 1275... | Line 1284... | ||
1275 | mov eax, [edi + desc.status] |
1284 | mov eax, [edi + desc.status] |
1276 | 1285 | ||
1277 | test eax, DES0_OWN |
1286 | test eax, DES0_OWN |
Line 1288... | Line 1297... | ||
1288 | shr ecx, RDES0_FL_SH |
1297 | shr ecx, RDES0_FL_SH |
1289 | and ecx, RDES0_FL_MASK |
1298 | and ecx, RDES0_FL_MASK |
1290 | sub ecx, 4 ; throw away the CRC |
1299 | sub ecx, 4 ; throw away the CRC |
1291 | DEBUGF 1,"got %u bytes\n", ecx |
1300 | DEBUGF 1,"got %u bytes\n", ecx |
Line 1292... | Line 1301... | ||
1292 | 1301 | ||
1293 | ; Push arguments for Eth_input (and some more...) |
1302 | ; Push arguments for EthInput (and some more...) |
1294 | push ebx |
1303 | push ebx |
1295 | push .rx_loop ; return addr |
1304 | push .rx_loop ; return addr |
- | 1305 | mov eax, dword[edi + RX_RING_SIZE*sizeof.desc] |
|
- | 1306 | push eax |
|
- | 1307 | mov [eax + NET_BUFF.length], ecx |
|
1296 | push ecx ; packet size |
1308 | mov [eax + NET_BUFF.device], ebx |
Line 1297... | Line 1309... | ||
1297 | push dword[edi + RX_RING_SIZE*sizeof.desc] ; packet ptr |
1309 | mov [eax + NET_BUFF.offset], NET_BUFF.data |
1298 | 1310 | ||
1299 | ; update statistics |
1311 | ; update statistics |
1300 | inc [ebx + device.packets_rx] |
1312 | inc [ebx + device.packets_rx] |
Line 1301... | Line 1313... | ||
1301 | add dword[ebx + device.bytes_rx], ecx |
1313 | add dword[ebx + device.bytes_rx], ecx |
1302 | adc dword[ebx + device.bytes_rx + 4], 0 |
1314 | adc dword[ebx + device.bytes_rx + 4], 0 |
1303 | 1315 | ||
1304 | ; Allocate new descriptor |
1316 | ; Allocate new descriptor |
- | 1317 | push edi ebx |
|
1305 | push edi ebx |
1318 | invoke NetAlloc, 1514 + NET_BUFF.data ; Allocate a buffer to put packet into |
1306 | invoke KernelAlloc, 1536 ; Allocate a buffer to put packet into |
1319 | pop ebx edi |
- | 1320 | jz .fail |
|
1307 | pop ebx edi |
1321 | mov [edi + RX_RING_SIZE*sizeof.desc], eax |
1308 | mov [edi + RX_RING_SIZE*sizeof.desc], eax |
1322 | invoke GetPhysAddr |
Line 1309... | Line 1323... | ||
1309 | invoke GetPhysAddr |
1323 | add eax, NET_BUFF.data |
1310 | mov [edi + desc.buffer1], eax |
1324 | mov [edi + desc.buffer1], eax |
1311 | mov [edi + desc.status], DES0_OWN ; mark descriptor as being free |
1325 | mov [edi + desc.status], DES0_OWN ; mark descriptor as being free |
Line 1312... | Line 1326... | ||
1312 | 1326 | ||
1313 | ; Move to next rx desc |
1327 | ; Move to next rx desc |
- | 1328 | inc [ebx + device.cur_rx] ; next descriptor |
|
- | 1329 | and [ebx + device.cur_rx], RX_RING_SIZE-1 |
|
1314 | inc [ebx + device.cur_rx] ; next descriptor |
1330 | |
Line 1315... | Line 1331... | ||
1315 | and [ebx + device.cur_rx], RX_RING_SIZE-1 |
1331 | jmp [EthInput] |
1316 | 1332 | .end_rx: |