Rev 5180 | Rev 5363 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5180 | Rev 5184 | ||
---|---|---|---|
Line 1225... | Line 1225... | ||
1225 | jz .not_tx |
1225 | jz .not_tx |
Line 1226... | Line 1226... | ||
1226 | 1226 | ||
1227 | push eax esi ecx |
1227 | push eax esi ecx |
1228 | DEBUGF 1,"TX ok!\n" |
1228 | DEBUGF 1,"TX ok!\n" |
1229 | .loop_tx: |
1229 | .loop_tx: |
1230 | ; go to last descriptor |
1230 | ; get last descriptor |
1231 | mov eax, [ebx + device.last_tx] |
1231 | mov eax, [ebx + device.last_tx] |
1232 | mov edx, sizeof.desc |
1232 | mov edx, sizeof.desc |
1233 | mul edx |
1233 | mul edx |
Line 1241... | Line 1241... | ||
1241 | 1241 | ||
1242 | mov [eax + desc.buffer1], 0 |
1242 | mov [eax + desc.buffer1], 0 |
1243 | DEBUGF 1, "Free buffer 0x%x\n", [eax + TX_RING_SIZE*sizeof.desc] |
1243 | DEBUGF 1,"Free buffer 0x%x\n", [eax + TX_RING_SIZE*sizeof.desc] |
Line 1244... | Line 1244... | ||
1244 | invoke KernelFree, [eax + TX_RING_SIZE*sizeof.desc] |
1244 | invoke KernelFree, [eax + TX_RING_SIZE*sizeof.desc] |
1245 | 1245 | ||
1246 | ; next descriptor |
1246 | ; advance to next descriptor |
Line 1247... | Line 1247... | ||
1247 | inc [ebx + device.last_tx] |
1247 | inc [ebx + device.last_tx] |
1248 | and [ebx + device.last_tx], TX_RING_SIZE-1 |
1248 | and [ebx + device.last_tx], TX_RING_SIZE-1 |
1249 | 1249 | ||
1250 | jmp .loop_tx |
1250 | jmp .loop_tx |
Line 1251... | Line 1251... | ||
1251 | .end_tx: |
1251 | .end_tx: |
1252 | pop ecx esi eax |
1252 | pop ecx esi eax |
- | 1253 | .not_tx: |
|
1253 | .not_tx: |
1254 | |
1254 | 1255 | ;---------------------------------- |
|
1255 | ;---------------------------------- |
1256 | ; RX irq |
Line 1256... | Line 1257... | ||
1256 | ; RX irq |
1257 | |
Line 1268... | Line 1269... | ||
1268 | mov eax, [ebx + device.cur_rx] |
1269 | mov eax, [ebx + device.cur_rx] |
1269 | mov edx, sizeof.desc |
1270 | mov edx, sizeof.desc |
1270 | mul edx |
1271 | mul edx |
1271 | lea edi, [ebx + device.rx_ring + eax] |
1272 | lea edi, [ebx + device.rx_ring + eax] |
Line 1272... | Line 1273... | ||
1272 | 1273 | ||
1273 | ; now check status |
1274 | ; Check current RX descriptor status |
Line 1274... | Line 1275... | ||
1274 | mov eax, [edi + desc.status] |
1275 | mov eax, [edi + desc.status] |
1275 | 1276 | ||
1276 | test eax, DES0_OWN |
1277 | test eax, DES0_OWN |
Line 1280... | Line 1281... | ||
1280 | test eax, RDES0_LS ; if not last desc of packet, error for now |
1281 | test eax, RDES0_LS ; if not last desc of packet, error for now |
1281 | jz .end_rx |
1282 | jz .end_rx |
1282 | test eax, RDES0_ES |
1283 | test eax, RDES0_ES |
1283 | jnz .end_rx |
1284 | jnz .end_rx |
Line 1284... | Line 1285... | ||
1284 | 1285 | ||
1285 | mov esi, [edi + RX_RING_SIZE*sizeof.desc] |
1286 | ; Calculate length |
1286 | mov ecx, [edi + desc.status] |
1287 | mov ecx, [edi + desc.status] |
1287 | shr ecx, RDES0_FL_SH |
1288 | shr ecx, RDES0_FL_SH |
1288 | and ecx, RDES0_FL_MASK |
1289 | and ecx, RDES0_FL_MASK |
1289 | sub ecx, 4 ; crc, we dont need it |
- | |
1290 | 1290 | sub ecx, 4 ; throw away the CRC |
|
1291 | DEBUGF 1,"size=%u, addr:0x%x\n", ecx, esi |
- | |
1292 | - | ||
1293 | push esi edi ecx |
- | |
1294 | invoke KernelAlloc, ecx ; Allocate a buffer to put packet into |
- | |
1295 | pop ecx edi esi |
- | |
1296 | test eax, eax |
- | |
Line -... | Line 1291... | ||
- | 1291 | DEBUGF 1,"got %u bytes\n", ecx |
|
1297 | jz .fail |
1292 | |
1298 | 1293 | ; Push arguments for Eth_input (and some more...) |
|
1299 | push ebx |
1294 | push ebx |
1300 | push dword .rx_loop |
1295 | push .rx_loop ; return addr |
Line 1301... | Line 1296... | ||
1301 | push ecx eax |
1296 | push ecx ; packet size |
1302 | xchg edi, eax |
1297 | push dword[edi + RX_RING_SIZE*sizeof.desc] ; packet ptr |
1303 | 1298 | ||
1304 | ; update statistics |
1299 | ; update statistics |
Line 1305... | Line 1300... | ||
1305 | inc [ebx + device.packets_rx] |
1300 | inc [ebx + device.packets_rx] |
1306 | add dword[ebx + device.bytes_rx], ecx |
1301 | add dword[ebx + device.bytes_rx], ecx |
1307 | adc dword[ebx + device.bytes_rx + 4], 0 |
1302 | adc dword[ebx + device.bytes_rx + 4], 0 |
1308 | - | ||
1309 | ; copy packet data |
- | |
1310 | shr cx, 1 |
1303 | |
1311 | jnc .nb |
1304 | ; Allocate new descriptor |
1312 | movsb |
1305 | push edi ebx |
1313 | .nb: |
- | |
1314 | shr cx, 1 |
1306 | invoke KernelAlloc, 1536 ; Allocate a buffer to put packet into |
1315 | jnc .nw |
- | |
1316 | movsw |
1307 | pop ebx edi |
Line -... | Line 1308... | ||
- | 1308 | mov [edi + RX_RING_SIZE*sizeof.desc], eax |
|
1317 | .nw: |
1309 | invoke GetPhysAddr |
1318 | rep movsd |
1310 | mov [edi + desc.buffer1], eax |
Line 1319... | Line 1311... | ||
1319 | 1311 | mov [edi + desc.status], DES0_OWN ; mark descriptor as being free |
|
1320 | mov [eax + desc.status], DES0_OWN ; free descriptor |
- | |
1321 | 1312 | ||
1322 | inc [ebx + device.cur_rx] ; next descriptor |
- | |
1323 | and [ebx + device.cur_rx], RX_RING_SIZE-1 |
- | |
1324 | 1313 | ; Move to next rx desc |
|
Line 1325... | Line 1314... | ||
1325 | jmp [Eth_input] |
1314 | inc [ebx + device.cur_rx] ; next descriptor |
1326 | 1315 | and [ebx + device.cur_rx], RX_RING_SIZE-1 |