BCM57XX: Update template

git-svn-id: svn://kolibrios.org@9159 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2021-08-28 09:56:53 +00:00
parent d297ba3894
commit 397acfbb0a

View File

@ -1,11 +1,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Broadcom NetXtreme 57xx driver for KolibriOS ;; ;; Broadcom NetXtreme 57xx driver for KolibriOS ;;
;; ;; ;; ;;
;; ;;
;; GNU GENERAL PUBLIC LICENSE ;; ;; GNU GENERAL PUBLIC LICENSE ;;
;; Version 2, June 1991 ;; ;; Version 2, June 1991 ;;
;; ;; ;; ;;
@ -21,11 +20,18 @@ entry START
COMPATIBLE_API = 0x0100 COMPATIBLE_API = 0x0100
API_VERSION = (COMPATIBLE_API shl 16) + CURRENT_API API_VERSION = (COMPATIBLE_API shl 16) + CURRENT_API
; configureable area
MAX_DEVICES = 16 MAX_DEVICES = 16
__DEBUG__ = 1 __DEBUG__ = 1
__DEBUG_LEVEL__ = 2 __DEBUG_LEVEL__ = 2
TX_RING_SIZE = 128 ; Number of packets in send ring buffer
RX_RING_SIZE = 128 ; Number of packets in receive ring buffer
; end configureable area
section '.flat' readable writable executable section '.flat' readable writable executable
include '../proc32.inc' include '../proc32.inc'
@ -34,6 +40,16 @@ include '../macros.inc'
include '../fdo.inc' include '../fdo.inc'
include '../netdrv.inc' include '../netdrv.inc'
if (bsr TX_RING_SIZE)>(bsf TX_RING_SIZE)
display 'TX_RING_SIZE must be a power of two'
err
end if
if (bsr RX_RING_SIZE)>(bsf RX_RING_SIZE)
display 'RX_RING_SIZE must be a power of two'
err
end if
struct device ETH_DEVICE struct device ETH_DEVICE
mmio_addr dd ? mmio_addr dd ?
@ -251,15 +267,11 @@ probe:
; Make the device a bus master ; Make the device a bus master
invoke PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command invoke PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command
or al, PCI_CMD_MASTER or al, PCI_CMD_MASTER + PCI_CMD_MMIO + PCI_CMD_PIO
invoke PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax invoke PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax
; TODO: validate the device ; TODO: validate the device
reset: reset:
DEBUGF 1,"Reset\n" DEBUGF 1,"Reset\n"
@ -308,16 +320,14 @@ read_mac:
;; ;; ;; ;;
;; Transmit ;; ;; Transmit ;;
;; ;; ;; ;;
;; In: buffer pointer in [esp+4] ;; ;; In: pointer to device structure in ebx ;;
;; size of buffer in [esp+8] ;; ;; Out: eax = 0 on success ;;
;; pointer to device structure in ebx ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 16
proc transmit stdcall bufferptr, buffersize proc transmit stdcall bufferptr, buffersize
pushf spin_lock_irqsave
cli
DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize] DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize]
mov eax, [bufferptr] mov eax, [bufferptr]
@ -327,13 +337,16 @@ proc transmit stdcall bufferptr, buffersize
[eax+13]:2,[eax+12]:2 [eax+13]:2,[eax+12]:2
cmp [buffersize], 1514 cmp [buffersize], 1514
ja .fail ja .error
cmp [buffersize], 60 cmp [buffersize], 60
jb .fail jb .error
; Program the descriptor
; test [something], STILL_BUSY?
; jnz .overrun
; TODO: Program the descriptor
; Update stats ; Update stats
inc [ebx + device.packets_tx] inc [ebx + device.packets_tx]
@ -342,14 +355,25 @@ proc transmit stdcall bufferptr, buffersize
adc dword[ebx + device.bytes_tx + 4], 0 adc dword[ebx + device.bytes_tx + 4], 0
DEBUGF 1,"Transmit OK\n" DEBUGF 1,"Transmit OK\n"
popf spin_unlock_irqrestore
xor eax, eax xor eax, eax
ret ret
.fail: .error:
DEBUGF 2,"Transmit failed\n" DEBUGF 2, "TX packet error\n"
invoke KernelFree, [bufferptr] inc [ebx + device.packets_tx_err]
popf invoke NetFree, [bufferptr]
spin_unlock_irqrestore
or eax, -1
ret
.overrun:
DEBUGF 2, "TX overrun\n"
inc [ebx + device.packets_tx_ovr]
invoke NetFree, [bufferptr]
spin_unlock_irqrestore
or eax, -1 or eax, -1
ret ret
@ -361,40 +385,24 @@ endp
;; Interrupt handler ;; ;; Interrupt handler ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;
align 16
align 4
int_handler: int_handler:
push ebx esi edi push ebx esi edi
DEBUGF 1,"INT\n" mov ebx, [esp+4*4]
;------------------------------------------- DEBUGF 1,"INT for 0x%x\n", ebx
; Find pointer of device wich made IRQ occur
mov ecx, [devices] ; TODO? if we are paranoid, we can check that the value from ebx is present in the current device_list
test ecx, ecx
jz .nothing
mov esi, device_list
.nextdevice:
mov ebx, [esi]
; mov edi, [ebx + device.mmio_addr] mov edi, [ebx + device.mmio_addr]
; mov eax, [edi + REG_ICR] ; mov eax, [edi + REG_ICR]
test eax, eax test eax, eax
jnz .got_it jz .nothing
.continue:
add esi, 4
dec ecx
jnz .nextdevice
.nothing:
pop edi esi ebx
xor eax, eax
ret DEBUGF 1,"Status: %x ", eax
.got_it: ; TODO: handle interrupts
DEBUGF 1,"Device: %x Status: %x ", ebx, eax
pop edi esi ebx pop edi esi ebx
xor eax, eax xor eax, eax
@ -402,6 +410,12 @@ int_handler:
ret ret
.nothing:
pop edi esi ebx
xor eax, eax
ret