Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4450 → Rev 4449

/drivers/ethernet/R6040.asm
198,7 → 198,7
.cur_rx dw ?
.cur_tx dw ?
.last_tx dw ?
.phy_addr dd ?
.phy_addr dw ?
.phy_mode dw ?
.mcr0 dw ?
.mcr1 dw ?
208,7 → 208,7
.pci_dev dd ?
.irq_line db ?
 
rb 1 ; dword alignment
rb 3 ; dword alignment
 
.tx_ring: rb (((x_head.sizeof*TX_RING_SIZE)+32) and 0xfffffff0)
.rx_ring: rb (((x_head.sizeof*RX_RING_SIZE)+32) and 0xfffffff0)
395,17 → 395,15
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
 
 
;mdio_read:
; stdcall phy_read, [device.io_addr], [device.phy_addr], ecx
macro mdio_write reg, val {
stdcall phy_read, [device.io_addr], [device.phy_addr], reg
}
 
; ret
macro mdio_write reg, val {
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
unload:
; TODO: (in this particular order)
423,7 → 421,7
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; probe: enables the device (if it really is R6040)
;; probe: enables the device (if it really is RTL8139)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
457,14 → 455,14
@@:
; Init RDC private data
mov [device.mcr0], MCR0_XMTEN or MCR0_RCVEN
mov [device.phy_addr], PHY1_ADDR
;mov [private.phy_addr], 1 ; Asper: Only one network card is supported now.
mov [device.switch_sig], 0
 
; Check the vendor ID on the PHY, if 0xFFFF assume none attached
stdcall phy_read, [device.phy_addr], 2
stdcall phy_read, 1, 2
cmp ax, 0xFFFF
jne @f
DEBUGF 2, "Failed to detect an attached PHY!\n"
DEBUGF 2, "Failed to detect an attached PHY\n" ;, generating random"
mov eax, -1
ret
@@:
487,8 → 485,9
@@:
 
; PHY Mode Check
stdcall phy_write, [device.phy_addr], 4, PHY_CAP
stdcall phy_write, [device.phy_addr], 0, PHY_MODE
movzx eax, [device.phy_addr]
stdcall phy_write, eax, 4, PHY_CAP
stdcall phy_write, eax, 0, PHY_MODE
 
if PHY_MODE = 0x3100
call phy_mode_chk
713,26 → 712,32
DEBUGF 1,"Checking PHY mode\n"
 
; PHY Link Status Check
stdcall phy_read, [device.phy_addr], MII_BMSR
test ax, BMSR_LSTATUS
movzx eax, [device.phy_addr]
stdcall phy_read, eax, 1
test eax, 0x4
jz .ret_0x8000
 
; PHY Chip Auto-Negotiation Status
test ax, BMSR_ANEGCOMPLETE
movzx eax, [device.phy_addr]
stdcall phy_read, eax, 1
test eax, 0x0020
jnz .auto_nego
 
; Force Mode
stdcall phy_read, [device.phy_addr], MII_BMCR
test ax, BMCR_FULLDPLX
movzx eax, [device.phy_addr]
stdcall phy_read, eax, 0
test eax, 0x100
jnz .ret_0x8000
 
.auto_nego:
; Auto Negotiation Mode
stdcall phy_read, [device.phy_addr], MII_LPA
mov cx, ax
stdcall phy_read, [device.phy_addr], MII_ADVERTISE
and ax, cx
test ax, ADVERTISE_10FULL + ADVERTISE_100FULL
movzx eax, [device.phy_addr]
stdcall phy_read, eax, 5
mov ecx, eax
movzx eax, [device.phy_addr]
stdcall phy_read, eax, 4
and eax, ecx
test eax, 0x140
jnz .ret_0x8000
 
xor eax, eax
798,6 → 803,7
 
inc [device.cur_tx]
and [device.cur_tx], TX_RING_SIZE - 1
xor eax, eax
 
; Update stats
inc [device.packets_tx]
805,7 → 811,6
add dword [device.bytes_tx], eax
adc dword [device.bytes_tx + 4], 0
 
xor eax, eax
ret 8
 
.wait_to_send:
984,13 → 989,13
test word[esp], RX_EARLY
jz .no_rxearly
 
DEBUGF 2, "RX early\n"
DEBUGF 1, "RX early\n"
 
.no_rxearly:
test word[esp], TX_EARLY
jz .no_txearly
 
DEBUGF 2, "TX early\n"
DEBUGF 1, "TX early\n"
 
.no_txearly:
test word[esp], EVENT_OVRFL
1002,7 → 1007,7
test word[esp], LINK_CHANGED
jz .no_link
 
DEBUGF 2, "Link changed\n"
DEBUGF 1, "Link changed\n"
 
.no_link:
pop ax
1092,6 → 1097,7
out dx, ax
 
;Write the command to the MDIO bus
 
mov eax, [phy_addr]
shl eax, 8
add eax, [reg]
1119,7 → 1125,7
align 4
read_mac:
 
DEBUGF 1,"Reading MAC:\n"
DEBUGF 1,"Reading MAC: "
 
mov cx, 3
lea edi, [device.mac]