Some cleanup in rtl8169 driver

git-svn-id: svn://kolibrios.org@2916 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-08-09 14:35:51 +00:00
parent 24d344231c
commit 3b724316fb

View File

@ -144,16 +144,16 @@ public version
PHY_Restart_Auto_Nego = 0x0200
PHY_Enable_Auto_Nego = 0x1000
; PHY_STAT_REG = 1;
; PHY_STAT_REG = 1
PHY_Auto_Neco_Comp = 0x0020
; PHY_AUTO_NEGO_REG = 4;
; PHY_AUTO_NEGO_REG = 4
PHY_Cap_10_Half = 0x0020
PHY_Cap_10_Full = 0x0040
PHY_Cap_100_Half = 0x0080
PHY_Cap_100_Full = 0x0100
; PHY_1000_CTRL_REG = 9;
; PHY_1000_CTRL_REG = 9
PHY_Cap_1000_Full = 0x0200
PHY_Cap_1000_Half = 0x0100
@ -180,15 +180,6 @@ public version
RX_BUF_SIZE = 1536 ; Rx Buffer size
ETH_ALEN = 6
ETH_HLEN = (2 * ETH_ALEN + 2)
ETH_ZLEN = 60 ; 60 + 4bytes auto payload for
; mininmum 64bytes frame length
; MAC address length
MAC_ADDR_LEN = 6
; max supported gigabit ethernet frame size -- must be at least (dev->mtu+14+4)
MAX_ETH_FRAME_SIZE = 1536
@ -215,12 +206,12 @@ DEFAULT_MTU = 1500
DEFAULT_RX_BUF_LEN = 1536
;#ifdef JUMBO_FRAME_SUPPORT
;#define MAX_JUMBO_FRAME_MTU ( 10000 )
;#define MAX_RX_SKBDATA_SIZE ( MAX_JUMBO_FRAME_MTU + ETH_HDR_LEN )
;#else
;ifdef JUMBO_FRAME_SUPPORT
; MAX_JUMBO_FRAME_MTU = 10000
; MAX_RX_SKBDATA_SIZE = (MAX_JUMBO_FRAME_MTU + ETH_HDR_LEN )
;else
MAX_RX_SKBDATA_SIZE = 1600
;#endif //end #ifdef JUMBO_FRAME_SUPPORT
;end if
MCFG_METHOD_01 = 0x01
MCFG_METHOD_02 = 0x02
@ -268,6 +259,12 @@ virtual at ebx
.pci_dev db ?
.irq_line db ?
rb 256-(($ - device) and 255) ; align 256
.tx_ring rb NUM_TX_DESC * tx_desc.size * 2
rb 256-(($ - device) and 255) ; align 256
.rx_ring rb NUM_RX_DESC * rx_desc.size * 2
tpc:
.mmio_addr dd ? ; memory map physical address
.chipset dd ?
@ -280,12 +277,6 @@ virtual at ebx
.TxDescArray dd ? ; Index of 256-alignment Tx Descriptor buffer
.RxDescArray dd ? ; Index of 256-alignment Rx Descriptor buffer
rb 256-(($ - device) and 255) ; align 256
tx_ring rb NUM_TX_DESC * tx_desc.size * 2
rb 256-(($ - device) and 255) ; align 256
rx_ring rb NUM_RX_DESC * rx_desc.size * 2
device_size = $ - device
end virtual
@ -374,7 +365,7 @@ proc START stdcall, state:dword
.entry:
DEBUGF 2,"Loading rtl8169 driver\n"
DEBUGF 2,"Loading %s driver\n", my_service
stdcall RegService, my_service, service_proc
ret
@ -488,7 +479,6 @@ proc service_proc stdcall, ioctl:dword
test eax, eax
jnz .err2 ; If an error occured, exit
mov [device.type], NET_TYPE_ETH
call NetRegDev
@ -517,8 +507,6 @@ proc service_proc stdcall, ioctl:dword
.err:
DEBUGF 2,"removing device structure\n"
stdcall KernelFree, ebx
.fail:
or eax, -1
ret
@ -626,9 +614,7 @@ probe:
DEBUGF 1,"probe\n"
call init_board
call read_mac
call PHY_config
; DEBUGF 1,"K : Set MAC Reg C+CR Offset 0x82h = 0x01h\n"
@ -701,11 +687,11 @@ reset:
DEBUGF 1,"reset\n"
lea eax, [tx_ring]
lea eax, [device.tx_ring]
mov [tpc.TxDescArrays], eax
mov [tpc.TxDescArray], eax
lea eax, [rx_ring]
lea eax, [device.rx_ring]
mov [tpc.RxDescArrays], eax
mov [tpc.RxDescArray], eax
@ -834,11 +820,11 @@ init_ring:
mov [tpc.cur_rx], eax
mov [tpc.cur_tx], eax
lea edi, [tx_ring]
lea edi, [device.tx_ring]
mov ecx, (NUM_TX_DESC * tx_desc.size) / 4
rep stosd
lea edi, [rx_ring]
lea edi, [device.rx_ring]
mov ecx, (NUM_RX_DESC * rx_desc.size) / 4
rep stosd
@ -875,6 +861,7 @@ hw_start:
mov al, CMD_Reset
out dx, al
DEBUGF 1,"Waiting for chip to reset... "
; Check that the chip has finished the reset
mov ecx, 1000
set_io REG_ChipCmd
@ -884,6 +871,7 @@ hw_start:
udelay 10
loop @b
@@:
DEBUGF 1,"done!\n"
set_io REG_Cfg9346
mov al, CFG_9346_Unlock
@ -946,12 +934,12 @@ hw_start:
xor eax, eax
mov [tpc.cur_rx], eax
lea eax, [tx_ring]
lea eax, [device.tx_ring]
GetRealAddr
set_io REG_TxDescStartAddr
out dx, eax
lea eax, [rx_ring]
lea eax, [device.rx_ring]
GetRealAddr
set_io REG_RxDescStartAddr
out dx, eax
@ -991,7 +979,7 @@ read_mac:
set_io REG_MAC0
xor ecx, ecx
lea edi, [device.mac]
mov ecx, MAC_ADDR_LEN
mov ecx, 6
; Get MAC address. FIXME: read EEPROM
@@: in al, dx
@ -999,7 +987,8 @@ read_mac:
inc edx
loop @r
DEBUGF 1,"MAC = %x-%x-%x-%x-%x-%x\n",[device.mac+0]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2
DEBUGF 1,"MAC = %x-%x-%x-%x-%x-%x\n",\
[device.mac+0]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2
ret
@ -1040,7 +1029,7 @@ transmit:
mov eax, tx_desc.size
mul [tpc.cur_tx]
lea esi, [eax + tx_ring]
lea esi, [eax + device.tx_ring]
DEBUGF 1,"Using TX desc: %x\n", esi
@ -1151,7 +1140,7 @@ int_handler:
DEBUGF 1,"ebx = 0x%x\n", ebx
mov eax, rx_desc.size
mul [tpc.cur_rx]
lea esi, [eax + rx_ring]
lea esi, [eax + device.rx_ring]
DEBUGF 1,"RxDesc.status = 0x%x\n", [esi + rx_desc.status]
@ -1219,7 +1208,7 @@ int_handler:
DEBUGF 1,"TX ok!\n"
mov ecx, NUM_TX_DESC
lea esi, [tx_ring]
lea esi, [device.tx_ring]
.txloop:
cmp [esi + tx_desc.buf_soft_addr], 0
jz .maybenext