Rev 5363 | Rev 5527 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5363 | Rev 5522 | ||
---|---|---|---|
Line 470... | Line 470... | ||
470 | ; - Remove device from local list (device_list) |
470 | ; - Remove device from local list (device_list) |
471 | ; - call unregister function in kernel |
471 | ; - call unregister function in kernel |
472 | ; - Remove all allocated structures and buffers the card used |
472 | ; - Remove all allocated structures and buffers the card used |
Line 473... | Line 473... | ||
473 | 473 | ||
474 | or eax, -1 |
- | |
475 | 474 | or eax, -1 |
|
Line 476... | Line 475... | ||
476 | ret |
475 | ret |
Line 558... | Line 557... | ||
558 | init_rx: |
557 | init_rx: |
Line 559... | Line 558... | ||
559 | 558 | ||
560 | lea edi, [ebx + device.rx_desc] |
559 | lea edi, [ebx + device.rx_desc] |
561 | mov ecx, RX_RING_SIZE |
560 | mov ecx, RX_RING_SIZE |
- | 561 | .loop: |
|
562 | .loop: |
562 | push ecx |
563 | push ecx edi |
563 | push edi |
564 | invoke KernelAlloc, MAX_PKT_SIZE |
564 | invoke NetAlloc, MAX_PKT_SIZE+NET_BUFF.data |
565 | test eax, eax |
565 | test eax, eax |
566 | jz .out_of_mem |
566 | jz .out_of_mem |
567 | DEBUGF 1,"RX buffer: 0x%x\n", eax |
567 | DEBUGF 1,"RX buffer: 0x%x\n", eax |
568 | pop edi |
568 | pop edi |
569 | mov dword[edi + RX_RING_SIZE*sizeof.RDESC], eax |
569 | mov dword[edi + RX_RING_SIZE*sizeof.RDESC], eax |
570 | push edi |
570 | push edi |
571 | invoke GetPhysAddr |
571 | invoke GetPhysAddr |
- | 572 | pop edi |
|
572 | pop edi |
573 | add eax, NET_BUFF.data |
573 | mov [edi + RDESC.addr_l], eax |
574 | mov [edi + RDESC.addr_l], eax |
574 | mov [edi + RDESC.addr_h], 0 |
575 | mov [edi + RDESC.addr_h], 0 |
575 | mov [edi + RDESC.status_l], 0 |
576 | mov [edi + RDESC.status_l], 0 |
576 | mov [edi + RDESC.status_h], 0 |
577 | mov [edi + RDESC.status_h], 0 |
Line 705... | Line 706... | ||
705 | 706 | ||
706 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
707 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
707 | ;; ;; |
708 | ;; ;; |
708 | ;; Transmit ;; |
709 | ;; Transmit ;; |
709 | ;; ;; |
710 | ;; ;; |
- | 711 | ;; In: ebx = pointer to device structure ;; |
|
710 | ;; In: pointer to device structure in ebx ;; |
712 | ;; Out: eax = 0 on success ;; |
711 | ;; ;; |
713 | ;; ;; |
Line 712... | Line 714... | ||
712 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
714 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 713... | Line 715... | ||
713 | 715 | ||
714 | proc transmit stdcall bufferptr, buffersize |
716 | proc transmit stdcall bufferptr |
Line -... | Line 717... | ||
- | 717 | ||
715 | 718 | pushf |
|
716 | pushf |
719 | cli |
717 | cli |
720 | |
718 | 721 | mov esi, [bufferptr] |
|
719 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize] |
722 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length] |
720 | mov eax, [bufferptr] |
723 | lea eax, [esi + NET_BUFF.data] |
Line 721... | Line 724... | ||
721 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
724 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
722 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
725 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
723 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
726 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
724 | [eax+13]:2,[eax+12]:2 |
727 | [eax+13]:2,[eax+12]:2 |
Line 725... | Line 728... | ||
725 | 728 | ||
726 | cmp [buffersize], 1514 |
729 | cmp [esi + NET_BUFF.length], 1514 |
727 | ja .fail |
730 | ja .fail |
728 | cmp [buffersize], 60 |
731 | cmp [esi + NET_BUFF.length], 60 |
729 | jb .fail |
732 | jb .fail |
- | 733 | ||
730 | 734 | ; Program the descriptor (use legacy mode) |
|
- | 735 | mov edi, [ebx + device.cur_tx] |
|
731 | ; Program the descriptor (use legacy mode) |
736 | DEBUGF 1, "Using TX desc: %u\n", edi |
732 | mov edi, [ebx + device.cur_tx] |
737 | shl edi, 4 ; edi = edi * sizeof.TDESC |
733 | DEBUGF 1, "Using TX desc: %u\n", edi |
738 | lea edi, [ebx + device.tx_desc + edi] |
Line 734... | Line 739... | ||
734 | shl edi, 4 ; edi = edi * sizeof.TDESC |
739 | mov eax, esi |
735 | lea edi, [ebx + device.tx_desc + edi] |
740 | mov dword[edi + TX_RING_SIZE*sizeof.TDESC], eax ; Store the data location (for driver) |
736 | mov dword[edi + TX_RING_SIZE*sizeof.TDESC], eax ; Store the data location (for driver) |
741 | add eax, [eax + NET_BUFF.offset] |
737 | invoke GetPhysAddr |
742 | invoke GetPhysAddr |
Line 738... | Line 743... | ||
738 | mov [edi + TDESC.addr_l], eax ; Data location (for hardware) |
743 | mov [edi + TDESC.addr_l], eax ; Data location (for hardware) |
Line 751... | Line 756... | ||
751 | mov [ebx + device.cur_tx], eax |
756 | mov [ebx + device.cur_tx], eax |
752 | mov dword[edi + REG_TDT], eax ; TDT - Transmit Descriptor Tail |
757 | mov dword[edi + REG_TDT], eax ; TDT - Transmit Descriptor Tail |
Line 753... | Line 758... | ||
753 | 758 | ||
754 | ; Update stats |
759 | ; Update stats |
755 | inc [ebx + device.packets_tx] |
760 | inc [ebx + device.packets_tx] |
756 | mov eax, [buffersize] |
761 | mov eax, [esi + NET_BUFF.length] |
757 | add dword[ebx + device.bytes_tx], eax |
762 | add dword[ebx + device.bytes_tx], eax |
Line 758... | Line 763... | ||
758 | adc dword[ebx + device.bytes_tx + 4], 0 |
763 | adc dword[ebx + device.bytes_tx + 4], 0 |
Line 765... | Line 770... | ||
765 | 770 | ||
766 | .fail: |
771 | .fail: |
Line 767... | Line 772... | ||
767 | call clean_tx |
772 | call clean_tx |
768 | 773 | ||
769 | DEBUGF 2,"Send failed\n" |
774 | DEBUGF 2,"Send failed\n" |
770 | invoke KernelFree, [bufferptr] |
775 | invoke NetFree, [bufferptr] |
771 | popf |
776 | popf |
Line 772... | Line 777... | ||
772 | or eax, -1 |
777 | or eax, -1 |
Line 831... | Line 836... | ||
831 | 836 | ||
832 | push eax ebx |
837 | push eax ebx |
833 | push .retaddr |
838 | push .retaddr |
834 | movzx ecx, word[esi + 8] ; Get the packet length |
839 | movzx ecx, word[esi + 8] ; Get the packet length |
- | 840 | DEBUGF 1,"got %u bytes\n", ecx |
|
835 | DEBUGF 1,"got %u bytes\n", ecx |
841 | mov eax, [esi + RX_RING_SIZE*sizeof.RDESC] ; Get packet pointer |
- | 842 | push eax |
|
- | 843 | mov [eax + NET_BUFF.length], ecx |
|
836 | push ecx |
844 | mov [eax + NET_BUFF.device], ebx |
Line 837... | Line 845... | ||
837 | push dword[esi + RX_RING_SIZE*sizeof.RDESC] ; Get packet pointer |
845 | mov [eax + NET_BUFF.offset], NET_BUFF.data |
838 | 846 | ||
839 | ; Update stats |
847 | ; Update stats |
840 | add dword[ebx + device.bytes_rx], ecx |
848 | add dword[ebx + device.bytes_rx], ecx |
Line 841... | Line 849... | ||
841 | adc dword[ebx + device.bytes_rx + 4], 0 |
849 | adc dword[ebx + device.bytes_rx + 4], 0 |
842 | inc [ebx + device.packets_rx] |
850 | inc [ebx + device.packets_rx] |
843 | 851 | ||
844 | ; Allocate new descriptor |
852 | ; Allocate new descriptor |
845 | push esi |
853 | push esi |
846 | invoke KernelAlloc, MAX_PKT_SIZE |
854 | invoke NetAlloc, MAX_PKT_SIZE+NET_BUFF.data |
847 | pop esi |
855 | pop esi |
848 | test eax, eax |
856 | test eax, eax |
- | 857 | jz .out_of_mem |
|
849 | jz .out_of_mem |
858 | mov dword[esi + RX_RING_SIZE*sizeof.RDESC], eax |
850 | mov dword[esi + RX_RING_SIZE*sizeof.RDESC], eax |
859 | invoke GetPhysAddr |
851 | invoke GetPhysAddr |
860 | add eax, NET_BUFF.data |
Line 852... | Line 861... | ||
852 | mov [esi + RDESC.addr_l], eax |
861 | mov [esi + RDESC.addr_l], eax |
Line 860... | Line 869... | ||
860 | 869 | ||
861 | ; Move to next rx desc |
870 | ; Move to next rx desc |
862 | inc [ebx + device.cur_rx] |
871 | inc [ebx + device.cur_rx] |
Line 863... | Line 872... | ||
863 | and [ebx + device.cur_rx], RX_RING_SIZE-1 |
872 | and [ebx + device.cur_rx], RX_RING_SIZE-1 |
Line 864... | Line 873... | ||
864 | 873 | ||
865 | jmp [Eth_input] |
874 | jmp [EthInput] |
Line 866... | Line 875... | ||
866 | 875 | ||
867 | .out_of_mem: |
876 | .out_of_mem: |
868 | DEBUGF 2,"Out of memory!\n" |
877 | DEBUGF 2,"Out of memory!\n" |
Line 869... | Line 878... | ||
869 | 878 | ||
870 | ; Move to next rx desc |
879 | ; Move to next rx desc |
Line 871... | Line 880... | ||
871 | inc [ebx + device.cur_rx] |
880 | inc [ebx + device.cur_rx] |
872 | and [ebx + device.cur_rx], RX_RING_SIZE-1 |
881 | and [ebx + device.cur_rx], RX_RING_SIZE-1 |
Line 916... | Line 925... | ||
916 | DEBUGF 1,"Cleaning up TX desc: 0x%x\n", edi |
925 | DEBUGF 1,"Cleaning up TX desc: 0x%x\n", edi |
Line 917... | Line 926... | ||
917 | 926 | ||
918 | push ebx |
927 | push ebx |
919 | push dword[edi + TX_RING_SIZE*sizeof.TDESC] |
928 | push dword[edi + TX_RING_SIZE*sizeof.TDESC] |
920 | mov dword[edi + TX_RING_SIZE*sizeof.TDESC], 0 |
929 | mov dword[edi + TX_RING_SIZE*sizeof.TDESC], 0 |
921 | invoke KernelFree |
930 | invoke NetFree |
Line 922... | Line 931... | ||
922 | pop ebx |
931 | pop ebx |
923 | 932 | ||
924 | inc [ebx + device.last_tx] |
933 | inc [ebx + device.last_tx] |