Rev 5363 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5363 | Rev 5522 | ||
---|---|---|---|
Line 663... | Line 663... | ||
663 | 663 | ||
664 | 664 | ||
665 | ;*************************************************************************** |
665 | ;*************************************************************************** |
666 | ; Function |
666 | ; Function |
667 | ; transmit |
667 | ; transmit |
Line 668... | Line 668... | ||
668 | ; buffer in [esp+4], size in [esp+8], pointer to device struct in ebx |
668 | ; buffer in [esp+4], pointer to device struct in ebx |
Line 669... | Line 669... | ||
669 | ;*************************************************************************** |
669 | ;*************************************************************************** |
670 | 670 | ||
Line 671... | Line 671... | ||
671 | proc transmit stdcall buffer_ptr, buffer_size |
671 | proc transmit stdcall buffer_ptr |
672 | 672 | ||
673 | pushf |
673 | pushf |
- | 674 | cli |
|
674 | cli |
675 | |
675 | 676 | mov esi, [buffer_ptr] |
|
Line 676... | Line 677... | ||
676 | mov esi, [buffer_ptr] |
677 | mov ecx, [esi + NET_BUFF.length] |
677 | mov ecx, [buffer_size] |
678 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", esi, ecx |
678 | DEBUGF 1, "Transmitting packet, buffer:%x, size:%u\n", esi, ecx |
679 | lea eax, [esi + NET_BUFF.data] |
679 | DEBUGF 1, "To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
680 | DEBUGF 1, "To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
Line 680... | Line 681... | ||
680 | [esi+0]:2,[esi+1]:2,[esi+2]:2,[esi+3]:2,[esi+4]:2,[esi+5]:2,[esi+6]:2,[esi+7]:2,[esi+8]:2,[esi+9]:2,[esi+10]:2,[esi+11]:2,[esi+13]:2,[esi+12]:2 |
681 | [esi+0]:2,[esi+1]:2,[esi+2]:2,[esi+3]:2,[esi+4]:2,[esi+5]:2,[esi+6]:2,[esi+7]:2,[esi+8]:2,[esi+9]:2,[esi+10]:2,[esi+11]:2,[esi+13]:2,[esi+12]:2 |
681 | 682 | ||
- | 683 | cmp ecx, ETH_FRAME_LEN |
|
682 | cmp ecx, ETH_FRAME_LEN |
684 | ja .err ; packet is too long |
683 | ja .err ; packet is too long |
685 | cmp ecx, ETH_ZLEN |
684 | cmp ecx, ETH_ZLEN |
686 | jb .err ; packet is too short |
Line 685... | Line 687... | ||
685 | jb .err ; packet is too short |
687 | |
686 | 688 | movzx edi, [ebx + device.tx_start] |
|
687 | movzx edi, [ebx + device.tx_start] |
689 | shl edi, 8 |
688 | shl edi, 8 |
690 | add esi, [esi + NET_BUFF.offset] |
Line 712... | Line 714... | ||
712 | out dx, al |
714 | out dx, al |
Line 713... | Line 715... | ||
713 | 715 | ||
Line 714... | Line 716... | ||
714 | DEBUGF 1, "Packet Sent!\n" |
716 | DEBUGF 1, "Packet Sent!\n" |
715 | - | ||
716 | inc [ebx + device.packets_tx] |
717 | |
717 | mov eax, [buffer_size] |
718 | inc [ebx + device.packets_tx] |
Line 718... | Line 719... | ||
718 | add dword[ebx + device.bytes_tx], eax |
719 | add dword[ebx + device.bytes_tx], ecx |
719 | adc dword[ebx + device.bytes_tx + 4], 0 |
720 | adc dword[ebx + device.bytes_tx + 4], 0 |
720 | 721 | ||
721 | invoke KernelFree, [buffer_ptr] |
722 | invoke NetFree, [buffer_ptr] |
Line 722... | Line 723... | ||
722 | popf |
723 | popf |
723 | xor eax, eax |
724 | xor eax, eax |
724 | ret |
725 | ret |
725 | 726 | ||
726 | .err: |
727 | .err: |
727 | DEBUGF 2, "Transmit error!\n" |
728 | DEBUGF 2, "Transmit error!\n" |
Line 728... | Line 729... | ||
728 | invoke KernelFree, [buffer_ptr] |
729 | invoke NetFree, [buffer_ptr] |
Line 783... | Line 784... | ||
783 | jz .no_rx |
784 | jz .no_rx |
784 | test [ebx + device.flags], FLAG_PIO |
785 | test [ebx + device.flags], FLAG_PIO |
785 | jz .no_rx ; FIXME: Only PIO mode supported for now |
786 | jz .no_rx ; FIXME: Only PIO mode supported for now |
Line 786... | Line 787... | ||
786 | 787 | ||
787 | ; allocate a buffer |
788 | ; allocate a buffer |
788 | invoke KernelAlloc, ETH_FRAME_LEN |
789 | invoke NetAlloc, ETH_FRAME_LEN+NET_BUFF.data |
789 | test eax, eax |
790 | test eax, eax |
Line 790... | Line 791... | ||
790 | jz .rx_fail_2 |
791 | jz .rx_fail_2 |
791 | 792 | ||
792 | ; Push return address and packet ptr to stack |
- | |
793 | pushd .no_rx |
793 | ; Push return address and packet ptr to stack |
- | 794 | pushd .no_rx |
|
- | 795 | push eax |
|
Line 794... | Line 796... | ||
794 | pushd 0 ; Reserve some space for the packet size |
796 | mov [eax + NET_BUFF.device], ebx |
795 | push eax |
797 | mov [eax + NET_BUFF.offset], NET_BUFF.data |
796 | 798 | ||
797 | ; read offset for current packet from device |
799 | ; read offset for current packet from device |
Line 824... | Line 826... | ||
824 | cmp cl, ch |
826 | cmp cl, ch |
825 | je .rx_fail |
827 | je .rx_fail |
826 | movzx esi, ch ; we are using 256 byte pages |
828 | movzx esi, ch ; we are using 256 byte pages |
827 | shl esi, 8 ; esi now holds the offset for current packet |
829 | shl esi, 8 ; esi now holds the offset for current packet |
Line 828... | Line 830... | ||
828 | 830 | ||
829 | ; Get packet header in ecx |
831 | ; Write packet header to frame header size field |
830 | push ecx ; reserve 4 bytes on stack to put packet header in |
832 | push ecx |
831 | mov edi, esp |
833 | mov edi, esp |
832 | mov cx, 4 |
834 | mov cx, 4 |
833 | call PIO_read |
835 | call PIO_read |
Line 838... | Line 840... | ||
838 | jz .rx_fail_3 |
840 | jz .rx_fail_3 |
Line 839... | Line 841... | ||
839 | 841 | ||
840 | ; calculate packet length in ecx |
842 | ; calculate packet length in ecx |
841 | shr ecx, 16 |
843 | shr ecx, 16 |
842 | sub ecx, 4 ; CRC doesnt count as data byte |
844 | sub ecx, 4 ; CRC doesnt count as data byte |
- | 845 | mov edi, [esp+4] |
|
Line 843... | Line 846... | ||
843 | mov [esp + 8], ecx |
846 | mov [edi + NET_BUFF.length], ecx |
844 | 847 | ||
845 | ; check if packet size is ok |
848 | ; check if packet size is ok |
846 | cmp ecx, ETH_ZLEN |
849 | cmp ecx, ETH_ZLEN |
Line 854... | Line 857... | ||
854 | adc dword[ebx + device.bytes_rx + 4], 0 |
857 | adc dword[ebx + device.bytes_rx + 4], 0 |
855 | inc [ebx + device.packets_rx] |
858 | inc [ebx + device.packets_rx] |
Line 856... | Line 859... | ||
856 | 859 | ||
857 | ; update read and write pointers |
860 | ; update read and write pointers |
858 | add esi, 4 |
861 | add esi, 4 |
Line 859... | Line 862... | ||
859 | mov edi, [esp + 4] |
862 | add edi, NET_BUFF.data |
860 | 863 | ||
861 | ; now check if we can read all data at once (if we cross the end boundary, we need to wrap back to the beginning) |
864 | ; now check if we can read all data at once (if we cross the end boundary, we need to wrap back to the beginning) |
862 | xor eax, eax |
865 | xor eax, eax |
Line 892... | Line 895... | ||
892 | set_io [ebx + device.io_addr], P0_BOUND |
895 | set_io [ebx + device.io_addr], P0_BOUND |
893 | dec al |
896 | dec al |
894 | out dx, al |
897 | out dx, al |
Line 895... | Line 898... | ||
895 | 898 | ||
896 | ; now send the data to the kernel |
899 | ; now send the data to the kernel |
Line 897... | Line 900... | ||
897 | jmp [Eth_input] |
900 | jmp [EthInput] |
898 | 901 | ||
899 | .rx_fail_3: |
902 | .rx_fail_3: |
900 | add esp, 4 |
903 | add esp, 4 |