Rev 3545 | Rev 4467 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3545 | Rev 3845 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; i8255x (Intel eepro 100) driver for KolibriOS ;; |
6 | ;; i8255x (Intel eepro 100) driver for KolibriOS ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; Written by hidnplayr@kolibrios.org ;; |
8 | ;; Written by hidnplayr@kolibrios.org ;; |
9 | ;; ;; |
9 | ;; ;; |
10 | ;; GNU GENERAL PUBLIC LICENSE ;; |
10 | ;; GNU GENERAL PUBLIC LICENSE ;; |
11 | ;; Version 2, June 1991 ;; |
11 | ;; Version 2, June 1991 ;; |
12 | ;; ;; |
12 | ;; ;; |
13 | ;; Some parts of this driver are based on the code of eepro100.c ;; |
13 | ;; Some parts of this driver are based on the code of eepro100.c ;; |
14 | ;; from linux. ;; |
14 | ;; from linux. ;; |
15 | ;; ;; |
15 | ;; ;; |
16 | ;; Intel's programming manual for i8255x: ;; |
16 | ;; Intel's programming manual for i8255x: ;; |
17 | ;; http://www.intel.com/design/network/manuals/8255x_opensdm.htm ;; |
17 | ;; http://www.intel.com/design/network/manuals/8255x_opensdm.htm ;; |
18 | ;; ;; |
18 | ;; ;; |
19 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
19 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
20 | 20 | ||
21 | ; TODO: use separate descriptors in memory instead of placing them in front of packets! |
21 | ; TODO: use separate descriptors in memory instead of placing them in front of packets! |
22 | 22 | ||
23 | 23 | ||
24 | format MS COFF |
24 | format MS COFF |
25 | 25 | ||
26 | API_VERSION = 0x01000100 |
26 | API_VERSION = 0x01000100 |
27 | DRIVER_VERSION = 5 |
27 | DRIVER_VERSION = 5 |
28 | 28 | ||
29 | MAX_DEVICES = 16 |
29 | MAX_DEVICES = 16 |
30 | 30 | ||
31 | DEBUG = 1 |
31 | DEBUG = 1 |
32 | __DEBUG__ = 1 |
32 | __DEBUG__ = 1 |
33 | __DEBUG_LEVEL__ = 2 |
33 | __DEBUG_LEVEL__ = 2 ; 1 = verbose, 2 = errors only |
34 | 34 | ||
35 | include '../proc32.inc' |
35 | include '../proc32.inc' |
36 | include '../imports.inc' |
36 | include '../imports.inc' |
37 | include '../fdo.inc' |
37 | include '../fdo.inc' |
38 | include '../netdrv.inc' |
38 | include '../netdrv.inc' |
39 | 39 | ||
40 | public START |
40 | public START |
41 | public service_proc |
41 | public service_proc |
42 | public version |
42 | public version |
43 | 43 | ||
44 | virtual at ebx |
44 | virtual at ebx |
45 | 45 | ||
46 | device: |
46 | device: |
47 | 47 | ||
48 | ETH_DEVICE |
48 | ETH_DEVICE |
49 | 49 | ||
50 | .io_addr dd ? |
50 | .io_addr dd ? |
51 | .pci_bus dd ? |
51 | .pci_bus dd ? |
52 | .pci_dev dd ? |
52 | .pci_dev dd ? |
53 | .irq_line db ? |
53 | .irq_line db ? |
54 | 54 | ||
55 | .rx_desc dd ? |
55 | .rx_desc dd ? |
56 | 56 | ||
57 | .ee_bus_width db ? |
57 | .ee_bus_width db ? |
58 | 58 | ||
59 | rb 0x100 - (($ - device) and 0xff) |
59 | rb 0x100 - (($ - device) and 0xff) |
60 | 60 | ||
61 | txfd: |
61 | txfd: |
62 | .status dw ? |
62 | .status dw ? |
63 | .command dw ? |
63 | .command dw ? |
64 | .link dd ? |
64 | .link dd ? |
65 | .tx_desc_addr dd ? |
65 | .tx_desc_addr dd ? |
66 | .count dd ? |
66 | .count dd ? |
67 | 67 | ||
68 | .tx_buf_addr0 dd ? |
68 | .tx_buf_addr0 dd ? |
69 | .tx_buf_size0 dd ? |
69 | .tx_buf_size0 dd ? |
70 | 70 | ||
71 | rb 0x100 - (($ - device) and 0xff) |
71 | rb 0x100 - (($ - device) and 0xff) |
72 | 72 | ||
73 | confcmd: |
73 | confcmd: |
74 | .status dw ? |
74 | .status dw ? |
75 | .command dw ? |
75 | .command dw ? |
76 | .link dd ? |
76 | .link dd ? |
77 | .data rb 64 |
77 | .data rb 64 |
78 | 78 | ||
79 | rb 0x100 - (($ - device) and 0xff) |
79 | rb 0x100 - (($ - device) and 0xff) |
80 | 80 | ||
81 | lstats: |
81 | lstats: |
82 | tx_good_frames dd ? |
82 | tx_good_frames dd ? |
83 | tx_coll16_errs dd ? |
83 | tx_coll16_errs dd ? |
84 | tx_late_colls dd ? |
84 | tx_late_colls dd ? |
85 | tx_underruns dd ? |
85 | tx_underruns dd ? |
86 | tx_lost_carrier dd ? |
86 | tx_lost_carrier dd ? |
87 | tx_deferred dd ? |
87 | tx_deferred dd ? |
88 | tx_one_colls dd ? |
88 | tx_one_colls dd ? |
89 | tx_multi_colls dd ? |
89 | tx_multi_colls dd ? |
90 | tx_total_colls dd ? |
90 | tx_total_colls dd ? |
91 | 91 | ||
92 | rx_good_frames dd ? |
92 | rx_good_frames dd ? |
93 | rx_crc_errs dd ? |
93 | rx_crc_errs dd ? |
94 | rx_align_errs dd ? |
94 | rx_align_errs dd ? |
95 | rx_resource_errs dd ? |
95 | rx_resource_errs dd ? |
96 | rx_overrun_errs dd ? |
96 | rx_overrun_errs dd ? |
97 | rx_colls_errs dd ? |
97 | rx_colls_errs dd ? |
98 | rx_runt_errs dd ? |
98 | rx_runt_errs dd ? |
99 | 99 | ||
100 | last_tx_buffer dd ? ;;; fixme |
100 | last_tx_buffer dd ? ;;; fixme |
101 | 101 | ||
102 | sizeof.device_struct = $ - device |
102 | sizeof.device_struct = $ - device |
103 | 103 | ||
104 | end virtual |
104 | end virtual |
105 | 105 | ||
106 | 106 | ||
107 | virtual at 0 |
107 | virtual at 0 |
108 | 108 | ||
109 | rxfd: |
109 | rxfd: |
110 | .status dw ? |
110 | .status dw ? |
111 | .command dw ? |
111 | .command dw ? |
112 | .link dd ? |
112 | .link dd ? |
113 | .rx_buf_addr dd ? |
113 | .rx_buf_addr dd ? |
114 | .count dw ? |
114 | .count dw ? |
115 | .size dw ? |
115 | .size dw ? |
116 | .packet: |
116 | .packet: |
117 | 117 | ||
118 | end virtual |
118 | end virtual |
119 | 119 | ||
120 | 120 | ||
121 | ; Serial EEPROM |
121 | ; Serial EEPROM |
122 | 122 | ||
123 | EE_SK = 1 shl 0 ; serial clock |
123 | EE_SK = 1 shl 0 ; serial clock |
124 | EE_CS = 1 shl 1 ; chip select |
124 | EE_CS = 1 shl 1 ; chip select |
125 | EE_DI = 1 shl 2 ; data in |
125 | EE_DI = 1 shl 2 ; data in |
126 | EE_DO = 1 shl 3 ; data out |
126 | EE_DO = 1 shl 3 ; data out |
127 | EE_MASK = EE_SK + EE_CS + EE_DI + EE_DO |
127 | EE_MASK = EE_SK + EE_CS + EE_DI + EE_DO |
128 | 128 | ||
129 | ; opcodes, first bit is start bit and must be 1 |
129 | ; opcodes, first bit is start bit and must be 1 |
130 | EE_READ = 110b |
130 | EE_READ = 110b |
131 | EE_WRITE = 101b |
131 | EE_WRITE = 101b |
132 | EE_ERASE = 111b |
132 | EE_ERASE = 111b |
133 | 133 | ||
134 | ; The SCB accepts the following controls for the Tx and Rx units: |
134 | ; The SCB accepts the following controls for the Tx and Rx units: |
135 | 135 | ||
136 | CU_START = 0x0010 |
136 | CU_START = 0x0010 |
137 | CU_RESUME = 0x0020 |
137 | CU_RESUME = 0x0020 |
138 | CU_STATSADDR = 0x0040 |
138 | CU_STATSADDR = 0x0040 |
139 | CU_SHOWSTATS = 0x0050 ; Dump statistics counters. |
139 | CU_SHOWSTATS = 0x0050 ; Dump statistics counters. |
140 | CU_CMD_BASE = 0x0060 ; Base address to add CU commands. |
140 | CU_CMD_BASE = 0x0060 ; Base address to add CU commands. |
141 | CU_DUMPSTATS = 0x0070 ; Dump then reset stats counters. |
141 | CU_DUMPSTATS = 0x0070 ; Dump then reset stats counters. |
142 | 142 | ||
143 | RX_START = 0x0001 |
143 | RX_START = 0x0001 |
144 | RX_RESUME = 0x0002 |
144 | RX_RESUME = 0x0002 |
145 | RX_ABORT = 0x0004 |
145 | RX_ABORT = 0x0004 |
146 | RX_ADDR_LOAD = 0x0006 |
146 | RX_ADDR_LOAD = 0x0006 |
147 | RX_RESUMENR = 0x0007 |
147 | RX_RESUMENR = 0x0007 |
148 | INT_MASK = 0x0100 |
148 | INT_MASK = 0x0100 |
149 | DRVR_INT = 0x0200 ; Driver generated interrupt |
149 | DRVR_INT = 0x0200 ; Driver generated interrupt |
150 | 150 | ||
151 | CmdIASetup = 0x0001 |
151 | CmdIASetup = 0x0001 |
152 | CmdConfigure = 0x0002 |
152 | CmdConfigure = 0x0002 |
153 | CmdTx = 0x0004 |
153 | CmdTx = 0x0004 |
154 | CmdTxFlex = 0x0008 |
154 | CmdTxFlex = 0x0008 |
155 | Cmdsuspend = 0x4000 |
155 | Cmdsuspend = 0x4000 |
156 | 156 | ||
157 | 157 | ||
158 | reg_scb_status = 0 |
158 | reg_scb_status = 0 |
159 | reg_scb_cmd = 2 |
159 | reg_scb_cmd = 2 |
160 | reg_scb_ptr = 4 |
160 | reg_scb_ptr = 4 |
161 | reg_port = 8 |
161 | reg_port = 8 |
162 | reg_eeprom = 14 |
162 | reg_eeprom = 14 |
163 | reg_mdi_ctrl = 16 |
163 | reg_mdi_ctrl = 16 |
164 | 164 | ||
165 | 165 | ||
166 | macro delay { |
166 | macro delay { |
167 | push eax |
167 | push eax |
168 | in ax, dx |
168 | in ax, dx |
169 | in ax, dx |
169 | in ax, dx |
170 | in ax, dx |
170 | in ax, dx |
171 | in ax, dx |
171 | in ax, dx |
172 | in ax, dx |
172 | in ax, dx |
173 | in ax, dx |
173 | in ax, dx |
174 | in ax, dx |
174 | in ax, dx |
175 | in ax, dx |
175 | in ax, dx |
176 | in ax, dx |
176 | in ax, dx |
177 | in ax, dx |
177 | in ax, dx |
178 | pop eax |
178 | pop eax |
179 | } |
179 | } |
180 | 180 | ||
181 | section '.flat' code readable align 16 |
181 | section '.flat' code readable align 16 |
182 | 182 | ||
183 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
183 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
184 | ;; ;; |
184 | ;; ;; |
185 | ;; proc START ;; |
185 | ;; proc START ;; |
186 | ;; ;; |
186 | ;; ;; |
187 | ;; (standard driver proc) ;; |
187 | ;; (standard driver proc) ;; |
188 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
188 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
189 | 189 | ||
190 | proc START stdcall, state:dword |
190 | proc START stdcall, state:dword |
191 | 191 | ||
192 | cmp [state], 1 |
192 | cmp [state], 1 |
193 | jne .exit |
193 | jne .exit |
194 | 194 | ||
195 | .entry: |
195 | .entry: |
196 | 196 | ||
197 | DEBUGF 1,"Loading %s driver\n", my_service |
197 | DEBUGF 1,"Loading driver\n" |
198 | stdcall RegService, my_service, service_proc |
198 | stdcall RegService, my_service, service_proc |
199 | ret |
199 | ret |
200 | 200 | ||
201 | .fail: |
201 | .fail: |
202 | .exit: |
202 | .exit: |
203 | xor eax, eax |
203 | xor eax, eax |
204 | ret |
204 | ret |
205 | 205 | ||
206 | endp |
206 | endp |
207 | 207 | ||
208 | 208 | ||
209 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
209 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
210 | ;; ;; |
210 | ;; ;; |
211 | ;; proc SERVICE_PROC ;; |
211 | ;; proc SERVICE_PROC ;; |
212 | ;; ;; |
212 | ;; ;; |
213 | ;; (standard driver proc) ;; |
213 | ;; (standard driver proc) ;; |
214 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
214 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
215 | 215 | ||
216 | align 4 |
216 | align 4 |
217 | proc service_proc stdcall, ioctl:dword |
217 | proc service_proc stdcall, ioctl:dword |
218 | 218 | ||
219 | mov edx, [ioctl] |
219 | mov edx, [ioctl] |
220 | mov eax, [IOCTL.io_code] |
220 | mov eax, [IOCTL.io_code] |
221 | 221 | ||
222 | ;------------------------------------------------------ |
222 | ;------------------------------------------------------ |
223 | 223 | ||
224 | cmp eax, 0 ;SRV_GETVERSION |
224 | cmp eax, 0 ;SRV_GETVERSION |
225 | jne @F |
225 | jne @F |
226 | 226 | ||
227 | cmp [IOCTL.out_size], 4 |
227 | cmp [IOCTL.out_size], 4 |
228 | jb .fail |
228 | jb .fail |
229 | mov eax, [IOCTL.output] |
229 | mov eax, [IOCTL.output] |
230 | mov [eax], dword API_VERSION |
230 | mov [eax], dword API_VERSION |
231 | 231 | ||
232 | xor eax, eax |
232 | xor eax, eax |
233 | ret |
233 | ret |
234 | 234 | ||
235 | ;------------------------------------------------------ |
235 | ;------------------------------------------------------ |
236 | @@: |
236 | @@: |
237 | cmp eax, 1 ;SRV_HOOK |
237 | cmp eax, 1 ;SRV_HOOK |
238 | jne .fail |
238 | jne .fail |
239 | 239 | ||
240 | cmp [IOCTL.inp_size], 3 ; Data input must be at least 3 bytes |
240 | cmp [IOCTL.inp_size], 3 ; Data input must be at least 3 bytes |
241 | jb .fail |
241 | jb .fail |
242 | 242 | ||
243 | mov eax, [IOCTL.input] |
243 | mov eax, [IOCTL.input] |
244 | cmp byte [eax], 1 ; 1 means device number and bus number (pci) are given |
244 | cmp byte [eax], 1 ; 1 means device number and bus number (pci) are given |
245 | jne .fail ; other types arent supported for this card yet |
245 | jne .fail ; other types arent supported for this card yet |
246 | 246 | ||
247 | ; check if the device is already listed |
247 | ; check if the device is already listed |
248 | 248 | ||
249 | mov esi, device_list |
249 | mov esi, device_list |
250 | mov ecx, [devices] |
250 | mov ecx, [devices] |
251 | test ecx, ecx |
251 | test ecx, ecx |
252 | jz .firstdevice |
252 | jz .firstdevice |
253 | 253 | ||
254 | ; mov eax, [IOCTL.input] ; get the pci bus and device numbers |
254 | ; mov eax, [IOCTL.input] ; get the pci bus and device numbers |
255 | mov ax , [eax+1] ; |
255 | mov ax , [eax+1] ; |
256 | .nextdevice: |
256 | .nextdevice: |
257 | mov ebx, [esi] |
257 | mov ebx, [esi] |
258 | cmp al, byte[device.pci_bus] |
258 | cmp al, byte[device.pci_bus] |
259 | jne @f |
259 | jne @f |
260 | cmp ah, byte[device.pci_dev] |
260 | cmp ah, byte[device.pci_dev] |
261 | je .find_devicenum ; Device is already loaded, let's find it's device number |
261 | je .find_devicenum ; Device is already loaded, let's find it's device number |
262 | @@: |
262 | @@: |
263 | add esi, 4 |
263 | add esi, 4 |
264 | loop .nextdevice |
264 | loop .nextdevice |
265 | 265 | ||
266 | 266 | ||
267 | ; This device doesnt have its own eth_device structure yet, lets create one |
267 | ; This device doesnt have its own eth_device structure yet, lets create one |
268 | .firstdevice: |
268 | .firstdevice: |
269 | cmp [devices], MAX_DEVICES ; First check if the driver can handle one more card |
269 | cmp [devices], MAX_DEVICES ; First check if the driver can handle one more card |
270 | jae .fail |
270 | jae .fail |
271 | 271 | ||
272 | allocate_and_clear ebx, sizeof.device_struct, .fail ; Allocate the buffer for device structure |
272 | allocate_and_clear ebx, sizeof.device_struct, .fail ; Allocate the buffer for device structure |
273 | 273 | ||
274 | ; Fill in the direct call addresses into the struct |
274 | ; Fill in the direct call addresses into the struct |
275 | 275 | ||
276 | mov [device.reset], reset |
276 | mov [device.reset], reset |
277 | mov [device.transmit], transmit |
277 | mov [device.transmit], transmit |
278 | mov [device.unload], unload |
278 | mov [device.unload], unload |
279 | mov [device.name], my_service |
279 | mov [device.name], my_service |
280 | 280 | ||
281 | ; save the pci bus and device numbers |
281 | ; save the pci bus and device numbers |
282 | 282 | ||
283 | mov eax, [IOCTL.input] |
283 | mov eax, [IOCTL.input] |
284 | movzx ecx, byte[eax+1] |
284 | movzx ecx, byte[eax+1] |
285 | mov [device.pci_bus], ecx |
285 | mov [device.pci_bus], ecx |
286 | movzx ecx, byte[eax+2] |
286 | movzx ecx, byte[eax+2] |
287 | mov [device.pci_dev], ecx |
287 | mov [device.pci_dev], ecx |
288 | 288 | ||
289 | ; Now, it's time to find the base io addres of the PCI device |
289 | ; Now, it's time to find the base io addres of the PCI device |
290 | 290 | ||
291 | PCI_find_io |
291 | PCI_find_io |
292 | 292 | ||
293 | ; We've found the io address, find IRQ now |
293 | ; We've found the io address, find IRQ now |
294 | 294 | ||
295 | PCI_find_irq |
295 | PCI_find_irq |
296 | 296 | ||
297 | DEBUGF 2,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\ |
297 | DEBUGF 1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\ |
298 | [device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4 |
298 | [device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4 |
299 | 299 | ||
300 | ; Ok, the eth_device structure is ready, let's probe the device |
300 | ; Ok, the eth_device structure is ready, let's probe the device |
301 | 301 | ||
302 | pushf |
302 | pushf |
303 | cli ; disable ints until initialisation is done |
303 | cli ; disable ints until initialisation is done |
304 | 304 | ||
305 | call probe ; this function will output in eax |
305 | call probe ; this function will output in eax |
306 | test eax, eax |
306 | test eax, eax |
307 | jnz .err ; If an error occured, exit |
307 | jnz .err ; If an error occured, exit |
308 | 308 | ||
309 | mov eax, [devices] ; Add the device structure to our device list |
309 | mov eax, [devices] ; Add the device structure to our device list |
310 | mov [device_list+4*eax], ebx ; (IRQ handler uses this list to find device) |
310 | mov [device_list+4*eax], ebx ; (IRQ handler uses this list to find device) |
311 | inc [devices] ; |
311 | inc [devices] ; |
312 | 312 | ||
313 | popf |
313 | popf |
314 | 314 | ||
315 | mov [device.type], NET_TYPE_ETH |
315 | mov [device.type], NET_TYPE_ETH |
316 | call NetRegDev |
316 | call NetRegDev |
317 | 317 | ||
318 | cmp eax, -1 |
318 | cmp eax, -1 |
319 | je .err |
319 | je .err |
320 | 320 | ||
321 | ret |
321 | ret |
322 | 322 | ||
323 | ; If the device was already loaded, find the device number and return it in eax |
323 | ; If the device was already loaded, find the device number and return it in eax |
324 | 324 | ||
325 | .find_devicenum: |
325 | .find_devicenum: |
326 | DEBUGF 2,"Trying to find device number of already registered device\n" |
326 | DEBUGF 2,"Trying to find device number of already registered device\n" |
327 | call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
327 | call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
328 | ; into a device number in edi |
328 | ; into a device number in edi |
329 | mov eax, edi ; Application wants it in eax instead |
329 | mov eax, edi ; Application wants it in eax instead |
330 | DEBUGF 2,"Kernel says: %u\n", eax |
330 | DEBUGF 2,"Kernel says: %u\n", eax |
331 | ret |
331 | ret |
332 | 332 | ||
333 | ; If an error occured, remove all allocated data and exit (returning -1 in eax) |
333 | ; If an error occured, remove all allocated data and exit (returning -1 in eax) |
334 | 334 | ||
335 | .err: |
335 | .err: |
336 | stdcall KernelFree, ebx |
336 | stdcall KernelFree, ebx |
337 | 337 | ||
338 | .fail: |
338 | .fail: |
339 | or eax, -1 |
339 | or eax, -1 |
340 | ret |
340 | ret |
341 | 341 | ||
342 | ;------------------------------------------------------ |
342 | ;------------------------------------------------------ |
343 | endp |
343 | endp |
344 | 344 | ||
345 | 345 | ||
346 | 346 | ||
347 | 347 | ||
348 | 348 | ||
349 | ;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;; |
349 | ;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;; |
350 | ;; ;; |
350 | ;; ;; |
351 | ;; Actual Hardware dependent code starts here ;; |
351 | ;; Actual Hardware dependent code starts here ;; |
352 | ;; ;; |
352 | ;; ;; |
353 | ;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;; |
353 | ;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;; |
354 | 354 | ||
355 | 355 | ||
356 | unload: |
356 | unload: |
357 | ; TODO: (in this particular order) |
357 | ; TODO: (in this particular order) |
358 | ; |
358 | ; |
359 | ; - Stop the device |
359 | ; - Stop the device |
360 | ; - Detach int handler |
360 | ; - Detach int handler |
361 | ; - Remove device from local list (device_list) |
361 | ; - Remove device from local list (device_list) |
362 | ; - call unregister function in kernel |
362 | ; - call unregister function in kernel |
363 | ; - Remove all allocated structures and buffers the card used |
363 | ; - Remove all allocated structures and buffers the card used |
364 | 364 | ||
365 | or eax,-1 |
365 | or eax,-1 |
366 | 366 | ||
367 | ret |
367 | ret |
368 | 368 | ||
369 | 369 | ||
370 | ;------------- |
370 | ;------------- |
371 | ; |
371 | ; |
372 | ; Probe |
372 | ; Probe |
373 | ; |
373 | ; |
374 | ;------------- |
374 | ;------------- |
375 | 375 | ||
376 | align 4 |
376 | align 4 |
377 | probe: |
377 | probe: |
378 | 378 | ||
379 | DEBUGF 1,"Probing i8255x\n" |
379 | DEBUGF 1,"Probing\n" |
380 | 380 | ||
381 | PCI_make_bus_master |
381 | PCI_make_bus_master |
382 | 382 | ||
383 | ;--------------------------- |
383 | ;--------------------------- |
384 | ; First, identify the device |
384 | ; First, identify the device |
385 | 385 | ||
386 | stdcall PciRead32, [device.pci_bus], [device.pci_dev], PCI_VENDOR_ID ; get device/vendor id |
386 | stdcall PciRead32, [device.pci_bus], [device.pci_dev], PCI_VENDOR_ID ; get device/vendor id |
387 | 387 | ||
388 | DEBUGF 1,"Vendor_id=0x%x\n", ax |
388 | DEBUGF 1,"Vendor_id=0x%x\n", ax |
389 | 389 | ||
390 | cmp ax, 0x8086 |
390 | cmp ax, 0x8086 |
391 | jne .notfound |
391 | jne .notfound |
392 | shr eax, 16 |
392 | shr eax, 16 |
393 | 393 | ||
394 | DEBUGF 1,"Device_id=0x%x\n", ax |
394 | DEBUGF 1,"Device_id=0x%x\n", ax |
395 | 395 | ||
396 | mov ecx, DEVICE_IDs |
396 | mov ecx, DEVICE_IDs |
397 | mov edi, device_id_list |
397 | mov edi, device_id_list |
398 | repne scasw |
398 | repne scasw |
399 | jne .notfound |
399 | jne .notfound |
400 | jmp .found |
400 | jmp .found |
401 | 401 | ||
402 | .notfound: |
402 | .notfound: |
403 | DEBUGF 1,"ERROR: Unsupported device!\n" |
403 | DEBUGF 2,"Unsupported device!\n" |
404 | or eax, -1 |
404 | or eax, -1 |
405 | ret |
405 | ret |
406 | 406 | ||
407 | .found: |
407 | .found: |
408 | 408 | ||
409 | call ee_get_width |
409 | call ee_get_width |
410 | call MAC_read_eeprom |
410 | call MAC_read_eeprom |
411 | 411 | ||
412 | ;;; TODO: detect phy |
412 | ;;; TODO: detect phy |
413 | 413 | ||
414 | 414 | ||
415 | 415 | ||
416 | ;---------- |
416 | ;---------- |
417 | ; |
417 | ; |
418 | ; Reset |
418 | ; Reset |
419 | ; |
419 | ; |
420 | ;---------- |
420 | ;---------- |
421 | 421 | ||
422 | align 4 |
422 | align 4 |
423 | reset: |
423 | reset: |
424 | 424 | ||
425 | movzx eax, [device.irq_line] |
425 | movzx eax, [device.irq_line] |
426 | DEBUGF 1,"Attaching int handler to irq %x\n", eax:1 |
426 | DEBUGF 1,"Attaching int handler to irq %x\n", eax:1 |
427 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
427 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
428 | test eax, eax |
428 | test eax, eax |
429 | jnz @f |
429 | jnz @f |
430 | DEBUGF 1,"\nCould not attach int handler!\n" |
430 | DEBUGF 2,"Could not attach int handler!\n" |
431 | ; or eax, -1 |
431 | ; or eax, -1 |
432 | ; ret |
432 | ; ret |
433 | @@: |
433 | @@: |
434 | 434 | ||
435 | DEBUGF 1,"Resetting %s\n", my_service |
435 | DEBUGF 1,"Resetting\n" |
436 | 436 | ||
437 | ;--------------- |
437 | ;--------------- |
438 | ; reset the card |
438 | ; reset the card |
439 | 439 | ||
440 | set_io 0 |
440 | set_io 0 |
441 | set_io reg_port |
441 | set_io reg_port |
442 | xor eax, eax ; Software Reset |
442 | xor eax, eax ; Software Reset |
443 | out dx, eax |
443 | out dx, eax |
444 | 444 | ||
445 | mov esi, 10 |
445 | mov esi, 10 |
446 | call Sleep ; Give the card time to warm up. |
446 | call Sleep ; Give the card time to warm up. |
447 | 447 | ||
448 | ;--------------------------------- |
448 | ;--------------------------------- |
449 | ; Tell device where to store stats |
449 | ; Tell device where to store stats |
450 | 450 | ||
451 | lea eax, [lstats] |
451 | lea eax, [lstats] |
452 | GetRealAddr |
452 | GetRealAddr |
453 | set_io 0 |
453 | set_io 0 |
454 | set_io reg_scb_ptr |
454 | set_io reg_scb_ptr |
455 | out dx, eax |
455 | out dx, eax |
456 | 456 | ||
457 | mov ax, INT_MASK + CU_STATSADDR |
457 | mov ax, INT_MASK + CU_STATSADDR |
458 | set_io reg_scb_cmd |
458 | set_io reg_scb_cmd |
459 | out dx, ax |
459 | out dx, ax |
460 | call cmd_wait |
460 | call cmd_wait |
461 | 461 | ||
462 | ;----------------- |
462 | ;----------------- |
463 | ; setup RX |
463 | ; setup RX |
464 | 464 | ||
465 | set_io reg_scb_ptr |
465 | set_io reg_scb_ptr |
466 | xor eax, eax |
466 | xor eax, eax |
467 | out dx, eax |
467 | out dx, eax |
468 | 468 | ||
469 | set_io reg_scb_cmd |
469 | set_io reg_scb_cmd |
470 | mov ax, INT_MASK + RX_ADDR_LOAD |
470 | mov ax, INT_MASK + RX_ADDR_LOAD |
471 | out dx, ax |
471 | out dx, ax |
472 | call cmd_wait |
472 | call cmd_wait |
473 | 473 | ||
474 | ;----------------------------- |
474 | ;----------------------------- |
475 | ; Create RX and TX descriptors |
475 | ; Create RX and TX descriptors |
476 | 476 | ||
477 | call create_ring |
477 | call create_ring |
478 | 478 | ||
479 | ; RX start |
479 | ; RX start |
480 | 480 | ||
481 | set_io 0 |
481 | set_io 0 |
482 | set_io reg_scb_ptr |
482 | set_io reg_scb_ptr |
483 | mov eax, [device.rx_desc] |
483 | mov eax, [device.rx_desc] |
484 | GetRealAddr |
484 | GetRealAddr |
485 | out dx, eax |
485 | out dx, eax |
486 | 486 | ||
487 | mov ax, INT_MASK + RX_START |
487 | mov ax, INT_MASK + RX_START |
488 | set_io reg_scb_cmd |
488 | set_io reg_scb_cmd |
489 | out dx, ax |
489 | out dx, ax |
490 | call cmd_wait |
490 | call cmd_wait |
491 | 491 | ||
492 | ; Set-up TX |
492 | ; Set-up TX |
493 | 493 | ||
494 | set_io reg_scb_ptr |
494 | set_io reg_scb_ptr |
495 | xor eax, eax |
495 | xor eax, eax |
496 | out dx, eax |
496 | out dx, eax |
497 | 497 | ||
498 | set_io reg_scb_cmd |
498 | set_io reg_scb_cmd |
499 | mov ax, INT_MASK + CU_CMD_BASE |
499 | mov ax, INT_MASK + CU_CMD_BASE |
500 | out dx, ax |
500 | out dx, ax |
501 | call cmd_wait |
501 | call cmd_wait |
502 | 502 | ||
503 | ; -------------------- |
503 | ; -------------------- |
504 | 504 | ||
505 | mov [confcmd.command], CmdConfigure + Cmdsuspend |
505 | mov [confcmd.command], CmdConfigure + Cmdsuspend |
506 | mov [confcmd.status], 0 |
506 | mov [confcmd.status], 0 |
507 | lea eax, [txfd] |
507 | lea eax, [txfd] |
508 | GetRealAddr |
508 | GetRealAddr |
509 | mov [confcmd.link], eax |
509 | mov [confcmd.link], eax |
510 | 510 | ||
511 | mov esi, confcmd_data |
511 | mov esi, confcmd_data |
512 | lea edi, [confcmd.data] |
512 | lea edi, [confcmd.data] |
513 | mov ecx, 22 |
513 | mov ecx, 22 |
514 | rep movsb |
514 | rep movsb |
515 | 515 | ||
516 | mov byte[confcmd.data + 1], 0x88 ; fifo of 8 each |
516 | mov byte[confcmd.data + 1], 0x88 ; fifo of 8 each |
517 | mov byte[confcmd.data + 4], 0 |
517 | mov byte[confcmd.data + 4], 0 |
518 | mov byte[confcmd.data + 5], 0x80 |
518 | mov byte[confcmd.data + 5], 0x80 |
519 | mov byte[confcmd.data + 15], 0x48 |
519 | mov byte[confcmd.data + 15], 0x48 |
520 | mov byte[confcmd.data + 19], 0x80 |
520 | mov byte[confcmd.data + 19], 0x80 |
521 | mov byte[confcmd.data + 21], 0x05 |
521 | mov byte[confcmd.data + 21], 0x05 |
522 | 522 | ||
523 | mov [txfd.command], CmdIASetup |
523 | mov [txfd.command], CmdIASetup |
524 | mov [txfd.status], 0 |
524 | mov [txfd.status], 0 |
525 | lea eax, [confcmd] |
525 | lea eax, [confcmd] |
526 | GetRealAddr |
526 | GetRealAddr |
527 | mov [txfd.link], eax |
527 | mov [txfd.link], eax |
528 | 528 | ||
529 | ;;; copy in our MAC |
529 | ;;; copy in our MAC |
530 | 530 | ||
531 | lea edi, [txfd.tx_desc_addr] |
531 | lea edi, [txfd.tx_desc_addr] |
532 | lea esi, [device.mac] |
532 | lea esi, [device.mac] |
533 | movsd |
533 | movsd |
534 | movsw |
534 | movsw |
535 | 535 | ||
536 | set_io reg_scb_ptr |
536 | set_io reg_scb_ptr |
537 | lea eax, [txfd] |
537 | lea eax, [txfd] |
538 | GetRealAddr |
538 | GetRealAddr |
539 | out dx, eax |
539 | out dx, eax |
540 | 540 | ||
541 | ; Start CU & enable ints |
541 | ; Start CU & enable ints |
542 | 542 | ||
543 | set_io reg_scb_cmd |
543 | set_io reg_scb_cmd |
544 | mov ax, CU_START |
544 | mov ax, CU_START |
545 | out dx, ax |
545 | out dx, ax |
546 | call cmd_wait |
546 | call cmd_wait |
547 | 547 | ||
548 | ;----------------------- |
548 | ;----------------------- |
549 | ; build txfd structure (again!) |
549 | ; build txfd structure (again!) |
550 | 550 | ||
551 | lea eax, [txfd] |
551 | lea eax, [txfd] |
552 | GetRealAddr |
552 | GetRealAddr |
553 | mov [txfd.link], eax |
553 | mov [txfd.link], eax |
554 | mov [txfd.count], 0x02208000 |
554 | mov [txfd.count], 0x02208000 |
555 | lea eax, [txfd.tx_buf_addr0] |
555 | lea eax, [txfd.tx_buf_addr0] |
556 | GetRealAddr |
556 | GetRealAddr |
557 | mov [txfd.tx_desc_addr], eax |
557 | mov [txfd.tx_desc_addr], eax |
558 | 558 | ||
559 | ; Indicate that we have successfully reset the card |
559 | ; Indicate that we have successfully reset the card |
560 | 560 | ||
561 | DEBUGF 1,"Resetting %s complete\n", my_service |
561 | DEBUGF 1,"Reset complete\n" |
562 | 562 | ||
563 | mov [device.mtu], 1514 |
563 | mov [device.mtu], 1514 |
564 | 564 | ||
565 | ; Set link state to unknown |
565 | ; Set link state to unknown |
566 | mov [device.state], ETH_LINK_UNKOWN |
566 | mov [device.state], ETH_LINK_UNKOWN |
567 | 567 | ||
568 | xor eax, eax ; indicate that we have successfully reset the card |
568 | xor eax, eax ; indicate that we have successfully reset the card |
569 | ret |
569 | ret |
570 | 570 | ||
571 | 571 | ||
572 | align 4 |
572 | align 4 |
573 | create_ring: |
573 | create_ring: |
574 | 574 | ||
575 | DEBUGF 1,"Creating ring\n" |
575 | DEBUGF 1,"Creating ring\n" |
576 | 576 | ||
577 | ;--------------------- |
577 | ;--------------------- |
578 | ; build rxfd structure |
578 | ; build rxfd structure |
579 | 579 | ||
580 | stdcall KernelAlloc, 2000 |
580 | stdcall KernelAlloc, 2000 |
581 | mov [device.rx_desc], eax |
581 | mov [device.rx_desc], eax |
582 | mov esi, eax |
582 | mov esi, eax |
583 | GetRealAddr |
583 | GetRealAddr |
584 | mov [esi + rxfd.status], 0x0000 |
584 | mov [esi + rxfd.status], 0x0000 |
585 | mov [esi + rxfd.command], 0x0000 |
585 | mov [esi + rxfd.command], 0x0000 |
586 | mov [esi + rxfd.link], eax |
586 | mov [esi + rxfd.link], eax |
587 | mov [esi + rxfd.count], 0 |
587 | mov [esi + rxfd.count], 0 |
588 | mov [esi + rxfd.size], 1528 |
588 | mov [esi + rxfd.size], 1528 |
589 | 589 | ||
590 | ;----------------------- |
590 | ;----------------------- |
591 | ; build txfd structure |
591 | ; build txfd structure |
592 | 592 | ||
593 | lea eax, [txfd] |
593 | lea eax, [txfd] |
594 | GetRealAddr |
594 | GetRealAddr |
595 | mov [txfd.link], eax |
595 | mov [txfd.link], eax |
596 | mov [txfd.count], 0x02208000 |
596 | mov [txfd.count], 0x02208000 |
597 | lea eax, [txfd.tx_buf_addr0] |
597 | lea eax, [txfd.tx_buf_addr0] |
598 | GetRealAddr |
598 | GetRealAddr |
599 | mov [txfd.tx_desc_addr], eax |
599 | mov [txfd.tx_desc_addr], eax |
600 | 600 | ||
601 | ret |
601 | ret |
602 | 602 | ||
603 | 603 | ||
604 | 604 | ||
605 | 605 | ||
606 | 606 | ||
607 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
607 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
608 | ;; ;; |
608 | ;; ;; |
609 | ;; Transmit ;; |
609 | ;; Transmit ;; |
610 | ;; ;; |
610 | ;; ;; |
611 | ;; In: buffer pointer in [esp+4] ;; |
611 | ;; In: buffer pointer in [esp+4] ;; |
612 | ;; size of buffer in [esp+8] ;; |
612 | ;; size of buffer in [esp+8] ;; |
613 | ;; pointer to device structure in ebx ;; |
613 | ;; pointer to device structure in ebx ;; |
614 | ;; ;; |
614 | ;; ;; |
615 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
615 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
616 | 616 | ||
617 | align 4 |
617 | align 4 |
618 | transmit: |
618 | transmit: |
619 | 619 | ||
620 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [esp+4], [esp+8] |
620 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [esp+4], [esp+8] |
621 | mov eax, [esp+4] |
621 | mov eax, [esp+4] |
622 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
622 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
623 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
623 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
624 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
624 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
625 | [eax+13]:2,[eax+12]:2 |
625 | [eax+13]:2,[eax+12]:2 |
626 | 626 | ||
627 | cmp dword [esp+8], 1514 |
627 | cmp dword [esp+8], 1514 |
628 | ja .error ; packet is too long |
628 | ja .error ; packet is too long |
629 | cmp dword [esp+8], 60 |
629 | cmp dword [esp+8], 60 |
630 | jb .error ; packet is too short |
630 | jb .error ; packet is too short |
631 | 631 | ||
632 | ;;; TODO: check if current descriptor is in use |
632 | ;;; TODO: check if current descriptor is in use |
633 | ; fill in buffer address and size |
633 | ; fill in buffer address and size |
634 | mov eax, [esp+4] |
634 | mov eax, [esp+4] |
635 | mov [last_tx_buffer], eax ;;; FIXME |
635 | mov [last_tx_buffer], eax ;;; FIXME |
636 | GetRealAddr |
636 | GetRealAddr |
637 | mov [txfd.tx_buf_addr0], eax |
637 | mov [txfd.tx_buf_addr0], eax |
638 | mov eax, [esp+8] |
638 | mov eax, [esp+8] |
639 | mov [txfd.tx_buf_size0], eax |
639 | mov [txfd.tx_buf_size0], eax |
640 | 640 | ||
641 | mov [txfd.status], 0 |
641 | mov [txfd.status], 0 |
642 | mov [txfd.command], Cmdsuspend + CmdTx + CmdTxFlex + 1 shl 15 ;;; EL bit |
642 | mov [txfd.command], Cmdsuspend + CmdTx + CmdTxFlex + 1 shl 15 ;;; EL bit |
643 | 643 | ||
644 | ; mov [txfd.count], 0x02208000 ;;;;;;;;;;; |
644 | ; mov [txfd.count], 0x02208000 ;;;;;;;;;;; |
645 | 645 | ||
646 | ; Inform device of the new/updated transmit descriptor |
646 | ; Inform device of the new/updated transmit descriptor |
647 | lea eax, [txfd] |
647 | lea eax, [txfd] |
648 | GetRealAddr |
648 | GetRealAddr |
649 | set_io 0 |
649 | set_io 0 |
650 | set_io reg_scb_ptr |
650 | set_io reg_scb_ptr |
651 | out dx, eax |
651 | out dx, eax |
652 | 652 | ||
653 | ; Start the transmit |
653 | ; Start the transmit |
654 | mov ax, CU_START |
654 | mov ax, CU_START |
655 | set_io reg_scb_cmd |
655 | set_io reg_scb_cmd |
656 | out dx, ax |
656 | out dx, ax |
657 | call cmd_wait |
657 | call cmd_wait |
658 | 658 | ||
659 | ; set_io 0 ;; why? |
659 | ; set_io 0 ;; why? |
660 | ; in ax, dx ;; |
660 | ; in ax, dx ;; |
661 | ; |
661 | ; |
662 | ; @@: |
662 | ; @@: |
663 | ; cmp [txfd.status], 0 ; wait for completion? dont seems a good idea to me.. |
663 | ; cmp [txfd.status], 0 ; wait for completion? dont seems a good idea to me.. |
664 | ; je @r |
664 | ; je @r |
665 | ; |
665 | ; |
666 | ; set_io 0 ;; why? |
666 | ; set_io 0 ;; why? |
667 | ; in ax, dx ;; |
667 | ; in ax, dx ;; |
668 | 668 | ||
669 | ; Update stats |
669 | ; Update stats |
670 | inc [device.packets_tx] |
670 | inc [device.packets_tx] |
671 | mov eax, [esp + 8] |
671 | mov eax, [esp + 8] |
672 | add dword [device.bytes_tx], eax |
672 | add dword [device.bytes_tx], eax |
673 | adc dword [device.bytes_tx + 4], 0 |
673 | adc dword [device.bytes_tx + 4], 0 |
674 | 674 | ||
675 | DEBUGF 1,"Transmit OK\n" |
675 | DEBUGF 1,"Transmit OK\n" |
676 | 676 | ||
677 | xor eax, eax |
677 | xor eax, eax |
678 | ret 8 |
678 | ret 8 |
679 | 679 | ||
680 | .error: |
680 | .error: |
681 | stdcall KernelFree, [esp+4] |
681 | stdcall KernelFree, [esp+4] |
682 | or eax, -1 |
682 | or eax, -1 |
683 | ret 8 |
683 | ret 8 |
684 | 684 | ||
685 | ;;;;;;;;;;;;;;;;;;;;;;; |
685 | ;;;;;;;;;;;;;;;;;;;;;;; |
686 | ;; ;; |
686 | ;; ;; |
687 | ;; Interrupt handler ;; |
687 | ;; Interrupt handler ;; |
688 | ;; ;; |
688 | ;; ;; |
689 | ;;;;;;;;;;;;;;;;;;;;;;; |
689 | ;;;;;;;;;;;;;;;;;;;;;;; |
690 | 690 | ||
691 | align 4 |
691 | align 4 |
692 | int_handler: |
692 | int_handler: |
693 | 693 | ||
694 | push ebx esi edi |
694 | push ebx esi edi |
695 | 695 | ||
696 | DEBUGF 1,"\n%s int\n", my_service |
696 | DEBUGF 1,"INT\n" |
697 | 697 | ||
698 | ; find pointer of device wich made IRQ occur |
698 | ; find pointer of device wich made IRQ occur |
699 | 699 | ||
700 | mov ecx, [devices] |
700 | mov ecx, [devices] |
701 | test ecx, ecx |
701 | test ecx, ecx |
702 | jz .nothing |
702 | jz .nothing |
703 | mov esi, device_list |
703 | mov esi, device_list |
704 | .nextdevice: |
704 | .nextdevice: |
705 | mov ebx, [esi] |
705 | mov ebx, [esi] |
706 | 706 | ||
707 | ; set_io 0 ; reg_scb_status = 0 |
707 | ; set_io 0 ; reg_scb_status = 0 |
708 | set_io reg_scb_status |
708 | set_io reg_scb_status |
709 | in ax, dx |
709 | in ax, dx |
710 | out dx, ax ; send it back to ACK |
710 | out dx, ax ; send it back to ACK |
711 | test ax, ax |
711 | test ax, ax |
712 | jnz .got_it |
712 | jnz .got_it |
713 | .continue: |
713 | .continue: |
714 | add esi, 4 |
714 | add esi, 4 |
715 | dec ecx |
715 | dec ecx |
716 | jnz .nextdevice |
716 | jnz .nextdevice |
717 | .nothing: |
717 | .nothing: |
718 | pop edi esi ebx |
718 | pop edi esi ebx |
719 | xor eax, eax |
719 | xor eax, eax |
720 | 720 | ||
721 | ret ; If no device was found, abort (The irq was probably for a device, not registered to this driver) |
721 | ret ; If no device was found, abort (The irq was probably for a device, not registered to this driver) |
722 | 722 | ||
723 | .got_it: |
723 | .got_it: |
724 | 724 | ||
725 | DEBUGF 1,"Device: %x Status: %x\n", ebx, ax |
725 | DEBUGF 1,"Device: %x Status: %x\n", ebx, ax |
726 | 726 | ||
727 | test ax, 1 shl 14 ; did we receive a frame? |
727 | test ax, 1 shl 14 ; did we receive a frame? |
728 | jz .no_rx |
728 | jz .no_rx |
729 | 729 | ||
730 | push ax |
730 | push ax |
731 | 731 | ||
732 | DEBUGF 1,"Receiving\n" |
732 | DEBUGF 1,"Receiving\n" |
733 | 733 | ||
734 | push ebx |
734 | push ebx |
735 | .rx_loop: |
735 | .rx_loop: |
736 | pop ebx |
736 | pop ebx |
737 | 737 | ||
738 | mov esi, [device.rx_desc] |
738 | mov esi, [device.rx_desc] |
739 | cmp [esi + rxfd.status], 0 ; we could also check bits C and OK (bit 15 and 13) |
739 | cmp [esi + rxfd.status], 0 ; we could also check bits C and OK (bit 15 and 13) |
740 | je .nodata |
740 | je .nodata |
741 | 741 | ||
742 | DEBUGF 1,"rxfd status=0x%x\n", [esi + rxfd.status]:4 |
742 | DEBUGF 1,"rxfd status=0x%x\n", [esi + rxfd.status]:4 |
743 | 743 | ||
744 | movzx ecx, [esi + rxfd.count] |
744 | movzx ecx, [esi + rxfd.count] |
745 | and ecx, 0x3fff |
745 | and ecx, 0x3fff |
746 | 746 | ||
747 | push ebx |
747 | push ebx |
748 | push .rx_loop |
748 | push .rx_loop |
749 | push ecx |
749 | push ecx |
750 | add esi, rxfd.packet |
750 | add esi, rxfd.packet |
751 | push esi |
751 | push esi |
752 | 752 | ||
753 | ; Update stats |
753 | ; Update stats |
754 | add dword [device.bytes_rx], ecx |
754 | add dword [device.bytes_rx], ecx |
755 | adc dword [device.bytes_rx + 4], 0 |
755 | adc dword [device.bytes_rx + 4], 0 |
756 | inc dword [device.packets_rx] |
756 | inc dword [device.packets_rx] |
757 | 757 | ||
758 | ; allocate new descriptor |
758 | ; allocate new descriptor |
759 | 759 | ||
760 | stdcall KernelAlloc, 2000 |
760 | stdcall KernelAlloc, 2000 |
761 | mov [device.rx_desc], eax |
761 | mov [device.rx_desc], eax |
762 | mov esi, eax |
762 | mov esi, eax |
763 | GetRealAddr |
763 | GetRealAddr |
764 | mov [esi + rxfd.status], 0x0000 |
764 | mov [esi + rxfd.status], 0x0000 |
765 | mov [esi + rxfd.command], 0xc000 ; End of list + Suspend |
765 | mov [esi + rxfd.command], 0xc000 ; End of list + Suspend |
766 | mov [esi + rxfd.link], eax |
766 | mov [esi + rxfd.link], eax |
767 | mov [esi + rxfd.count], 0 |
767 | mov [esi + rxfd.count], 0 |
768 | mov [esi + rxfd.size], 1528 |
768 | mov [esi + rxfd.size], 1528 |
769 | 769 | ||
770 | ; restart RX |
770 | ; restart RX |
771 | 771 | ||
772 | set_io 0 |
772 | set_io 0 |
773 | set_io reg_scb_ptr |
773 | set_io reg_scb_ptr |
774 | ; lea eax, [device.rx_desc] |
774 | ; lea eax, [device.rx_desc] |
775 | ; GetRealAddr |
775 | ; GetRealAddr |
776 | out dx, eax |
776 | out dx, eax |
777 | 777 | ||
778 | set_io reg_scb_cmd |
778 | set_io reg_scb_cmd |
779 | mov ax, RX_START |
779 | mov ax, RX_START |
780 | out dx, ax |
780 | out dx, ax |
781 | call cmd_wait |
781 | call cmd_wait |
782 | 782 | ||
783 | ; And give packet to kernel |
783 | ; And give packet to kernel |
784 | 784 | ||
785 | jmp Eth_input |
785 | jmp Eth_input |
786 | 786 | ||
787 | .nodata: |
787 | .nodata: |
788 | DEBUGF 1, "no more data\n" |
788 | DEBUGF 1, "no more data\n" |
789 | pop ax |
789 | pop ax |
790 | 790 | ||
791 | .no_rx: |
791 | .no_rx: |
792 | 792 | ||
793 | ; Cleanup after TX |
793 | ; Cleanup after TX |
794 | cmp [txfd.status], 0 |
794 | cmp [txfd.status], 0 |
795 | je .done |
795 | je .done |
796 | cmp [last_tx_buffer], 0 |
796 | cmp [last_tx_buffer], 0 |
797 | je .done |
797 | je .done |
798 | push ax |
798 | push ax |
799 | DEBUGF 1, "Removing packet 0x%x from RAM!\n", [last_tx_buffer] |
799 | DEBUGF 1, "Removing packet 0x%x from RAM!\n", [last_tx_buffer] |
800 | stdcall KernelFree, [last_tx_buffer] |
800 | stdcall KernelFree, [last_tx_buffer] |
801 | mov [last_tx_buffer], 0 |
801 | mov [last_tx_buffer], 0 |
802 | pop ax |
802 | pop ax |
803 | 803 | ||
804 | .done: |
804 | .done: |
805 | and ax, 00111100b |
805 | and ax, 00111100b |
806 | cmp ax, 00001000b |
806 | cmp ax, 00001000b |
807 | jne .fail |
807 | jne .fail |
808 | 808 | ||
809 | DEBUGF 1, "out of resources!\n" |
809 | DEBUGF 1, "out of resources!\n" |
810 | ; Restart the RX |
810 | ; Restart the RX |
811 | 811 | ||
812 | ; allocate new descriptor |
812 | ; allocate new descriptor |
813 | 813 | ||
814 | stdcall KernelAlloc, 2000 |
814 | stdcall KernelAlloc, 2000 |
815 | mov [device.rx_desc], eax |
815 | mov [device.rx_desc], eax |
816 | mov esi, eax |
816 | mov esi, eax |
817 | GetRealAddr |
817 | GetRealAddr |
818 | mov [esi + rxfd.status], 0x0000 |
818 | mov [esi + rxfd.status], 0x0000 |
819 | mov [esi + rxfd.command], 0xc000 ; End of list + Suspend |
819 | mov [esi + rxfd.command], 0xc000 ; End of list + Suspend |
820 | mov [esi + rxfd.link], eax |
820 | mov [esi + rxfd.link], eax |
821 | mov [esi + rxfd.count], 0 |
821 | mov [esi + rxfd.count], 0 |
822 | mov [esi + rxfd.size], 1528 |
822 | mov [esi + rxfd.size], 1528 |
823 | 823 | ||
824 | ; restart RX |
824 | ; restart RX |
825 | 825 | ||
826 | set_io 0 |
826 | set_io 0 |
827 | set_io reg_scb_ptr |
827 | set_io reg_scb_ptr |
828 | ; lea eax, [device.rx_desc] |
828 | ; lea eax, [device.rx_desc] |
829 | ; GetRealAddr |
829 | ; GetRealAddr |
830 | out dx, eax |
830 | out dx, eax |
831 | 831 | ||
832 | set_io reg_scb_cmd |
832 | set_io reg_scb_cmd |
833 | mov ax, RX_START |
833 | mov ax, RX_START |
834 | out dx, ax |
834 | out dx, ax |
835 | call cmd_wait |
835 | call cmd_wait |
836 | 836 | ||
837 | .fail: |
837 | .fail: |
838 | pop edi esi ebx |
838 | pop edi esi ebx |
839 | xor eax, eax |
839 | xor eax, eax |
840 | inc eax |
840 | inc eax |
841 | 841 | ||
842 | ret |
842 | ret |
843 | 843 | ||
844 | 844 | ||
845 | 845 | ||
846 | 846 | ||
847 | align 4 |
847 | align 4 |
848 | cmd_wait: |
848 | cmd_wait: |
849 | 849 | ||
850 | in al, dx |
850 | in al, dx |
851 | test al, al |
851 | test al, al |
852 | jnz cmd_wait |
852 | jnz cmd_wait |
853 | 853 | ||
854 | ret |
854 | ret |
855 | 855 | ||
856 | 856 | ||
857 | 857 | ||
858 | 858 | ||
859 | 859 | ||
860 | 860 | ||
861 | align 4 |
861 | align 4 |
862 | ee_read: ; esi = address to read |
862 | ee_read: ; esi = address to read |
863 | 863 | ||
864 | DEBUGF 1,"Eeprom read from 0x%x", esi |
864 | DEBUGF 1,"Eeprom read from 0x%x\n", esi |
865 | 865 | ||
866 | set_io 0 |
866 | set_io 0 |
867 | set_io reg_eeprom |
867 | set_io reg_eeprom |
868 | 868 | ||
869 | ;----------------------------------------------------- |
869 | ;----------------------------------------------------- |
870 | ; Prepend start bit + read opcode to the address field |
870 | ; Prepend start bit + read opcode to the address field |
871 | ; and shift it to the very left bits of esi |
871 | ; and shift it to the very left bits of esi |
872 | 872 | ||
873 | mov cl, 29 |
873 | mov cl, 29 |
874 | sub cl, [device.ee_bus_width] |
874 | sub cl, [device.ee_bus_width] |
875 | shl esi, cl |
875 | shl esi, cl |
876 | or esi, EE_READ shl 29 |
876 | or esi, EE_READ shl 29 |
877 | 877 | ||
878 | movzx ecx, [device.ee_bus_width] |
878 | movzx ecx, [device.ee_bus_width] |
879 | add ecx, 3 |
879 | add ecx, 3 |
880 | 880 | ||
881 | mov al, EE_CS |
881 | mov al, EE_CS |
882 | out dx, al |
882 | out dx, al |
883 | delay |
883 | delay |
884 | 884 | ||
885 | ;----------------------- |
885 | ;----------------------- |
886 | ; Write this to the chip |
886 | ; Write this to the chip |
887 | 887 | ||
888 | .loop: |
888 | .loop: |
889 | mov al, EE_CS + EE_SK |
889 | mov al, EE_CS + EE_SK |
890 | shl esi, 1 |
890 | shl esi, 1 |
891 | jnc @f |
891 | jnc @f |
892 | or al, EE_DI |
892 | or al, EE_DI |
893 | @@: |
893 | @@: |
894 | out dx, al |
894 | out dx, al |
895 | delay |
895 | delay |
896 | 896 | ||
897 | and al, not EE_SK |
897 | and al, not EE_SK |
898 | out dx, al |
898 | out dx, al |
899 | delay |
899 | delay |
900 | 900 | ||
901 | loop .loop |
901 | loop .loop |
902 | 902 | ||
903 | ;------------------------------ |
903 | ;------------------------------ |
904 | ; Now read the data from eeprom |
904 | ; Now read the data from eeprom |
905 | 905 | ||
906 | xor esi, esi |
906 | xor esi, esi |
907 | mov ecx, 16 |
907 | mov ecx, 16 |
908 | 908 | ||
909 | .loop2: |
909 | .loop2: |
910 | shl esi, 1 |
910 | shl esi, 1 |
911 | mov al, EE_CS + EE_SK |
911 | mov al, EE_CS + EE_SK |
912 | out dx, al |
912 | out dx, al |
913 | delay |
913 | delay |
914 | 914 | ||
915 | in al, dx |
915 | in al, dx |
916 | test al, EE_DO |
916 | test al, EE_DO |
917 | jz @f |
917 | jz @f |
918 | inc esi |
918 | inc esi |
919 | @@: |
919 | @@: |
920 | 920 | ||
921 | mov al, EE_CS |
921 | mov al, EE_CS |
922 | out dx, al |
922 | out dx, al |
923 | delay |
923 | delay |
924 | 924 | ||
925 | loop .loop2 |
925 | loop .loop2 |
926 | 926 | ||
927 | ;----------------------- |
927 | ;----------------------- |
928 | ; de-activate the eeprom |
928 | ; de-activate the eeprom |
929 | 929 | ||
930 | xor ax, ax |
930 | xor ax, ax |
931 | out dx, ax |
931 | out dx, ax |
932 | 932 | ||
933 | 933 | ||
934 | DEBUGF 1,"=0x%x\n", esi:4 |
934 | DEBUGF 1,"0x%x\n", esi:4 |
935 | ret |
935 | ret |
936 | 936 | ||
937 | 937 | ||
938 | 938 | ||
939 | align 4 |
939 | align 4 |
940 | ee_write: ; esi = address to write to, di = data |
940 | ee_write: ; esi = address to write to, di = data |
941 | 941 | ||
942 | DEBUGF 1,"Eeprom write 0x%x to 0x%x\n", di, esi |
942 | DEBUGF 1,"Eeprom write 0x%x to 0x%x\n", di, esi |
943 | 943 | ||
944 | set_io 0 |
944 | set_io 0 |
945 | set_io reg_eeprom |
945 | set_io reg_eeprom |
946 | 946 | ||
947 | ;----------------------------------------------------- |
947 | ;----------------------------------------------------- |
948 | ; Prepend start bit + write opcode to the address field |
948 | ; Prepend start bit + write opcode to the address field |
949 | ; and shift it to the very left bits of esi |
949 | ; and shift it to the very left bits of esi |
950 | 950 | ||
951 | mov cl, 29 |
951 | mov cl, 29 |
952 | sub cl, [device.ee_bus_width] |
952 | sub cl, [device.ee_bus_width] |
953 | shl esi, cl |
953 | shl esi, cl |
954 | or esi, EE_WRITE shl 29 |
954 | or esi, EE_WRITE shl 29 |
955 | 955 | ||
956 | movzx ecx, [device.ee_bus_width] |
956 | movzx ecx, [device.ee_bus_width] |
957 | add ecx, 3 |
957 | add ecx, 3 |
958 | 958 | ||
959 | mov al, EE_CS ; enable chip |
959 | mov al, EE_CS ; enable chip |
960 | out dx, al |
960 | out dx, al |
961 | 961 | ||
962 | ;----------------------- |
962 | ;----------------------- |
963 | ; Write this to the chip |
963 | ; Write this to the chip |
964 | 964 | ||
965 | .loop: |
965 | .loop: |
966 | mov al, EE_CS + EE_SK |
966 | mov al, EE_CS + EE_SK |
967 | shl esi, 1 |
967 | shl esi, 1 |
968 | jnc @f |
968 | jnc @f |
969 | or al, EE_DI |
969 | or al, EE_DI |
970 | @@: |
970 | @@: |
971 | out dx, al |
971 | out dx, al |
972 | delay |
972 | delay |
973 | 973 | ||
974 | and al, not EE_SK |
974 | and al, not EE_SK |
975 | out dx, al |
975 | out dx, al |
976 | delay |
976 | delay |
977 | 977 | ||
978 | loop .loop |
978 | loop .loop |
979 | 979 | ||
980 | ;----------------------------- |
980 | ;----------------------------- |
981 | ; Now write the data to eeprom |
981 | ; Now write the data to eeprom |
982 | 982 | ||
983 | mov ecx, 16 |
983 | mov ecx, 16 |
984 | 984 | ||
985 | .loop2: |
985 | .loop2: |
986 | mov al, EE_CS + EE_SK |
986 | mov al, EE_CS + EE_SK |
987 | shl di, 1 |
987 | shl di, 1 |
988 | jnc @f |
988 | jnc @f |
989 | or al, EE_DI |
989 | or al, EE_DI |
990 | @@: |
990 | @@: |
991 | out dx, al |
991 | out dx, al |
992 | delay |
992 | delay |
993 | 993 | ||
994 | and al, not EE_SK |
994 | and al, not EE_SK |
995 | out dx, al |
995 | out dx, al |
996 | delay |
996 | delay |
997 | 997 | ||
998 | loop .loop2 |
998 | loop .loop2 |
999 | 999 | ||
1000 | ;----------------------- |
1000 | ;----------------------- |
1001 | ; de-activate the eeprom |
1001 | ; de-activate the eeprom |
1002 | 1002 | ||
1003 | xor al, al |
1003 | xor al, al |
1004 | out dx, al |
1004 | out dx, al |
1005 | 1005 | ||
1006 | 1006 | ||
1007 | ret |
1007 | ret |
1008 | 1008 | ||
1009 | 1009 | ||
1010 | 1010 | ||
1011 | align 4 |
1011 | align 4 |
1012 | ee_get_width: |
1012 | ee_get_width: |
1013 | - | ||
1014 | ; DEBUGF 1,"Eeprom get width\n" |
- | |
1015 | 1013 | ||
1016 | set_io 0 |
1014 | set_io 0 |
1017 | set_io reg_eeprom |
1015 | set_io reg_eeprom |
1018 | 1016 | ||
1019 | mov al, EE_CS ; activate eeprom |
1017 | mov al, EE_CS ; activate eeprom |
1020 | out dx, al |
1018 | out dx, al |
1021 | delay |
1019 | delay |
1022 | 1020 | ||
1023 | mov si, EE_READ shl 13 |
1021 | mov si, EE_READ shl 13 |
1024 | xor ecx, ecx |
1022 | xor ecx, ecx |
1025 | .loop: |
1023 | .loop: |
1026 | mov al, EE_CS + EE_SK |
1024 | mov al, EE_CS + EE_SK |
1027 | shl si, 1 |
1025 | shl si, 1 |
1028 | jnc @f |
1026 | jnc @f |
1029 | or al, EE_DI |
1027 | or al, EE_DI |
1030 | @@: |
1028 | @@: |
1031 | out dx, al |
1029 | out dx, al |
1032 | delay |
1030 | delay |
1033 | 1031 | ||
1034 | and al, not EE_SK |
1032 | and al, not EE_SK |
1035 | out dx, al |
1033 | out dx, al |
1036 | delay |
1034 | delay |
1037 | 1035 | ||
1038 | inc ecx |
1036 | inc ecx |
1039 | 1037 | ||
1040 | cmp ecx, 15 |
1038 | cmp ecx, 15 |
1041 | jae .give_up |
1039 | jae .give_up |
1042 | 1040 | ||
1043 | in al, dx |
1041 | in al, dx |
1044 | test al, EE_DO |
1042 | test al, EE_DO |
1045 | jnz .loop |
1043 | jnz .loop |
1046 | - | ||
1047 | .give_up: |
1044 | |
1048 | xor al, al |
1045 | xor al, al |
1049 | out dx, al ; de-activate eeprom |
1046 | out dx, al ; de-activate eeprom |
1050 | 1047 | ||
1051 | sub cl, 3 ; dont count the opcode bits |
1048 | sub cl, 3 ; dont count the opcode bits |
1052 | - | ||
1053 | mov [device.ee_bus_width], cl |
1049 | mov [device.ee_bus_width], cl |
1054 | DEBUGF 1,"Eeprom width=%u bit\n", ecx |
1050 | DEBUGF 1, "Eeprom width=%u bit\n", ecx |
- | 1051 | ||
1055 | 1052 | ret |
|
1056 | 1053 | ||
1057 | ;----------------------- |
1054 | .give_up: |
1058 | ; de-activate the eeprom |
1055 | DEBUGF 2, "Eeprom not found!\n" |
1059 | 1056 | ||
1060 | xor eax, eax |
1057 | xor al, al |
1061 | out dx, eax |
1058 | out dx, al ; de-activate eeprom |
1062 | 1059 | ||
1063 | ret |
1060 | ret |
1064 | 1061 | ||
1065 | 1062 | ||
1066 | 1063 | ||
1067 | ; cx = phy addr |
1064 | ; cx = phy addr |
1068 | ; dx = phy reg addr |
1065 | ; dx = phy reg addr |
1069 | 1066 | ||
1070 | ; ax = data |
1067 | ; ax = data |
1071 | 1068 | ||
1072 | align 4 |
1069 | align 4 |
1073 | mdio_read: |
1070 | mdio_read: |
1074 | 1071 | ||
1075 | DEBUGF 1,"MDIO read\n" |
1072 | DEBUGF 1,"MDIO read\n" |
1076 | 1073 | ||
1077 | shl ecx, 21 ; PHY addr |
1074 | shl ecx, 21 ; PHY addr |
1078 | shl edx, 16 ; PHY reg addr |
1075 | shl edx, 16 ; PHY reg addr |
1079 | 1076 | ||
1080 | mov eax, ecx |
1077 | mov eax, ecx |
1081 | or eax, edx |
1078 | or eax, edx |
1082 | or eax, 10b shl 26 ; read opcode |
1079 | or eax, 10b shl 26 ; read opcode |
1083 | 1080 | ||
1084 | set_io 0 |
1081 | set_io 0 |
1085 | set_io reg_mdi_ctrl |
1082 | set_io reg_mdi_ctrl |
1086 | out dx, eax |
1083 | out dx, eax |
1087 | 1084 | ||
1088 | .wait: |
1085 | .wait: |
1089 | delay |
1086 | delay |
1090 | in eax, dx |
1087 | in eax, dx |
1091 | test eax, 1 shl 28 ; ready bit |
1088 | test eax, 1 shl 28 ; ready bit |
1092 | jz .wait |
1089 | jz .wait |
1093 | 1090 | ||
1094 | ret |
1091 | ret |
1095 | 1092 | ||
1096 | ; ax = data |
1093 | ; ax = data |
1097 | ; cx = phy addr |
1094 | ; cx = phy addr |
1098 | ; dx = phy reg addr |
1095 | ; dx = phy reg addr |
1099 | 1096 | ||
1100 | ; ax = data |
1097 | ; ax = data |
1101 | 1098 | ||
1102 | align 4 |
1099 | align 4 |
1103 | mdio_write: |
1100 | mdio_write: |
1104 | 1101 | ||
1105 | DEBUGF 1,"MDIO write\n" |
1102 | DEBUGF 1,"MDIO write\n" |
1106 | 1103 | ||
1107 | and eax, 0xffff |
1104 | and eax, 0xffff |
1108 | 1105 | ||
1109 | shl ecx, 21 ; PHY addr |
1106 | shl ecx, 21 ; PHY addr |
1110 | shl edx, 16 ; PHY reg addr |
1107 | shl edx, 16 ; PHY reg addr |
1111 | 1108 | ||
1112 | or eax, ecx |
1109 | or eax, ecx |
1113 | or eax, edx |
1110 | or eax, edx |
1114 | or eax, 01b shl 26 ; write opcode |
1111 | or eax, 01b shl 26 ; write opcode |
1115 | 1112 | ||
1116 | set_io 0 |
1113 | set_io 0 |
1117 | set_io reg_mdi_ctrl |
1114 | set_io reg_mdi_ctrl |
1118 | out dx, eax |
1115 | out dx, eax |
1119 | 1116 | ||
1120 | .wait: |
1117 | .wait: |
1121 | delay |
1118 | delay |
1122 | in eax, dx |
1119 | in eax, dx |
1123 | test eax, 1 shl 28 ; ready bit |
1120 | test eax, 1 shl 28 ; ready bit |
1124 | jz .wait |
1121 | jz .wait |
1125 | 1122 | ||
1126 | ret |
1123 | ret |
1127 | 1124 | ||
1128 | read_mac: |
1125 | read_mac: |
1129 | 1126 | ||
1130 | ret |
1127 | ret |
1131 | 1128 | ||
1132 | 1129 | ||
1133 | 1130 | ||
1134 | align 4 |
1131 | align 4 |
1135 | MAC_read_eeprom: |
1132 | MAC_read_eeprom: |
1136 | 1133 | ||
1137 | mov esi, 0 |
1134 | mov esi, 0 |
1138 | call ee_read |
1135 | call ee_read |
1139 | mov word[device.mac], si |
1136 | mov word[device.mac], si |
1140 | 1137 | ||
1141 | mov esi, 1 |
1138 | mov esi, 1 |
1142 | call ee_read |
1139 | call ee_read |
1143 | mov word[device.mac+2], si |
1140 | mov word[device.mac+2], si |
1144 | 1141 | ||
1145 | mov esi, 2 |
1142 | mov esi, 2 |
1146 | call ee_read |
1143 | call ee_read |
1147 | mov word[device.mac+4], si |
1144 | mov word[device.mac+4], si |
1148 | 1145 | ||
1149 | 1146 | ||
1150 | ret |
1147 | ret |
1151 | 1148 | ||
1152 | 1149 | ||
1153 | align 4 |
1150 | align 4 |
1154 | MAC_write: |
1151 | MAC_write: |
1155 | 1152 | ||
1156 | ;;;; |
1153 | ;;;; |
1157 | 1154 | ||
1158 | ret |
1155 | ret |
1159 | 1156 | ||
1160 | 1157 | ||
1161 | 1158 | ||
1162 | 1159 | ||
1163 | ; End of code |
1160 | ; End of code |
1164 | 1161 | ||
1165 | align 4 ; Place all initialised data here |
1162 | align 4 ; Place all initialised data here |
1166 | 1163 | ||
1167 | devices dd 0 ; number of currently running devices |
1164 | devices dd 0 ; number of currently running devices |
1168 | version dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF) |
1165 | version dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF) |
1169 | my_service db 'i8255x', 0 ; max 16 chars include zero |
1166 | my_service db 'i8255x', 0 ; max 16 chars include zero |
1170 | devicename db 'Intel Etherexpress pro/100', 0 |
1167 | devicename db 'Intel Etherexpress pro/100', 0 |
1171 | 1168 | ||
1172 | confcmd_data db 22, 0x08, 0, 0, 0, 0x80, 0x32, 0x03, 1 |
1169 | confcmd_data db 22, 0x08, 0, 0, 0, 0x80, 0x32, 0x03, 1 |
1173 | db 0, 0x2e, 0, 0x60, 0, 0xf2, 0x48, 0, 0x40, 0xf2 |
1170 | db 0, 0x2e, 0, 0x60, 0, 0xf2, 0x48, 0, 0x40, 0xf2 |
1174 | db 0x80, 0x3f, 0x05 ; 22 bytes total |
1171 | db 0x80, 0x3f, 0x05 ; 22 bytes total |
1175 | 1172 | ||
1176 | 1173 | ||
1177 | device_id_list: |
1174 | device_id_list: |
1178 | 1175 | ||
1179 | dw 0x1029 |
1176 | dw 0x1029 |
1180 | dw 0x1030 |
1177 | dw 0x1030 |
1181 | dw 0x1031 |
1178 | dw 0x1031 |
1182 | dw 0x1032 |
1179 | dw 0x1032 |
1183 | dw 0x1033 |
1180 | dw 0x1033 |
1184 | dw 0x1034 |
1181 | dw 0x1034 |
1185 | dw 0x1038 |
1182 | dw 0x1038 |
1186 | dw 0x1039 |
1183 | dw 0x1039 |
1187 | dw 0x103A |
1184 | dw 0x103A |
1188 | dw 0x103B |
1185 | dw 0x103B |
1189 | dw 0x103C |
1186 | dw 0x103C |
1190 | dw 0x103D |
1187 | dw 0x103D |
1191 | dw 0x103E |
1188 | dw 0x103E |
1192 | dw 0x1050 |
1189 | dw 0x1050 |
1193 | dw 0x1051 |
1190 | dw 0x1051 |
1194 | dw 0x1052 |
1191 | dw 0x1052 |
1195 | dw 0x1053 |
1192 | dw 0x1053 |
1196 | dw 0x1054 |
1193 | dw 0x1054 |
1197 | dw 0x1055 |
1194 | dw 0x1055 |
1198 | dw 0x1056 |
1195 | dw 0x1056 |
1199 | dw 0x1057 |
1196 | dw 0x1057 |
1200 | dw 0x1059 |
1197 | dw 0x1059 |
1201 | dw 0x1064 |
1198 | dw 0x1064 |
1202 | dw 0x1065 |
1199 | dw 0x1065 |
1203 | dw 0x1066 |
1200 | dw 0x1066 |
1204 | dw 0x1067 |
1201 | dw 0x1067 |
1205 | dw 0x1068 |
1202 | dw 0x1068 |
1206 | dw 0x1069 |
1203 | dw 0x1069 |
1207 | dw 0x106A |
1204 | dw 0x106A |
1208 | dw 0x106B |
1205 | dw 0x106B |
1209 | dw 0x1091 |
1206 | dw 0x1091 |
1210 | dw 0x1092 |
1207 | dw 0x1092 |
1211 | dw 0x1093 |
1208 | dw 0x1093 |
1212 | dw 0x1094 |
1209 | dw 0x1094 |
1213 | dw 0x1095 |
1210 | dw 0x1095 |
1214 | dw 0x10fe |
1211 | dw 0x10fe |
1215 | dw 0x1209 |
1212 | dw 0x1209 |
1216 | dw 0x1229 |
1213 | dw 0x1229 |
1217 | dw 0x2449 |
1214 | dw 0x2449 |
1218 | dw 0x2459 |
1215 | dw 0x2459 |
1219 | dw 0x245D |
1216 | dw 0x245D |
1220 | dw 0x27DC |
1217 | dw 0x27DC |
1221 | 1218 | ||
1222 | DEVICE_IDs = ($ - device_id_list) / 2 |
1219 | DEVICE_IDs = ($ - device_id_list) / 2 |
1223 | 1220 | ||
1224 | mac_82557_D100_A = 0 |
1221 | mac_82557_D100_A = 0 |
1225 | mac_82557_D100_B = 1 |
1222 | mac_82557_D100_B = 1 |
1226 | mac_82557_D100_C = 2 |
1223 | mac_82557_D100_C = 2 |
1227 | mac_82558_D101_A4 = 4 |
1224 | mac_82558_D101_A4 = 4 |
1228 | mac_82558_D101_B0 = 5 |
1225 | mac_82558_D101_B0 = 5 |
1229 | mac_82559_D101M = 8 |
1226 | mac_82559_D101M = 8 |
1230 | mac_82559_D101S = 9 |
1227 | mac_82559_D101S = 9 |
1231 | mac_82550_D102 = 12 |
1228 | mac_82550_D102 = 12 |
1232 | mac_82550_D102_C = 13 |
1229 | mac_82550_D102_C = 13 |
1233 | mac_82551_E = 14 |
1230 | mac_82551_E = 14 |
1234 | mac_82551_F = 15 |
1231 | mac_82551_F = 15 |
1235 | mac_82551_10 = 16 |
1232 | mac_82551_10 = 16 |
1236 | mac_unknown = 0xFF |
1233 | mac_unknown = 0xFF |
1237 | 1234 | ||
1238 | phy_100a = 0x000003E0 |
1235 | phy_100a = 0x000003E0 |
1239 | phy_100c = 0x035002A8 |
1236 | phy_100c = 0x035002A8 |
1240 | phy_82555_tx = 0x015002A8 |
1237 | phy_82555_tx = 0x015002A8 |
1241 | phy_nsc_tx = 0x5C002000 |
1238 | phy_nsc_tx = 0x5C002000 |
1242 | phy_82562_et = 0x033002A8 |
1239 | phy_82562_et = 0x033002A8 |
1243 | phy_82562_em = 0x032002A8 |
1240 | phy_82562_em = 0x032002A8 |
1244 | phy_82562_ek = 0x031002A8 |
1241 | phy_82562_ek = 0x031002A8 |
1245 | phy_82562_eh = 0x017002A8 |
1242 | phy_82562_eh = 0x017002A8 |
1246 | phy_82552_v = 0xd061004d |
1243 | phy_82552_v = 0xd061004d |
1247 | phy_unknown = 0xFFFFFFFF |
1244 | phy_unknown = 0xFFFFFFFF |
1248 | 1245 | ||
1249 | 1246 | ||
1250 | include_debug_strings ; All data wich FDO uses will be included here |
1247 | include_debug_strings ; All data wich FDO uses will be included here |
1251 | 1248 | ||
1252 | section '.data' data readable writable align 16 ; place all uninitialized data place here |
1249 | section '.data' data readable writable align 16 ; place all uninitialized data place here |
1253 | 1250 | ||
1254 | device_list rd MAX_DEVICES ; This list contains all pointers to device structures the driver is handling |
1251 | device_list rd MAX_DEVICES ; This list contains all pointers to device structures the driver is handling |