Rev 7251 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7251 | Rev 9159 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2021. 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 | ;; Broadcom NetXtreme 57xx driver for KolibriOS ;; |
6 | ;; Broadcom NetXtreme 57xx driver for KolibriOS ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; ;; |
- | |
9 | ;; GNU GENERAL PUBLIC LICENSE ;; |
8 | ;; GNU GENERAL PUBLIC LICENSE ;; |
10 | ;; Version 2, June 1991 ;; |
9 | ;; Version 2, June 1991 ;; |
11 | ;; ;; |
10 | ;; ;; |
12 | ;; Broadcom's programmers's manual for the BCM57xx ;; |
11 | ;; Broadcom's programmers's manual for the BCM57xx ;; |
13 | ;; http://www.broadcom.com/collateral/pg/57XX-PG105-R.pdf ;; |
12 | ;; http://www.broadcom.com/collateral/pg/57XX-PG105-R.pdf ;; |
Line 19... | Line 18... | ||
19 | 18 | ||
20 | CURRENT_API = 0x0200 |
19 | CURRENT_API = 0x0200 |
21 | COMPATIBLE_API = 0x0100 |
20 | COMPATIBLE_API = 0x0100 |
Line -... | Line 21... | ||
- | 21 | API_VERSION = (COMPATIBLE_API shl 16) + CURRENT_API |
|
- | 22 | ||
22 | API_VERSION = (COMPATIBLE_API shl 16) + CURRENT_API |
23 | ; configureable area |
Line 23... | Line 24... | ||
23 | 24 | ||
24 | MAX_DEVICES = 16 |
25 | MAX_DEVICES = 16 |
Line -... | Line 26... | ||
- | 26 | ||
- | 27 | __DEBUG__ = 1 |
|
- | 28 | __DEBUG_LEVEL__ = 2 |
|
- | 29 | ||
- | 30 | TX_RING_SIZE = 128 ; Number of packets in send ring buffer |
|
25 | 31 | RX_RING_SIZE = 128 ; Number of packets in receive ring buffer |
|
Line 26... | Line 32... | ||
26 | __DEBUG__ = 1 |
32 | |
27 | __DEBUG_LEVEL__ = 2 |
33 | ; end configureable area |
28 | 34 | ||
29 | section '.flat' readable writable executable |
35 | section '.flat' readable writable executable |
30 | 36 | ||
Line -... | Line 37... | ||
- | 37 | include '../proc32.inc' |
|
- | 38 | include '../struct.inc' |
|
- | 39 | include '../macros.inc' |
|
- | 40 | include '../fdo.inc' |
|
- | 41 | include '../netdrv.inc' |
|
- | 42 | ||
- | 43 | if (bsr TX_RING_SIZE)>(bsf TX_RING_SIZE) |
|
- | 44 | display 'TX_RING_SIZE must be a power of two' |
|
- | 45 | err |
|
- | 46 | end if |
|
31 | include '../proc32.inc' |
47 | |
Line 32... | Line 48... | ||
32 | include '../struct.inc' |
48 | if (bsr RX_RING_SIZE)>(bsf RX_RING_SIZE) |
33 | include '../macros.inc' |
49 | display 'RX_RING_SIZE must be a power of two' |
34 | include '../fdo.inc' |
50 | err |
Line 249... | Line 265... | ||
249 | 265 | ||
Line 250... | Line 266... | ||
250 | DEBUGF 1,"Probe\n" |
266 | DEBUGF 1,"Probe\n" |
251 | 267 | ||
252 | ; Make the device a bus master |
268 | ; Make the device a bus master |
253 | invoke PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command |
269 | invoke PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command |
Line 254... | Line -... | ||
254 | or al, PCI_CMD_MASTER |
- | |
255 | invoke PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax |
270 | or al, PCI_CMD_MASTER + PCI_CMD_MMIO + PCI_CMD_PIO |
Line 256... | Line -... | ||
256 | - | ||
257 | - | ||
258 | ; TODO: validate the device |
- | |
259 | 271 | invoke PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax |
|
Line 260... | Line 272... | ||
260 | 272 | ||
Line 261... | Line 273... | ||
261 | 273 | ; TODO: validate the device |
|
Line 306... | Line 318... | ||
306 | 318 | ||
307 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
319 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
308 | ;; ;; |
320 | ;; ;; |
309 | ;; Transmit ;; |
321 | ;; Transmit ;; |
310 | ;; ;; |
322 | ;; ;; |
311 | ;; In: buffer pointer in [esp+4] ;; |
323 | ;; In: pointer to device structure in ebx ;; |
312 | ;; size of buffer in [esp+8] ;; |
- | |
313 | ;; pointer to device structure in ebx ;; |
324 | ;; Out: eax = 0 on success ;; |
314 | ;; ;; |
325 | ;; ;; |
315 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
326 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
316 | 327 | align 16 |
|
Line 317... | Line 328... | ||
317 | proc transmit stdcall bufferptr, buffersize |
328 | proc transmit stdcall bufferptr, buffersize |
318 | - | ||
Line 319... | Line 329... | ||
319 | pushf |
329 | |
320 | cli |
330 | spin_lock_irqsave |
321 | 331 | ||
322 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize] |
332 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize] |
323 | mov eax, [bufferptr] |
333 | mov eax, [bufferptr] |
324 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
334 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
Line 325... | Line 335... | ||
325 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
335 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
326 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
336 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
327 | [eax+13]:2,[eax+12]:2 |
337 | [eax+13]:2,[eax+12]:2 |
328 | 338 | ||
329 | cmp [buffersize], 1514 |
- | |
Line -... | Line 339... | ||
- | 339 | cmp [buffersize], 1514 |
|
Line -... | Line 340... | ||
- | 340 | ja .error |
|
- | 341 | cmp [buffersize], 60 |
|
Line -... | Line 342... | ||
- | 342 | jb .error |
|
Line 330... | Line 343... | ||
330 | ja .fail |
343 | |
331 | cmp [buffersize], 60 |
344 | ; Program the descriptor |
332 | jb .fail |
345 | |
333 | 346 | ; test [something], STILL_BUSY? |
|
334 | 347 | ; jnz .overrun |
|
Line 335... | Line 348... | ||
335 | 348 | ||
336 | 349 | ; TODO: Program the descriptor |
|
337 | 350 | ||
338 | ; Update stats |
351 | ; Update stats |
Line 339... | Line 352... | ||
339 | inc [ebx + device.packets_tx] |
352 | inc [ebx + device.packets_tx] |
340 | mov eax, [buffersize] |
353 | mov eax, [buffersize] |
- | 354 | add dword[ebx + device.bytes_tx], eax |
|
341 | add dword[ebx + device.bytes_tx], eax |
355 | adc dword[ebx + device.bytes_tx + 4], 0 |
- | 356 | ||
- | 357 | DEBUGF 1,"Transmit OK\n" |
|
- | 358 | spin_unlock_irqrestore |
|
342 | adc dword[ebx + device.bytes_tx + 4], 0 |
359 | xor eax, eax |
- | 360 | ret |
|
- | 361 | ||
- | 362 | .error: |
|
- | 363 | DEBUGF 2, "TX packet error\n" |
|
- | 364 | inc [ebx + device.packets_tx_err] |
|
- | 365 | invoke NetFree, [bufferptr] |
|
- | 366 | ||
343 | 367 | spin_unlock_irqrestore |
|
344 | DEBUGF 1,"Transmit OK\n" |
368 | or eax, -1 |
Line 345... | Line 369... | ||
345 | popf |
369 | ret |
Line 359... | Line 383... | ||
359 | ;;;;;;;;;;;;;;;;;;;;;;; |
383 | ;;;;;;;;;;;;;;;;;;;;;;; |
360 | ;; ;; |
384 | ;; ;; |
361 | ;; Interrupt handler ;; |
385 | ;; Interrupt handler ;; |
362 | ;; ;; |
386 | ;; ;; |
363 | ;;;;;;;;;;;;;;;;;;;;;;; |
387 | ;;;;;;;;;;;;;;;;;;;;;;; |
364 | - | ||
365 | align 4 |
388 | align 16 |
366 | int_handler: |
389 | int_handler: |
Line 367... | Line 390... | ||
367 | 390 | ||
Line 368... | Line 391... | ||
368 | push ebx esi edi |
391 | push ebx esi edi |
369 | - | ||
370 | DEBUGF 1,"INT\n" |
392 | |
Line 371... | Line -... | ||
371 | ;------------------------------------------- |
- | |
372 | ; Find pointer of device wich made IRQ occur |
- | |
373 | - | ||
374 | mov ecx, [devices] |
393 | mov ebx, [esp+4*4] |
375 | test ecx, ecx |
- | |
376 | jz .nothing |
- | |
Line 377... | Line 394... | ||
377 | mov esi, device_list |
394 | DEBUGF 1,"INT for 0x%x\n", ebx |
378 | .nextdevice: |
395 | |
379 | mov ebx, [esi] |
396 | ; TODO? if we are paranoid, we can check that the value from ebx is present in the current device_list |
380 | 397 | ||
381 | ; mov edi, [ebx + device.mmio_addr] |
398 | mov edi, [ebx + device.mmio_addr] |
382 | ; mov eax, [edi + REG_ICR] |
- | |
383 | test eax, eax |
399 | ; mov eax, [edi + REG_ICR] |
- | 400 | test eax, eax |
|
384 | jnz .got_it |
401 | jz .nothing |
385 | .continue: |
402 | |
386 | add esi, 4 |
403 | DEBUGF 1,"Status: %x ", eax |
387 | dec ecx |
404 | |
- | 405 | ; TODO: handle interrupts |
|
Line 388... | Line 406... | ||
388 | jnz .nextdevice |
406 | |
Line 389... | Line 407... | ||
389 | .nothing: |
407 | pop edi esi ebx |
390 | pop edi esi ebx |
- | |
391 | xor eax, eax |
- | |
392 | - | ||
393 | ret |
408 | xor eax, eax |
394 | 409 | inc eax |
|
395 | .got_it: |
- | |
Line 396... | Line 410... | ||
396 | 410 |