Rev 4470 | Rev 4580 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4470 | Rev 4576 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | 23 | ||
24 | DEBUG = 1 |
24 | DEBUG = 1 |
25 | __DEBUG__ = 1 |
25 | __DEBUG__ = 1 |
Line 26... | Line 26... | ||
26 | __DEBUG_LEVEL__ = 2 |
26 | __DEBUG_LEVEL__ = 2 |
27 | 27 | ||
Line 28... | Line 28... | ||
28 | NUM_TX_DESC = 4 |
28 | NUM_TX_DESC = 6 |
29 | NUM_RX_DESC = 4 |
29 | NUM_RX_DESC = 12 |
30 | 30 | ||
31 | include '../struct.inc' |
31 | include '../struct.inc' |
Line 644... | Line 644... | ||
644 | DEBUGF 1,"Attaching int handler to irq %x\n", eax:1 |
644 | DEBUGF 1,"Attaching int handler to irq %x\n", eax:1 |
645 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
645 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
646 | test eax, eax |
646 | test eax, eax |
647 | jnz @f |
647 | jnz @f |
648 | DEBUGF 1,"Could not attach int handler!\n" |
648 | DEBUGF 1,"Could not attach int handler!\n" |
649 | ; or eax, -1 |
649 | or eax, -1 |
650 | ; ret |
650 | ret |
651 | @@: |
651 | @@: |
Line 652... | Line 652... | ||
652 | 652 | ||
Line 653... | Line 653... | ||
653 | ; Reset the chip to erase previous misconfiguration. |
653 | ; Reset the chip to erase previous misconfiguration. |
Line 661... | Line 661... | ||
661 | call init_ring |
661 | call init_ring |
Line 662... | Line 662... | ||
662 | 662 | ||
663 | ; Initialize other registers. |
663 | ; Initialize other registers. |
Line 664... | Line 664... | ||
664 | ; Configure the PCI bus bursts and FIFO thresholds. |
664 | ; Configure the PCI bus bursts and FIFO thresholds. |
665 | 665 | ||
Line 666... | Line 666... | ||
666 | mov [device.bcrvalue], 0x10 ; little-endian, 8 burst length |
666 | mov [device.bcrvalue], 0x10 ; little-endian, 8 burst length |
667 | mov [device.crvalue], 0xa00 ; 128 burst length |
667 | mov [device.crvalue], 0xa00 ; 128 burst length |
668 | 668 | ||
669 | cmp [device.dev_id], 0x891 |
669 | cmp [device.dev_id], 0x891 |
Line 697... | Line 697... | ||
697 | 697 | ||
Line 698... | Line 698... | ||
698 | ; Enable interrupts |
698 | ; Enable interrupts |
699 | 699 | ||
700 | set_io 0 |
700 | set_io 0 |
701 | set_io ISR |
701 | set_io ISR |
702 | mov eax, (FBE or TUNF or CNTOVF or RBU or TI or RI) |
- | |
703 | out dx, eax |
702 | mov eax, FBE or TUNF or CNTOVF or RBU or TI or RI |
704 | - | ||
705 | set_io IMR |
703 | out dx, eax |
Line 706... | Line 704... | ||
706 | ; mov eax, (FBE or TUNF or CNTOVF or RBU or TI or RI) |
704 | set_io IMR |
Line 707... | Line 705... | ||
707 | out dx, eax |
705 | out dx, eax |
Line 780... | Line 778... | ||
780 | mov [esi + mtd_desc.next_desc_logical], eax |
778 | mov [esi + mtd_desc.next_desc_logical], eax |
781 | push ecx esi |
779 | push ecx esi |
782 | GetRealAddr |
780 | GetRealAddr |
783 | pop esi ecx |
781 | pop esi ecx |
784 | mov [esi + mtd_desc.next_desc], eax |
782 | mov [esi + mtd_desc.next_desc], eax |
785 | - | ||
- | 783 | mov [esi + mtd_desc.skbuff], 0 |
|
786 | add esi, mtd_desc.size |
784 | add esi, mtd_desc.size |
787 | loop .tx_desc_loop |
785 | loop .tx_desc_loop |
Line 788... | Line 786... | ||
788 | 786 | ||
Line 1013... | Line 1011... | ||
1013 | 1011 | ||
1014 | cmp dword [esp+8], 1514 |
1012 | cmp dword [esp+8], 1514 |
Line 1015... | Line 1013... | ||
1015 | ja .fail |
1013 | ja .fail |
- | 1014 | ||
- | 1015 | mov esi, [device.cur_tx] |
|
- | 1016 | ||
- | 1017 | test [esi + mtd_desc.status], TXOWN |
|
1016 | 1018 | jnz .fail |
|
1017 | mov esi, [device.cur_tx] |
1019 | |
Line 1018... | Line -... | ||
1018 | push [esi + mtd_desc.next_desc_logical] |
- | |
1019 | pop [device.cur_tx] |
- | |
1020 | 1020 | push [esi + mtd_desc.next_desc_logical] |
|
1021 | ; todo: check if descriptor is not owned by the device! |
1021 | pop [device.cur_tx] |
1022 | 1022 | ||
1023 | mov eax, [esp + 4] |
1023 | mov eax, [esp + 4] |
Line 1024... | Line 1024... | ||
1024 | mov [esi + mtd_desc.skbuff], eax |
1024 | mov [esi + mtd_desc.skbuff], eax |
- | 1025 | GetRealAddr |
|
1025 | GetRealAddr |
1026 | mov [esi + mtd_desc.buffer], eax |
- | 1027 | ||
- | 1028 | mov eax, [esp + 8] |
|
1026 | mov [esi + mtd_desc.buffer], eax |
1029 | mov ecx, eax |
1027 | 1030 | shl eax, PKTSShift ; packet size |
|
1028 | mov eax, [esp + 8] |
- | |
1029 | shl eax, PKTSShift ; packet size |
1031 | shl ecx, TBSShift |
Line 1030... | Line -... | ||
1030 | or eax, TXLD + TXFD + CRCEnable + PADEnable + TXIC + 1536 shl TBSShift ; buffer size |
- | |
1031 | mov [esi + mtd_desc.control], eax |
1032 | or eax, ecx |
1032 | - | ||
1033 | mov [esi + mtd_desc.status], TXOWN |
1033 | or eax, TXIC + TXLD + TXFD + CRCEnable + PADEnable |
1034 | 1034 | mov [esi + mtd_desc.control], eax |
|
1035 | ;------------- |
1035 | mov [esi + mtd_desc.status], TXOWN |
1036 | ; Update stats |
1036 | |
Line 1037... | Line 1037... | ||
1037 | 1037 | ; Update stats |
|
1038 | inc [device.packets_tx] |
- | |
1039 | mov eax, [esp+8] |
1038 | inc [device.packets_tx] |
1040 | add dword [device.bytes_tx], eax |
1039 | mov eax, [esp+8] |
1041 | adc dword [device.bytes_tx + 4], 0 |
- | |
1042 | - | ||
1043 | ; Point to transmit descriptor |
- | |
1044 | - | ||
1045 | set_io 0 |
- | |
1046 | set_io TXLBA |
- | |
1047 | mov eax, esi |
- | |
1048 | GetRealAddr |
- | |
1049 | out dx, eax |
- | |
1050 | - | ||
1051 | ; set_io TCRRCR |
- | |
1052 | ; mov eax, [device.crvalue] |
1040 | add dword [device.bytes_tx], eax |
1053 | ; out dx, eax |
1041 | adc dword [device.bytes_tx + 4], 0 |
Line 1054... | Line 1042... | ||
1054 | 1042 | ||
1055 | ; Wake the potentially-idle transmit channel. |
1043 | ; TX Poll |
Line 1075... | Line 1063... | ||
1075 | 1063 | ||
1076 | set_io 0 |
1064 | set_io 0 |
1077 | set_io PAR0 |
1065 | set_io PAR0 |
1078 | lea edi, [device.mac] |
1066 | lea edi, [device.mac] |
1079 | insd |
- | |
1080 | stosd |
1067 | insd |
1081 | set_io PAR1 |
1068 | set_io PAR1 |
1082 | insw |
- | |
1083 | stosw |
- | |
1084 | 1069 | insw |
|
1085 | DEBUGF 1,"MAC = %x-%x-%x-%x-%x-%x\n",\ |
1070 | DEBUGF 1,"MAC = %x-%x-%x-%x-%x-%x\n",\ |
Line 1086... | Line 1071... | ||
1086 | [device.mac+0]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2 |
1071 | [device.mac+0]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2 |
Line 1103... | Line 1088... | ||
1103 | align 4 |
1088 | align 4 |
1104 | int_handler: |
1089 | int_handler: |
Line 1105... | Line 1090... | ||
1105 | 1090 | ||
Line 1106... | Line 1091... | ||
1106 | push ebx esi edi |
1091 | push ebx esi edi |
Line 1107... | Line 1092... | ||
1107 | 1092 | ||
Line 1108... | Line 1093... | ||
1108 | DEBUGF 1,"int\n" |
1093 | DEBUGF 1,"INT\n" |
1109 | 1094 | ||
Line 1136... | Line 1121... | ||
1136 | 1121 | ||
Line 1137... | Line 1122... | ||
1137 | DEBUGF 1,"Device: %x Status: %x\n", ebx, ax |
1122 | DEBUGF 1,"Device: %x Status: %x\n", ebx, ax |
1138 | 1123 | ||
1139 | test ax, RI ; receive interrupt |
- | |
1140 | jz .no_rx |
- | |
1141 | - | ||
1142 | DEBUGF 1,"Receive interrupt\n" |
1124 | test ax, RI ; receive interrupt |
1143 | .rx: |
- | |
1144 | push ax |
1125 | jz .no_rx |
1145 | 1126 | push ax |
|
1146 | .rx_loop: |
- | |
1147 | mov esi, [device.cur_rx] |
1127 | .rx_loop: |
1148 | 1128 | mov esi, [device.cur_rx] |
|
Line -... | Line 1129... | ||
- | 1129 | test [esi + mtd_desc.status], RXOWN |
|
1149 | test [esi + mtd_desc.status], RXOWN |
1130 | jnz .fail_rx |
Line 1150... | Line 1131... | ||
1150 | jnz .fail_rx |
1131 | |
1151 | 1132 | push ebx |
|
1152 | push .rx_complete |
1133 | push .rx_complete |
1153 | 1134 | ||
- | 1135 | mov ecx, [esi + mtd_desc.status] |
|
Line 1154... | Line -... | ||
1154 | mov ecx, [esi + mtd_desc.status] |
- | |
1155 | shr ecx, FLNGShift |
1136 | shr ecx, FLNGShift |
1156 | sub ecx, 4 ; we dont need CRC |
- | |
1157 | push ecx |
1137 | sub ecx, 4 ; we dont need CRC |
1158 | 1138 | push ecx |
|
1159 | ;------------- |
1139 | DEBUGF 1,"Received %u bytes\n", ecx |
1160 | ; Update stats |
- | |
Line 1161... | Line 1140... | ||
1161 | 1140 | ||
1162 | add dword [device.bytes_rx], ecx |
- | |
1163 | adc dword [device.bytes_rx + 4], 0 |
1141 | ; Update stats |
Line 1164... | Line 1142... | ||
1164 | inc dword [device.packets_rx] |
1142 | add dword[device.bytes_rx], ecx |
- | 1143 | adc dword[device.bytes_rx + 4], 0 |
|
1165 | 1144 | inc [device.packets_rx] |
|
1166 | - | ||
1167 | push [esi + mtd_desc.skbuff] |
1145 | |
1168 | - | ||
- | 1146 | push [esi + mtd_desc.skbuff] |
|
1169 | jmp Eth_input |
1147 | jmp Eth_input |
- | 1148 | ||
1170 | 1149 | .rx_complete: |
|
1171 | .rx_complete: |
1150 | pop ebx |
1172 | mov esi, [device.cur_rx] |
1151 | mov esi, [device.cur_rx] |
1173 | - | ||
1174 | mov [esi + mtd_desc.control], 1536 shl RBSShift |
1152 | mov [esi + mtd_desc.control], 1536 shl RBSShift |
Line 1175... | Line 1153... | ||
1175 | 1153 | push esi |
|
1176 | stdcall KernelAlloc, 1536 |
1154 | stdcall KernelAlloc, 1536 |
Line 1177... | Line 1155... | ||
1177 | mov [esi + mtd_desc.skbuff], eax |
1155 | pop esi |
1178 | call GetPgAddr |
1156 | mov [esi + mtd_desc.skbuff], eax |
1179 | mov [esi + mtd_desc.buffer], eax |
1157 | call GetPgAddr |
1180 | 1158 | mov [esi + mtd_desc.buffer], eax |
|
Line 1193... | Line 1171... | ||
1193 | ; |
1171 | ; |
1194 | ; /* Restart Rx engine if stopped. */ |
1172 | ; /* Restart Rx engine if stopped. */ |
1195 | ; outl(0, mtdx.ioaddr + RXPDR); |
1173 | ; outl(0, mtdx.ioaddr + RXPDR); |
Line 1196... | Line 1174... | ||
1196 | 1174 | ||
1197 | .fail_rx: |
1175 | .fail_rx: |
1198 | DEBUGF 1,"RX failed\n" |
- | |
1199 | 1176 | DEBUGF 1,"RX done\n" |
|
1200 | pop ax |
- | |
Line -... | Line 1177... | ||
- | 1177 | pop ax |
|
1201 | .no_rx: |
1178 | |
1202 | 1179 | .no_rx: |
|
1203 | test ax, TI ; transmit interrupt |
- | |
1204 | jz .no_tx |
1180 | test ax, TI ; transmit interrupt |
1205 | 1181 | jz .no_tx |
|
1206 | DEBUGF 1,"Transmit interrupt\n" |
- | |
1207 | push ax |
1182 | DEBUGF 1,"TX\n" |
1208 | 1183 | push ax |
|
1209 | lea esi, [device.tx_desc] |
1184 | lea esi, [device.tx_desc] |
1210 | mov ecx, NUM_TX_DESC |
- | |
1211 | .tx_loop: |
1185 | mov ecx, NUM_TX_DESC |
1212 | 1186 | .tx_loop: |
|
1213 | test [esi + mtd_desc.status], TXOWN |
- | |
1214 | jnz .skip_this_one |
1187 | test [esi + mtd_desc.status], TXOWN |
1215 | 1188 | jnz .skip_this_one |
|
1216 | mov eax, [esi + mtd_desc.skbuff] |
1189 | mov eax, [esi + mtd_desc.skbuff] |
1217 | test eax, eax |
- | |
1218 | je .skip_this_one |
1190 | test eax, eax |
1219 | - | ||
1220 | mov [esi + mtd_desc.skbuff], 0 |
1191 | je .skip_this_one |
1221 | 1192 | mov [esi + mtd_desc.skbuff], 0 |
|
1222 | DEBUGF 1,"freeing buffer:%x\n", eax |
- | |
1223 | stdcall KernelFree, eax |
1193 | DEBUGF 1,"freeing buffer: 0x%x\n", eax |
1224 | 1194 | stdcall KernelFree, eax |
|
1225 | .skip_this_one: |
1195 | .skip_this_one: |
1226 | mov esi, [esi + mtd_desc.next_desc_logical] |
- | |
1227 | loop .tx_loop |
1196 | mov esi, [esi + mtd_desc.next_desc_logical] |
Line 1228... | Line 1197... | ||
1228 | 1197 | loop .tx_loop |
|
1229 | pop ax |
- | |
1230 | 1198 | pop ax |
|
1231 | .no_tx: |
1199 | |
1232 | - | ||
1233 | test ax, TBU |
1200 | .no_tx: |
1234 | jz .no_tbu |
- | |
1235 | 1201 | ; test ax, TBU |
|
Line 1236... | Line 1202... | ||
1236 | DEBUGF 1,"Transmit buffer unavailable!\n" |
1202 | ; jz .no_tbu |
1237 | 1203 | ; DEBUGF 2,"Transmit buffer unavailable!\n" |
|
1238 | .no_tbu: |
1204 | ; .no_tbu: |
1239 | 1205 |