forked from KolibriOS/kolibrios
R6040: replaced some magic numbers with constants, small bugfixes.
git-svn-id: svn://kolibrios.org@4450 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
6e9baa9c88
commit
783026b4b8
@ -198,7 +198,7 @@ virtual at ebx
|
|||||||
.cur_rx dw ?
|
.cur_rx dw ?
|
||||||
.cur_tx dw ?
|
.cur_tx dw ?
|
||||||
.last_tx dw ?
|
.last_tx dw ?
|
||||||
.phy_addr dw ?
|
.phy_addr dd ?
|
||||||
.phy_mode dw ?
|
.phy_mode dw ?
|
||||||
.mcr0 dw ?
|
.mcr0 dw ?
|
||||||
.mcr1 dw ?
|
.mcr1 dw ?
|
||||||
@ -208,7 +208,7 @@ virtual at ebx
|
|||||||
.pci_dev dd ?
|
.pci_dev dd ?
|
||||||
.irq_line db ?
|
.irq_line db ?
|
||||||
|
|
||||||
rb 3 ; dword alignment
|
rb 1 ; dword alignment
|
||||||
|
|
||||||
.tx_ring: rb (((x_head.sizeof*TX_RING_SIZE)+32) and 0xfffffff0)
|
.tx_ring: rb (((x_head.sizeof*TX_RING_SIZE)+32) and 0xfffffff0)
|
||||||
.rx_ring: rb (((x_head.sizeof*RX_RING_SIZE)+32) and 0xfffffff0)
|
.rx_ring: rb (((x_head.sizeof*RX_RING_SIZE)+32) and 0xfffffff0)
|
||||||
@ -395,13 +395,15 @@ endp
|
|||||||
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
|
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
|
||||||
|
|
||||||
|
|
||||||
macro mdio_write reg, val {
|
;mdio_read:
|
||||||
stdcall phy_read, [device.io_addr], [device.phy_addr], reg
|
; stdcall phy_read, [device.io_addr], [device.phy_addr], ecx
|
||||||
}
|
|
||||||
|
|
||||||
macro mdio_write reg, val {
|
; ret
|
||||||
stdcall phy_write, [device.io_addr], [devce.phy_addr], reg, val
|
|
||||||
}
|
;mdio_write:
|
||||||
|
; stdcall phy_write, [device.io_addr], [device.phy_addr], ecx, eax
|
||||||
|
|
||||||
|
; ret
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
@ -421,7 +423,7 @@ ret
|
|||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;
|
;;
|
||||||
;; probe: enables the device (if it really is RTL8139)
|
;; probe: enables the device (if it really is R6040)
|
||||||
;;
|
;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
@ -455,14 +457,14 @@ probe:
|
|||||||
@@:
|
@@:
|
||||||
; Init RDC private data
|
; Init RDC private data
|
||||||
mov [device.mcr0], MCR0_XMTEN or MCR0_RCVEN
|
mov [device.mcr0], MCR0_XMTEN or MCR0_RCVEN
|
||||||
;mov [private.phy_addr], 1 ; Asper: Only one network card is supported now.
|
mov [device.phy_addr], PHY1_ADDR
|
||||||
mov [device.switch_sig], 0
|
mov [device.switch_sig], 0
|
||||||
|
|
||||||
; Check the vendor ID on the PHY, if 0xFFFF assume none attached
|
; Check the vendor ID on the PHY, if 0xFFFF assume none attached
|
||||||
stdcall phy_read, 1, 2
|
stdcall phy_read, [device.phy_addr], 2
|
||||||
cmp ax, 0xFFFF
|
cmp ax, 0xFFFF
|
||||||
jne @f
|
jne @f
|
||||||
DEBUGF 2, "Failed to detect an attached PHY\n" ;, generating random"
|
DEBUGF 2, "Failed to detect an attached PHY!\n"
|
||||||
mov eax, -1
|
mov eax, -1
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
@ -485,9 +487,8 @@ probe:
|
|||||||
@@:
|
@@:
|
||||||
|
|
||||||
; PHY Mode Check
|
; PHY Mode Check
|
||||||
movzx eax, [device.phy_addr]
|
stdcall phy_write, [device.phy_addr], 4, PHY_CAP
|
||||||
stdcall phy_write, eax, 4, PHY_CAP
|
stdcall phy_write, [device.phy_addr], 0, PHY_MODE
|
||||||
stdcall phy_write, eax, 0, PHY_MODE
|
|
||||||
|
|
||||||
if PHY_MODE = 0x3100
|
if PHY_MODE = 0x3100
|
||||||
call phy_mode_chk
|
call phy_mode_chk
|
||||||
@ -712,32 +713,26 @@ phy_mode_chk:
|
|||||||
DEBUGF 1,"Checking PHY mode\n"
|
DEBUGF 1,"Checking PHY mode\n"
|
||||||
|
|
||||||
; PHY Link Status Check
|
; PHY Link Status Check
|
||||||
movzx eax, [device.phy_addr]
|
stdcall phy_read, [device.phy_addr], MII_BMSR
|
||||||
stdcall phy_read, eax, 1
|
test ax, BMSR_LSTATUS
|
||||||
test eax, 0x4
|
|
||||||
jz .ret_0x8000
|
jz .ret_0x8000
|
||||||
|
|
||||||
; PHY Chip Auto-Negotiation Status
|
; PHY Chip Auto-Negotiation Status
|
||||||
movzx eax, [device.phy_addr]
|
test ax, BMSR_ANEGCOMPLETE
|
||||||
stdcall phy_read, eax, 1
|
|
||||||
test eax, 0x0020
|
|
||||||
jnz .auto_nego
|
jnz .auto_nego
|
||||||
|
|
||||||
; Force Mode
|
; Force Mode
|
||||||
movzx eax, [device.phy_addr]
|
stdcall phy_read, [device.phy_addr], MII_BMCR
|
||||||
stdcall phy_read, eax, 0
|
test ax, BMCR_FULLDPLX
|
||||||
test eax, 0x100
|
|
||||||
jnz .ret_0x8000
|
jnz .ret_0x8000
|
||||||
|
|
||||||
.auto_nego:
|
.auto_nego:
|
||||||
; Auto Negotiation Mode
|
; Auto Negotiation Mode
|
||||||
movzx eax, [device.phy_addr]
|
stdcall phy_read, [device.phy_addr], MII_LPA
|
||||||
stdcall phy_read, eax, 5
|
mov cx, ax
|
||||||
mov ecx, eax
|
stdcall phy_read, [device.phy_addr], MII_ADVERTISE
|
||||||
movzx eax, [device.phy_addr]
|
and ax, cx
|
||||||
stdcall phy_read, eax, 4
|
test ax, ADVERTISE_10FULL + ADVERTISE_100FULL
|
||||||
and eax, ecx
|
|
||||||
test eax, 0x140
|
|
||||||
jnz .ret_0x8000
|
jnz .ret_0x8000
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@ -803,7 +798,6 @@ transmit:
|
|||||||
|
|
||||||
inc [device.cur_tx]
|
inc [device.cur_tx]
|
||||||
and [device.cur_tx], TX_RING_SIZE - 1
|
and [device.cur_tx], TX_RING_SIZE - 1
|
||||||
xor eax, eax
|
|
||||||
|
|
||||||
; Update stats
|
; Update stats
|
||||||
inc [device.packets_tx]
|
inc [device.packets_tx]
|
||||||
@ -811,6 +805,7 @@ transmit:
|
|||||||
add dword [device.bytes_tx], eax
|
add dword [device.bytes_tx], eax
|
||||||
adc dword [device.bytes_tx + 4], 0
|
adc dword [device.bytes_tx + 4], 0
|
||||||
|
|
||||||
|
xor eax, eax
|
||||||
ret 8
|
ret 8
|
||||||
|
|
||||||
.wait_to_send:
|
.wait_to_send:
|
||||||
@ -989,13 +984,13 @@ int_handler:
|
|||||||
test word[esp], RX_EARLY
|
test word[esp], RX_EARLY
|
||||||
jz .no_rxearly
|
jz .no_rxearly
|
||||||
|
|
||||||
DEBUGF 1, "RX early\n"
|
DEBUGF 2, "RX early\n"
|
||||||
|
|
||||||
.no_rxearly:
|
.no_rxearly:
|
||||||
test word[esp], TX_EARLY
|
test word[esp], TX_EARLY
|
||||||
jz .no_txearly
|
jz .no_txearly
|
||||||
|
|
||||||
DEBUGF 1, "TX early\n"
|
DEBUGF 2, "TX early\n"
|
||||||
|
|
||||||
.no_txearly:
|
.no_txearly:
|
||||||
test word[esp], EVENT_OVRFL
|
test word[esp], EVENT_OVRFL
|
||||||
@ -1007,7 +1002,7 @@ int_handler:
|
|||||||
test word[esp], LINK_CHANGED
|
test word[esp], LINK_CHANGED
|
||||||
jz .no_link
|
jz .no_link
|
||||||
|
|
||||||
DEBUGF 1, "Link changed\n"
|
DEBUGF 2, "Link changed\n"
|
||||||
|
|
||||||
.no_link:
|
.no_link:
|
||||||
pop ax
|
pop ax
|
||||||
@ -1097,7 +1092,6 @@ proc phy_write stdcall, phy_addr:dword, reg:dword, val:dword
|
|||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
;Write the command to the MDIO bus
|
;Write the command to the MDIO bus
|
||||||
|
|
||||||
mov eax, [phy_addr]
|
mov eax, [phy_addr]
|
||||||
shl eax, 8
|
shl eax, 8
|
||||||
add eax, [reg]
|
add eax, [reg]
|
||||||
@ -1125,7 +1119,7 @@ endp
|
|||||||
align 4
|
align 4
|
||||||
read_mac:
|
read_mac:
|
||||||
|
|
||||||
DEBUGF 1,"Reading MAC: "
|
DEBUGF 1,"Reading MAC:\n"
|
||||||
|
|
||||||
mov cx, 3
|
mov cx, 3
|
||||||
lea edi, [device.mac]
|
lea edi, [device.mac]
|
||||||
|
Loading…
Reference in New Issue
Block a user