Rev 5363 | Rev 6229 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5363 | Rev 5522 | ||
---|---|---|---|
Line 402... | Line 402... | ||
402 | ; - Remove device from local list (RTL8139_LIST) |
402 | ; - Remove device from local list (RTL8139_LIST) |
403 | ; - call unregister function in kernel |
403 | ; - call unregister function in kernel |
404 | ; - Remove all allocated structures and buffers the card used |
404 | ; - Remove all allocated structures and buffers the card used |
Line 405... | Line 405... | ||
405 | 405 | ||
406 | or eax, -1 |
- | |
407 | 406 | or eax, -1 |
|
Line 408... | Line 407... | ||
408 | ret |
407 | ret |
409 | 408 | ||
Line 626... | Line 625... | ||
626 | 625 | ||
627 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
626 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
628 | ;; ;; |
627 | ;; ;; |
629 | ;; Transmit ;; |
628 | ;; Transmit ;; |
630 | ;; ;; |
- | |
631 | ;; In: buffer pointer in [esp+4] ;; |
- | |
632 | ;; size of buffer in [esp+8] ;; |
629 | ;; ;; |
633 | ;; pointer to device structure in ebx ;; |
630 | ;; In: pointer to device structure in ebx ;; |
634 | ;; ;; |
631 | ;; ;; |
Line 635... | Line 632... | ||
635 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
632 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 636... | Line 633... | ||
636 | 633 | ||
637 | proc transmit stdcall bufferptr, buffersize |
634 | proc transmit stdcall bufferptr |
Line -... | Line 635... | ||
- | 635 | ||
638 | 636 | pushf |
|
639 | pushf |
637 | cli |
640 | cli |
638 | |
641 | 639 | mov esi, [bufferptr] |
|
642 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize] |
640 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length] |
643 | mov eax, [bufferptr] |
641 | lea eax, [esi + NET_BUFF.data] |
Line 644... | Line 642... | ||
644 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
642 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
645 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
643 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
646 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
644 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
647 | [eax+13]:2,[eax+12]:2 |
645 | [eax+13]:2,[eax+12]:2 |
Line 648... | Line 646... | ||
648 | 646 | ||
649 | cmp [buffersize], 1514 |
647 | cmp [esi + NET_BUFF.length], 1514 |
650 | ja .fail |
648 | ja .fail |
Line 660... | Line 658... | ||
660 | in eax, dx |
658 | in eax, dx |
661 | test eax, (1 shl BIT_OWN) |
659 | test eax, (1 shl BIT_OWN) |
662 | jz .wait_to_send |
660 | jz .wait_to_send |
Line 663... | Line 661... | ||
663 | 661 | ||
664 | .send_packet: |
- | |
665 | ; get next descriptor |
- | |
666 | inc [ebx + device.curr_tx_desc] |
- | |
667 | and [ebx + device.curr_tx_desc], NUM_TX_DESC-1 |
- | |
668 | - | ||
669 | ; Update stats |
- | |
670 | inc [ebx + device.packets_tx] |
- | |
671 | mov eax, [buffersize] |
- | |
672 | add dword [ebx + device.bytes_tx], eax |
- | |
673 | adc dword [ebx + device.bytes_tx+4], 0 |
- | |
674 | 662 | .send_packet: |
|
675 | ; Set the buffer address |
663 | ; Set the buffer address |
- | 664 | set_io [ebx + device.io_addr], REG_TSAD0 |
|
676 | set_io [ebx + device.io_addr], REG_TSAD0 |
665 | mov [ebx + device.TX_DESC+ecx], esi |
677 | mov eax, [bufferptr] |
666 | mov eax, esi |
678 | mov [ebx + device.TX_DESC+ecx], eax |
667 | add eax, [eax + NET_BUFF.offset] |
679 | invoke GetPhysAddr |
668 | invoke GetPhysAddr |
Line 680... | Line 669... | ||
680 | out dx, eax |
669 | out dx, eax |
681 | 670 | ||
682 | ; And the size of the buffer |
671 | ; And the size of the buffer |
683 | set_io [ebx + device.io_addr], REG_TSD0 |
672 | set_io [ebx + device.io_addr], REG_TSD0 |
684 | mov eax, [buffersize] |
673 | mov eax, [esi + NET_BUFF.length] |
Line -... | Line 674... | ||
- | 674 | or eax, (ERTXTH shl BIT_ERTXTH) ; Early threshold |
|
- | 675 | out dx, eax |
|
- | 676 | ||
- | 677 | ; get next descriptor |
|
- | 678 | inc [ebx + device.curr_tx_desc] |
|
- | 679 | and [ebx + device.curr_tx_desc], NUM_TX_DESC-1 |
|
- | 680 | ||
- | 681 | ; Update stats |
|
- | 682 | inc [ebx + device.packets_tx] |
|
- | 683 | mov ecx, [esi + NET_BUFF.length] |
|
685 | or eax, (ERTXTH shl BIT_ERTXTH) ; Early threshold |
684 | add dword [ebx + device.bytes_tx], ecx |
686 | out dx, eax |
685 | adc dword [ebx + device.bytes_tx+4], 0 |
687 | 686 | ||
688 | DEBUGF 1, "Packet Sent!\n" |
687 | DEBUGF 1, "Packet Sent!\n" |
Line 708... | Line 707... | ||
708 | 707 | ||
Line 709... | Line 708... | ||
709 | jmp .send_packet |
708 | jmp .send_packet |
710 | 709 | ||
711 | .fail: |
710 | .fail: |
712 | DEBUGF 2, "transmit failed!\n" |
711 | DEBUGF 2, "transmit failed!\n" |
713 | invoke KernelFree, [bufferptr] |
712 | invoke NetFree, [bufferptr] |
714 | popf |
713 | popf |
Line 715... | Line 714... | ||
715 | or eax, -1 |
714 | or eax, -1 |
Line 793... | Line 792... | ||
793 | inc [ebx + device.packets_rx] |
792 | inc [ebx + device.packets_rx] |
Line 794... | Line 793... | ||
794 | 793 | ||
Line 795... | Line 794... | ||
795 | DEBUGF 1, "Received %u bytes\n", ecx |
794 | DEBUGF 1, "Received %u bytes\n", ecx |
- | 795 | ||
796 | 796 | push ebx eax ecx |
|
797 | push ebx eax ecx |
797 | add ecx, NET_BUFF.data |
798 | invoke KernelAlloc, ecx ; Allocate a buffer to put packet into |
798 | invoke NetAlloc, ecx ; Allocate a buffer to put packet into |
799 | pop ecx |
799 | pop ecx |
- | 800 | test eax, eax ; Test if we allocated succesfully |
|
- | 801 | jz .abort |
|
- | 802 | mov [eax + NET_BUFF.length], ecx |
|
Line 800... | Line 803... | ||
800 | test eax, eax ; Test if we allocated succesfully |
803 | mov [eax + NET_BUFF.device], ebx |
801 | jz .abort |
- | |
802 | 804 | mov [eax + NET_BUFF.offset], NET_BUFF.data |
|
803 | mov edi, eax ; Where we will copy too |
805 | |
Line 804... | Line 806... | ||
804 | 806 | lea edi, [eax + NET_BUFF.data] ; Where we will copy too |
|
805 | mov esi, [esp] ; The buffer we will copy from |
807 | mov esi, [esp] ; The buffer we will copy from |
Line 806... | Line 808... | ||
806 | add esi, 4 ; Dont copy CRC |
808 | add esi, 4 ; Dont copy CRC |
807 | 809 | ||
808 | push dword .abort ; Kernel will return to this address after EthReceiver |
810 | push .abort ; return addr for Eth_input |
809 | push ecx edi ; Save buffer pointer and size, to pass to kernel |
811 | push eax ; buffer ptr for Eth_input |
Line 819... | Line 821... | ||
819 | .nw: |
821 | .nw: |
820 | jz .nd |
822 | jz .nd |
821 | rep movsd |
823 | rep movsd |
822 | .nd: |
824 | .nd: |
Line 823... | Line 825... | ||
823 | 825 | ||
Line 824... | Line 826... | ||
824 | jmp [Eth_input] ; Send it to kernel |
826 | jmp [EthInput] ; Send it to kernel |
825 | 827 | ||
826 | .abort: |
828 | .abort: |
827 | pop eax ebx |
829 | pop eax ebx |
Line 921... | Line 923... | ||
921 | DEBUGF 1, "TX: Transmit OK!\n" |
923 | DEBUGF 1, "TX: Transmit OK!\n" |
Line 922... | Line 924... | ||
922 | 924 | ||
923 | .no_tok: |
925 | .no_tok: |
924 | DEBUGF 1, "free transmit buffer 0x%x\n", [ebx + device.TX_DESC+ecx]:8 |
926 | DEBUGF 1, "free transmit buffer 0x%x\n", [ebx + device.TX_DESC+ecx]:8 |
925 | push ecx ebx |
927 | push ecx ebx |
926 | invoke KernelFree, [ebx + device.TX_DESC+ecx] |
928 | invoke NetFree, [ebx + device.TX_DESC+ecx] |
927 | pop ebx ecx |
929 | pop ebx ecx |
Line 928... | Line 930... | ||
928 | mov [ebx + device.TX_DESC+ecx], 0 |
930 | mov [ebx + device.TX_DESC+ecx], 0 |
929 | 931 |