Rev 5363 | Rev 8897 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5363 | Rev 5522 | ||
---|---|---|---|
Line 489... | Line 489... | ||
489 | 489 | ||
Line 490... | Line 490... | ||
490 | ; If an error occured, remove all allocated data and exit (returning -1 in eax) |
490 | ; If an error occured, remove all allocated data and exit (returning -1 in eax) |
491 | 491 | ||
492 | .destroy: |
- | |
- | 492 | .destroy: |
|
493 | ; todo: reset device into virgin state |
493 | ; todo: reset device into virgin state |
494 | 494 | add eax, NET_BUFF.data |
|
495 | dec [devices] |
495 | dec [devices] |
496 | .err: |
496 | .err: |
Line 520... | Line 520... | ||
520 | ; - Remove device from local list (device_list) |
520 | ; - Remove device from local list (device_list) |
521 | ; - call unregister function in kernel |
521 | ; - call unregister function in kernel |
522 | ; - Remove all allocated structures and buffers the card used |
522 | ; - Remove all allocated structures and buffers the card used |
Line 523... | Line 523... | ||
523 | 523 | ||
524 | or eax,-1 |
- | |
525 | 524 | or eax, -1 |
|
Line 526... | Line 525... | ||
526 | ret |
525 | ret |
527 | 526 | ||
Line 866... | Line 865... | ||
866 | lea edi, [ebx + device.phys_addr] |
865 | lea edi, [ebx + device.phys_addr] |
867 | movsd |
866 | movsd |
868 | movsw |
867 | movsw |
Line 869... | Line 868... | ||
869 | 868 | ||
- | 869 | call init_ring |
|
- | 870 | test eax, eax |
|
Line 870... | Line 871... | ||
870 | call init_ring |
871 | jnz .fail |
Line 871... | Line 872... | ||
871 | 872 | ||
872 | mov edx, [ebx + device.io_addr] ; init ring destroys edx |
873 | mov edx, [ebx + device.io_addr] ; init ring destroys edx |
Line 921... | Line 922... | ||
921 | 922 | ||
Line 922... | Line 923... | ||
922 | call check_media |
923 | call check_media |
923 | 924 | ||
- | 925 | DEBUGF 1,"reset complete\n" |
|
924 | DEBUGF 1,"reset complete\n" |
926 | xor eax, eax |
Line 925... | Line 927... | ||
925 | xor eax, eax |
927 | .fail: |
926 | ret |
928 | ret |
Line 936... | Line 938... | ||
936 | invoke GetPhysAddr |
938 | invoke GetPhysAddr |
937 | mov [ebx + device.rx_ring_phys], eax |
939 | mov [ebx + device.rx_ring_phys], eax |
938 | mov ecx, RX_RING_SIZE |
940 | mov ecx, RX_RING_SIZE |
939 | .rx_init: |
941 | .rx_init: |
940 | push ecx |
942 | push ecx |
941 | invoke KernelAlloc, PKT_BUF_SZ |
943 | invoke NetAlloc, PKT_BUF_SZ+NET_BUFF.data |
942 | pop ecx |
944 | pop ecx |
- | 945 | test eax, eax |
|
- | 946 | jz .out_of_mem |
|
943 | mov [edi + descriptor.virtual], eax |
947 | mov [edi + descriptor.virtual], eax |
944 | invoke GetPhysAddr |
948 | invoke GetPhysAddr |
- | 949 | add eax, NET_BUFF.data |
|
945 | mov [edi + descriptor.base], eax |
950 | mov [edi + descriptor.base], eax |
946 | mov [edi + descriptor.length], - PKT_BUF_SZ |
951 | mov [edi + descriptor.length], - PKT_BUF_SZ |
947 | mov [edi + descriptor.status], RXSTAT_OWN |
952 | mov [edi + descriptor.status], RXSTAT_OWN |
948 | mov dword[edi + descriptor.msg_length], 0 ; also clears misc field |
953 | mov dword[edi + descriptor.msg_length], 0 ; also clears misc field |
949 | add edi, sizeof.descriptor |
954 | add edi, sizeof.descriptor |
Line 965... | Line 970... | ||
965 | 970 | ||
966 | mov [ebx + device.cur_tx], 0 |
971 | mov [ebx + device.cur_tx], 0 |
967 | mov [ebx + device.last_tx], 0 |
972 | mov [ebx + device.last_tx], 0 |
Line -... | Line 973... | ||
- | 973 | mov [ebx + device.cur_rx], 0 |
|
- | 974 | ||
- | 975 | xor eax, eax |
|
- | 976 | ret |
|
- | 977 | ||
- | 978 | .out_of_mem: |
|
- | 979 | DEBUGF 2,"Out of memory!\n" |
|
968 | mov [ebx + device.cur_rx], 0 |
980 | |
Line 978... | Line 990... | ||
978 | ;; ;; |
990 | ;; ;; |
979 | ;; In: pointer to device structure in ebx ;; |
991 | ;; In: pointer to device structure in ebx ;; |
980 | ;; ;; |
992 | ;; ;; |
981 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
993 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 982... | Line 994... | ||
982 | 994 | ||
Line 983... | Line 995... | ||
983 | proc transmit stdcall bufferptr, buffersize |
995 | proc transmit stdcall bufferptr |
984 | 996 | ||
Line -... | Line 997... | ||
- | 997 | pushf |
|
985 | pushf |
998 | cli |
986 | cli |
999 | |
987 | 1000 | mov esi, [bufferptr] |
|
988 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize] |
1001 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length] |
989 | mov eax, [bufferptr] |
1002 | lea eax, [esi + NET_BUFF.data] |
990 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
1003 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
Line 991... | Line 1004... | ||
991 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
1004 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
992 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
1005 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
993 | [eax+13]:2,[eax+12]:2 |
1006 | [eax+13]:2,[eax+12]:2 |
994 | 1007 | ||
Line 995... | Line 1008... | ||
995 | cmp [buffersize], 1514 |
1008 | cmp [esi + NET_BUFF.length], 1514 |
996 | ja .fail |
1009 | ja .fail |
997 | cmp [buffersize], 60 |
1010 | cmp [esi + NET_BUFF.length], 60 |
998 | jb .fail |
1011 | jb .fail |
999 | 1012 | ||
Line 1000... | Line 1013... | ||
1000 | ; check descriptor |
1013 | ; check descriptor |
1001 | lea edi, [ebx + device.tx_ring] |
1014 | lea edi, [ebx + device.tx_ring] |
1002 | movzx eax, [ebx + device.cur_tx] |
1015 | movzx ecx, [ebx + device.cur_tx] |
- | 1016 | shl ecx, 4 |
|
1003 | shl eax, 4 |
1017 | add edi, ecx |
1004 | add edi, eax |
1018 | |
1005 | 1019 | test [edi + descriptor.status], TXCTL_OWN |
|
1006 | test [edi + descriptor.status], TXCTL_OWN |
1020 | jnz .fail |
1007 | jnz .fail |
1021 | ; descriptor is free, use it |
1008 | ; descriptor is free, use it |
1022 | mov [edi + descriptor.virtual], esi |
1009 | mov eax, [bufferptr] |
1023 | mov eax, esi |
1010 | mov [edi + descriptor.virtual], eax |
1024 | add eax, [eax + NET_BUFF.offset] |
1011 | invoke GetPhysAddr |
1025 | invoke GetPhysAddr |
1012 | mov [edi + descriptor.base], eax |
1026 | mov [edi + descriptor.base], eax |
Line 1028... | Line 1042... | ||
1028 | inc [ebx + device.cur_tx] |
1042 | inc [ebx + device.cur_tx] |
1029 | and [ebx + device.cur_tx], TX_RING_SIZE - 1 |
1043 | and [ebx + device.cur_tx], TX_RING_SIZE - 1 |
Line 1030... | Line 1044... | ||
1030 | 1044 | ||
1031 | ; Update stats |
1045 | ; Update stats |
1032 | inc [ebx + device.packets_tx] |
1046 | inc [ebx + device.packets_tx] |
1033 | mov eax, [buffersize] |
1047 | mov eax, [esi + NET_BUFF.length] |
1034 | add dword[ebx + device.bytes_tx], eax |
1048 | add dword[ebx + device.bytes_tx], eax |
Line 1035... | Line 1049... | ||
1035 | adc dword[ebx + device.bytes_tx + 4], 0 |
1049 | adc dword[ebx + device.bytes_tx + 4], 0 |
1036 | 1050 | ||
1037 | .finish: |
1051 | .finish: |
1038 | popf |
1052 | popf |
Line 1039... | Line 1053... | ||
1039 | xor eax, eax |
1053 | xor eax, eax |
1040 | ret |
1054 | ret |
1041 | 1055 | ||
1042 | .fail: |
1056 | .fail: |
1043 | DEBUGF 2, "Send failed\n" |
1057 | DEBUGF 2, "Send failed\n" |
1044 | invoke KernelFree, [bufferptr] |
1058 | invoke NetFree, [bufferptr] |
Line 1045... | Line 1059... | ||
1045 | popf |
1059 | popf |
Line 1122... | Line 1136... | ||
1122 | 1136 | ||
1123 | ; Set pointers for ETH_input |
1137 | ; Set pointers for ETH_input |
Line 1124... | Line 1138... | ||
1124 | push ebx |
1138 | push ebx |
- | 1139 | ||
1125 | 1140 | push .rx_loop ; return address |
|
- | 1141 | mov eax, [edi + descriptor.virtual] |
|
- | 1142 | push eax ; packet address |
|
1126 | push .rx_loop ; return address |
1143 | mov [eax + NET_BUFF.length], ecx |
Line 1127... | Line 1144... | ||
1127 | push ecx ; packet size |
1144 | mov [eax + NET_BUFF.device], ebx |
1128 | push [edi + descriptor.virtual] ; packet address |
1145 | mov [eax + NET_BUFF.offset], NET_BUFF.data |
1129 | 1146 | ||
1130 | ; Update stats |
1147 | ; Update stats |
Line 1131... | Line 1148... | ||
1131 | add dword[ebx + device.bytes_rx], ecx |
1148 | add dword[ebx + device.bytes_rx], ecx |
1132 | adc dword[ebx + device.bytes_rx + 4], 0 |
1149 | adc dword[ebx + device.bytes_rx + 4], 0 |
- | 1150 | inc [ebx + device.packets_rx] |
|
- | 1151 | ||
1133 | inc [ebx + device.packets_rx] |
1152 | ; now allocate a new buffer |
1134 | 1153 | invoke NetAlloc, PKT_BUF_SZ+NET_BUFF.data ; Allocate a buffer for the next packet |
|
- | 1154 | test eax, eax |
|
1135 | ; now allocate a new buffer |
1155 | jz .out_of_mem |
1136 | invoke KernelAlloc, PKT_BUF_SZ ; Allocate a buffer for the next packet |
1156 | mov [edi + descriptor.virtual], eax ; set virtual address |
Line 1137... | Line 1157... | ||
1137 | mov [edi + descriptor.virtual], eax ; set virtual address |
1157 | invoke GetPhysAddr |
1138 | invoke GetPhysAddr |
1158 | add eax, NET_BUFF.data |
Line 1139... | Line 1159... | ||
1139 | mov [edi + descriptor.base], eax ; and physical address |
1159 | mov [edi + descriptor.base], eax ; and physical address |
- | 1160 | mov [edi + descriptor.status], RXSTAT_OWN ; give it back to PCnet controller |
|
- | 1161 | ||
- | 1162 | inc [ebx + device.cur_rx] ; set next receive descriptor |
|
- | 1163 | and [ebx + device.cur_rx], RX_RING_SIZE - 1 |
|
- | 1164 | ||
- | 1165 | jmp [EthInput] |
|
- | 1166 | ||
- | 1167 | .out_of_mem: |
|
Line 1140... | Line 1168... | ||
1140 | mov [edi + descriptor.status], RXSTAT_OWN ; give it back to PCnet controller |
1168 | DEBUGF 2,"Out of memory!\n" |
1141 | 1169 | ||
Line 1142... | Line 1170... | ||
1142 | inc [ebx + device.cur_rx] ; set next receive descriptor |
1170 | inc [ebx + device.cur_rx] ; set next receive descriptor |
Line 1165... | Line 1193... | ||
1165 | 1193 | ||
Line 1166... | Line 1194... | ||
1166 | mov [edi + descriptor.virtual], 0 |
1194 | mov [edi + descriptor.virtual], 0 |
Line 1167... | Line 1195... | ||
1167 | 1195 | ||
Line 1168... | Line 1196... | ||
1168 | DEBUGF 1,"Removing packet %x from memory\n", eax |
1196 | DEBUGF 1,"Removing packet %x from memory\n", eax |
1169 | 1197 | ||
1170 | invoke KernelFree, eax |
1198 | invoke NetFree, eax |