2010-10-01 11:21:55 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2012-03-15 13:41:29 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
|
2010-10-01 11:21:55 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
|
|
|
;; Copyright (c) 2004, Endre Kozma <endre.kozma@axelero.hu>
|
|
|
|
;; All rights reserved.
|
|
|
|
;;
|
|
|
|
;; Redistribution and use in source and binary forms, with or without
|
|
|
|
;; modification, are permitted provided that the following conditions are
|
|
|
|
;; met:
|
|
|
|
;;
|
|
|
|
;; 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
;; this list of conditions and the following disclaimer.
|
|
|
|
;;
|
|
|
|
;; 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
;; notice, this list of conditions and the following disclaimer in the
|
|
|
|
;; documentation and/or other materials provided with the distribution.
|
|
|
|
;;
|
|
|
|
;; 3. The name of the author may not be used to endorse or promote products
|
|
|
|
;; derived from this software without specific prior written permission.
|
|
|
|
;;
|
|
|
|
;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
;; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; 3C59X.INC ;;
|
|
|
|
;; ;;
|
|
|
|
;; Ethernet driver for Menuet OS ;;
|
|
|
|
;; ;;
|
|
|
|
;; Driver for 3Com fast etherlink 3c59x and ;;
|
|
|
|
;; etherlink XL 3c900 and 3c905 cards ;;
|
|
|
|
;; References: ;;
|
|
|
|
;; www.3Com.com - data sheets ;;
|
|
|
|
;; DP83840A.pdf - ethernet physical layer ;;
|
|
|
|
;; 3c59x.c - linux driver ;;
|
|
|
|
;; ethernet driver template by Mike Hibbett ;;
|
|
|
|
;; ;;
|
|
|
|
;; Credits ;;
|
|
|
|
;; Mike Hibbett, ;;
|
|
|
|
;; who kindly supplied me with a 3Com905C-TX-M card ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; History
|
|
|
|
;; =======
|
|
|
|
;; $Log: 3C59X.INC,v $
|
|
|
|
;; Revision 1.3 2004/07/11 12:21:12 kozma
|
|
|
|
;; Support of vortex chips (3c59x) added.
|
|
|
|
;; Support of 3c920 and 3c982 added.
|
|
|
|
;; Corrections.
|
|
|
|
;;
|
|
|
|
;; Revision 1.2 2004/06/12 19:40:20 kozma
|
|
|
|
;; Function e3c59x_set_available_media added in order to set
|
|
|
|
;; the default media in case auto detection finds no valid link.
|
|
|
|
;; Incorrect mii check removed (3c900 Cyclone works now).
|
|
|
|
;; Cleanups.
|
|
|
|
;;
|
|
|
|
;; Revision 1.1 2004/06/12 18:27:15 kozma
|
|
|
|
;; Initial revision
|
|
|
|
;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
; comment the next line out if you don't want debug info printed
|
|
|
|
; on the debug board. This option adds a lot of bytes to the driver
|
|
|
|
; so it's worth to comment it out.
|
|
|
|
; E3C59X_DEBUG equ 1
|
|
|
|
|
|
|
|
; forcing full duplex mode makes sense at some cards and link types
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_FORCE_FD equ 1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
macro virt_to_dma reg
|
|
|
|
{
|
2012-03-08 09:33:38 +01:00
|
|
|
sub reg, OS_BASE
|
2010-10-01 11:21:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
macro dma_to_virt reg
|
|
|
|
{
|
2012-03-08 09:33:38 +01:00
|
|
|
add reg, OS_BASE
|
2010-10-01 11:21:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
macro zero_to_virt reg
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
macro virt_to_zero reg
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
macro zero_to_dma reg
|
|
|
|
{
|
2012-03-08 09:33:38 +01:00
|
|
|
sub reg, OS_BASE
|
2010-10-01 11:21:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
macro dma_to_zero reg
|
|
|
|
{
|
2012-03-08 09:33:38 +01:00
|
|
|
add reg, OS_BASE
|
2010-10-01 11:21:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
macro strtbl name, [string]
|
|
|
|
{
|
|
|
|
common
|
2012-03-08 09:33:38 +01:00
|
|
|
label name dword
|
2010-10-01 11:21:55 +02:00
|
|
|
forward
|
2012-03-08 09:33:38 +01:00
|
|
|
local label
|
|
|
|
dd label
|
2010-10-01 11:21:55 +02:00
|
|
|
forward
|
2012-03-08 09:33:38 +01:00
|
|
|
label db string, 0
|
2010-10-01 11:21:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
; Ethernet frame symbols
|
2012-03-08 09:33:38 +01:00
|
|
|
ETH_ALEN equ 6
|
|
|
|
ETH_HLEN equ (2*ETH_ALEN+2)
|
|
|
|
ETH_ZLEN equ 60 ; 60 + 4bytes auto payload for
|
|
|
|
; mininmum 64bytes frame length
|
2010-10-01 11:21:55 +02:00
|
|
|
; PCI programming
|
2012-03-08 09:33:38 +01:00
|
|
|
PCI_REG_COMMAND equ 0x4 ; command register
|
|
|
|
PCI_REG_STATUS equ 0x6 ; status register
|
|
|
|
PCI_REG_LATENCY equ 0xd ; latency timer register
|
|
|
|
PCI_REG_CAP_PTR equ 0x34 ; capabilities pointer
|
|
|
|
PCI_REG_CAPABILITY_ID equ 0x0 ; capapility ID in pm register block
|
|
|
|
PCI_REG_PM_STATUS equ 0x4 ; power management status register
|
|
|
|
PCI_REG_PM_CTRL equ 0x4 ; power management control register
|
|
|
|
PCI_BIT_PIO equ 0 ; bit0: io space control
|
|
|
|
PCI_BIT_MMIO equ 1 ; bit1: memory space control
|
|
|
|
PCI_BIT_MASTER equ 2 ; bit2: device acts as a PCI master
|
2010-10-01 11:21:55 +02:00
|
|
|
; Registers
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_POWER_MGMT_CTRL equ 0x7c
|
|
|
|
E3C59X_REG_UP_LIST_PTR equ 0x38
|
|
|
|
E3C59X_REG_UP_PKT_STATUS equ 0x30
|
|
|
|
E3C59X_REG_TX_FREE_THRESH equ 0x2f
|
|
|
|
E3C59X_REG_DN_LIST_PTR equ 0x24
|
|
|
|
E3C59X_REG_DMA_CTRL equ 0x20
|
|
|
|
E3C59X_REG_TX_STATUS equ 0x1b
|
|
|
|
E3C59X_REG_RX_STATUS equ 0x18
|
|
|
|
E3C59X_REG_TX_DATA equ 0x10
|
2010-10-01 11:21:55 +02:00
|
|
|
; Common window registers
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_INT_STATUS equ 0xe
|
|
|
|
E3C59X_REG_COMMAND equ 0xe
|
2010-10-01 11:21:55 +02:00
|
|
|
; Register window 7
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_MASTER_STATUS equ 0xc
|
|
|
|
E3C59X_REG_POWER_MGMT_EVENT equ 0xc
|
|
|
|
E3C59X_REG_MASTER_LEN equ 0x6
|
|
|
|
E3C59X_REG_VLAN_ETHER_TYPE equ 0x4
|
|
|
|
E3C59X_REG_VLAN_MASK equ 0x0
|
|
|
|
E3C59X_REG_MASTER_ADDRESS equ 0x0
|
2010-10-01 11:21:55 +02:00
|
|
|
; Register window 6
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_BYTES_XMITTED_OK equ 0xc
|
|
|
|
E3C59X_REG_BYTES_RCVD_OK equ 0xa
|
|
|
|
E3C59X_REG_UPPER_FRAMES_OK equ 0x9
|
|
|
|
E3C59X_REG_FRAMES_DEFERRED equ 0x8
|
|
|
|
E3C59X_REG_FRAMES_RCVD_OK equ 0x7
|
|
|
|
E3C59X_REG_FRAMES_XMITTED_OK equ 0x6
|
|
|
|
E3C59X_REG_RX_OVERRUNS equ 0x5
|
|
|
|
E3C59X_REG_LATE_COLLISIONS equ 0x4
|
|
|
|
E3C59X_REG_SINGLE_COLLISIONS equ 0x3
|
|
|
|
E3C59X_REG_MULTIPLE_COLLISIONS equ 0x2
|
|
|
|
E3C59X_REG_SQE_ERRORS equ 0x1
|
|
|
|
E3C59X_REG_CARRIER_LOST equ 0x0
|
2010-10-01 11:21:55 +02:00
|
|
|
; Register window 5
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_INDICATION_ENABLE equ 0xc
|
|
|
|
E3C59X_REG_INTERRUPT_ENABLE equ 0xa
|
|
|
|
E3C59X_REG_TX_RECLAIM_THRESH equ 0x9
|
|
|
|
E3C59X_REG_RX_FILTER equ 0x8
|
|
|
|
E3C59X_REG_RX_EARLY_THRESH equ 0x6
|
|
|
|
E3C59X_REG_TX_START_THRESH equ 0x0
|
2010-10-01 11:21:55 +02:00
|
|
|
; Register window 4
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_UPPER_BYTES_OK equ 0xe
|
|
|
|
E3C59X_REG_BAD_SSD equ 0xc
|
|
|
|
E3C59X_REG_MEDIA_STATUS equ 0xa
|
|
|
|
E3C59X_REG_PHYSICAL_MGMT equ 0x8
|
|
|
|
E3C59X_REG_NETWORK_DIAGNOSTIC equ 0x6
|
|
|
|
E3C59X_REG_FIFO_DIAGNOSTIC equ 0x4
|
|
|
|
E3C59X_REG_VCO_DIAGNOSTIC equ 0x2 ; may not supported
|
2010-10-01 11:21:55 +02:00
|
|
|
; Bits in register window 4
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_BIT_AUTOSELECT equ 24
|
2010-10-01 11:21:55 +02:00
|
|
|
; Register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_TX_FREE equ 0xc
|
|
|
|
E3C59X_REG_RX_FREE equ 0xa
|
|
|
|
E3C59X_REG_MEDIA_OPTIONS equ 0x8
|
|
|
|
E3C59X_REG_MAC_CONTROL equ 0x6
|
|
|
|
E3C59X_REG_MAX_PKT_SIZE equ 0x4
|
|
|
|
E3C59X_REG_INTERNAL_CONFIG equ 0x0
|
2010-10-01 11:21:55 +02:00
|
|
|
; Register window 2
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_RESET_OPTIONS equ 0xc
|
|
|
|
E3C59X_REG_STATION_MASK_HI equ 0xa
|
|
|
|
E3C59X_REG_STATION_MASK_MID equ 0x8
|
|
|
|
E3C59X_REG_STATION_MASK_LO equ 0x6
|
|
|
|
E3C59X_REG_STATION_ADDRESS_HI equ 0x4
|
|
|
|
E3C59X_REG_STATION_ADDRESS_MID equ 0x2
|
|
|
|
E3C59X_REG_STATION_ADDRESS_LO equ 0x0
|
2010-10-01 11:21:55 +02:00
|
|
|
; Register window 1
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_TRIGGER_BITS equ 0xc
|
|
|
|
E3C59X_REG_SOS_BITS equ 0xa
|
|
|
|
E3C59X_REG_WAKE_ON_TIMER equ 0x8
|
|
|
|
E3C59X_REG_SMB_RXBYTES equ 0x7
|
|
|
|
E3C59X_REG_SMB_DIAG equ 0x5
|
|
|
|
E3C59X_REG_SMB_ARB equ 0x4
|
|
|
|
E3C59X_REG_SMB_STATUS equ 0x2
|
|
|
|
E3C59X_REG_SMB_ADDRESS equ 0x1
|
|
|
|
E3C59X_REG_SMB_FIFO_DATA equ 0x0
|
2010-10-01 11:21:55 +02:00
|
|
|
; Register window 0
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_EEPROM_DATA equ 0xc
|
|
|
|
E3C59X_REG_EEPROM_COMMAND equ 0xa
|
|
|
|
E3C59X_REG_BIOS_ROM_DATA equ 0x8
|
|
|
|
E3C59X_REG_BIOS_ROM_ADDR equ 0x4
|
2010-10-01 11:21:55 +02:00
|
|
|
; Physical management bits
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_BIT_MGMT_DIR equ 2 ; drive with the data written in mgmtData
|
|
|
|
E3C59X_BIT_MGMT_DATA equ 1 ; MII management data bit
|
|
|
|
E3C59X_BIT_MGMT_CLK equ 0 ; MII management clock
|
2010-10-01 11:21:55 +02:00
|
|
|
; MII commands
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_MII_CMD_MASK equ (1111b shl 10)
|
|
|
|
E3C59X_MII_CMD_READ equ (0110b shl 10)
|
|
|
|
E3C59X_MII_CMD_WRITE equ (0101b shl 10)
|
2010-10-01 11:21:55 +02:00
|
|
|
; MII registers
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_REG_MII_BMCR equ 0 ; basic mode control register
|
|
|
|
E3C59X_REG_MII_BMSR equ 1 ; basic mode status register
|
|
|
|
E3C59X_REG_MII_ANAR equ 4 ; auto negotiation advertisement register
|
|
|
|
E3C59X_REG_MII_ANLPAR equ 5 ; auto negotiation link partner ability register
|
|
|
|
E3C59X_REG_MII_ANER equ 6 ; auto negotiation expansion register
|
2010-10-01 11:21:55 +02:00
|
|
|
; MII bits
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_BIT_MII_AUTONEG_COMPLETE equ 5 ; auto-negotiation complete
|
|
|
|
E3C59X_BIT_MII_PREAMBLE_SUPPRESSION equ 6
|
2010-10-01 11:21:55 +02:00
|
|
|
; eeprom bits and commands
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_EEPROM_CMD_READ equ 0x80
|
|
|
|
E3C59X_EEPROM_BIT_BUSY equ 15
|
2010-10-01 11:21:55 +02:00
|
|
|
; eeprom registers
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_EEPROM_REG_OEM_NODE_ADDR equ 0xa
|
|
|
|
E3C59X_EEPROM_REG_CAPABILITIES equ 0x10
|
2010-10-01 11:21:55 +02:00
|
|
|
; Commands for command register
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_SELECT_REGISTER_WINDOW equ (1 shl 11)
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
IS_VORTEX equ 0x1
|
|
|
|
IS_BOOMERANG equ 0x2
|
|
|
|
IS_CYCLONE equ 0x4
|
|
|
|
IS_TORNADO equ 0x8
|
|
|
|
EEPROM_8BIT equ 0x10
|
|
|
|
HAS_PWR_CTRL equ 0x20
|
|
|
|
HAS_MII equ 0x40
|
|
|
|
HAS_NWAY equ 0x80
|
|
|
|
HAS_CB_FNS equ 0x100
|
|
|
|
INVERT_MII_PWR equ 0x200
|
|
|
|
INVERT_LED_PWR equ 0x400
|
|
|
|
MAX_COLLISION_RESET equ 0x800
|
|
|
|
EEPROM_OFFSET equ 0x1000
|
|
|
|
HAS_HWCKSM equ 0x2000
|
|
|
|
EXTRA_PREAMBLE equ 0x4000
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
iglobal
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_hw_versions:
|
2012-03-08 09:33:38 +01:00
|
|
|
dw 0x5900, IS_VORTEX ; 3c590 Vortex 10Mbps
|
|
|
|
dw 0x5920, IS_VORTEX ; 3c592 EISA 10Mbps Demon/Vortex
|
|
|
|
dw 0x5970, IS_VORTEX ; 3c597 EISA Fast Demon/Vortex
|
|
|
|
dw 0x5950, IS_VORTEX ; 3c595 Vortex 100baseTx
|
|
|
|
dw 0x5951, IS_VORTEX ; 3c595 Vortex 100baseT4
|
|
|
|
dw 0x5952, IS_VORTEX ; 3c595 Vortex 100base-MII
|
|
|
|
dw 0x9000, IS_BOOMERANG ; 3c900 Boomerang 10baseT
|
|
|
|
dw 0x9001, IS_BOOMERANG ; 3c900 Boomerang 10Mbps Combo
|
|
|
|
dw 0x9004, IS_CYCLONE or HAS_NWAY or HAS_HWCKSM ; 3c900 Cyclone 10Mbps TPO
|
|
|
|
dw 0x9005, IS_CYCLONE or HAS_HWCKSM ; 3c900 Cyclone 10Mbps Combo
|
|
|
|
dw 0x9006, IS_CYCLONE or HAS_HWCKSM ; 3c900 Cyclone 10Mbps TPC
|
|
|
|
dw 0x900A, IS_CYCLONE or HAS_HWCKSM ; 3c900B-FL Cyclone 10base-FL
|
|
|
|
dw 0x9050, IS_BOOMERANG or HAS_MII ; 3c905 Boomerang 100baseTx
|
|
|
|
dw 0x9051, IS_BOOMERANG or HAS_MII ; 3c905 Boomerang 100baseT4
|
|
|
|
dw 0x9055, IS_CYCLONE or HAS_NWAY or HAS_HWCKSM or EXTRA_PREAMBLE ; 3c905B Cyclone 100baseTx
|
|
|
|
dw 0x9058, IS_CYCLONE or HAS_NWAY or HAS_HWCKSM ; 3c905B Cyclone 10/100/BNC
|
|
|
|
dw 0x905A, IS_CYCLONE or HAS_HWCKSM ; 3c905B-FX Cyclone 100baseFx
|
|
|
|
dw 0x9200, IS_TORNADO or HAS_NWAY or HAS_HWCKSM ; 3c905C Tornado
|
|
|
|
dw 0x9800, IS_CYCLONE or HAS_NWAY or HAS_HWCKSM ; 3c980 Cyclone
|
|
|
|
dw 0x9805, IS_TORNADO or HAS_NWAY or HAS_HWCKSM ; 3c982 Dual Port Server Cyclone
|
|
|
|
dw 0x7646, IS_CYCLONE or HAS_NWAY or HAS_HWCKSM ; 3cSOHO100-TX Hurricane
|
|
|
|
dw 0x5055, IS_CYCLONE or EEPROM_8BIT or HAS_HWCKSM ; 3c555 Laptop Hurricane
|
|
|
|
dw 0x6055, IS_TORNADO or HAS_NWAY or EEPROM_8BIT or HAS_CB_FNS \
|
|
|
|
or INVERT_MII_PWR or HAS_HWCKSM ; 3c556 Laptop Tornado
|
|
|
|
dw 0x6056, IS_TORNADO or HAS_NWAY or EEPROM_OFFSET or HAS_CB_FNS \
|
|
|
|
or INVERT_MII_PWR or HAS_HWCKSM ; 3c556B Laptop Hurricane
|
|
|
|
dw 0x5b57, IS_BOOMERANG or HAS_MII or EEPROM_8BIT ; 3c575 [Megahertz] 10/100 LAN CardBus
|
|
|
|
dw 0x5057, IS_BOOMERANG or HAS_MII or EEPROM_8BIT ; 3c575 Boomerang CardBus
|
|
|
|
dw 0x5157, IS_CYCLONE or HAS_NWAY or HAS_CB_FNS or EEPROM_8BIT \
|
|
|
|
or INVERT_LED_PWR or HAS_HWCKSM ; 3CCFE575BT Cyclone CardBus
|
|
|
|
dw 0x5257, IS_TORNADO or HAS_NWAY or HAS_CB_FNS or EEPROM_8BIT or INVERT_MII_PWR \
|
|
|
|
or MAX_COLLISION_RESET or HAS_HWCKSM ; 3CCFE575CT Tornado CardBus
|
|
|
|
dw 0x6560, IS_CYCLONE or HAS_NWAY or HAS_CB_FNS or EEPROM_8BIT or INVERT_MII_PWR \
|
|
|
|
or INVERT_LED_PWR or HAS_HWCKSM ; 3CCFE656 Cyclone CardBus
|
|
|
|
dw 0x6562, IS_CYCLONE or HAS_NWAY or HAS_CB_FNS or EEPROM_8BIT or INVERT_MII_PWR \
|
|
|
|
or INVERT_LED_PWR or HAS_HWCKSM ; 3CCFEM656B Cyclone+Winmodem CardBus
|
|
|
|
dw 0x6564, IS_TORNADO or HAS_NWAY or HAS_CB_FNS or EEPROM_8BIT or INVERT_MII_PWR \
|
|
|
|
or MAX_COLLISION_RESET or HAS_HWCKSM ; 3CXFEM656C Tornado+Winmodem CardBus
|
|
|
|
dw 0x4500, IS_TORNADO or HAS_NWAY or HAS_HWCKSM ; 3c450 HomePNA Tornado
|
|
|
|
dw 0x9201, IS_TORNADO or HAS_NWAY or HAS_HWCKSM ; 3c920 Tornado
|
|
|
|
dw 0x1201, IS_TORNADO or HAS_HWCKSM or HAS_NWAY ; 3c982 Hydra Dual Port A
|
|
|
|
dw 0x1202, IS_TORNADO or HAS_HWCKSM or HAS_NWAY ; 3c982 Hydra Dual Port B
|
|
|
|
dw 0x9056, IS_CYCLONE or HAS_NWAY or HAS_HWCKSM or EXTRA_PREAMBLE ; 3c905B-T4
|
|
|
|
dw 0x9210, IS_TORNADO or HAS_NWAY or HAS_HWCKSM ; 3c920B-EMB-WNM Tornado
|
2010-10-01 11:21:55 +02:00
|
|
|
E3C59X_HW_VERSIONS_SIZE= $-e3c59x_hw_versions
|
|
|
|
endg
|
|
|
|
|
|
|
|
; RX/TX buffers sizes
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_MAX_ETH_PKT_SIZE equ 1536 ; max packet size
|
|
|
|
E3C59X_NUM_RX_DESC equ 4 ; a power of 2 number
|
|
|
|
E3C59X_NUM_TX_DESC equ 4 ; a power of 2 number
|
|
|
|
E3C59X_RX_BUFFER_SIZE equ (E3C59X_MAX_ETH_FRAME_SIZE*E3C59X_NUM_RX_DESC)
|
|
|
|
E3C59X_TX_BUFFER_SIZE equ (E3C59X_MAX_ETH_FRAME_SIZE*E3C59X_NUM_TX_DESC)
|
2010-10-01 11:21:55 +02:00
|
|
|
; Download Packet Descriptor
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_DPD_DN_NEXT_PTR equ 0
|
|
|
|
E3C59X_DPD_FRAME_START_HDR equ 4
|
|
|
|
E3C59X_DPD_DN_FRAG_ADDR equ 8 ; for packet data
|
|
|
|
E3C59X_DPD_DN_FRAG_LEN equ 12 ; for packet data
|
|
|
|
E3C59X_DPD_SIZE equ 16 ; a power of 2 number
|
2010-10-01 11:21:55 +02:00
|
|
|
; Upload Packet Descriptor
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_UPD_UP_NEXT_PTR equ 0
|
|
|
|
E3C59X_UPD_PKT_STATUS equ 4
|
|
|
|
E3C59X_UPD_UP_FRAG_ADDR equ 8 ; for packet data
|
|
|
|
E3C59X_UPD_UP_FRAG_LEN equ 12 ; for packet data
|
|
|
|
E3C59X_UPD_SIZE equ 16
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
; RX/TX buffers
|
|
|
|
if defined E3C59X_LINUX
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_MAX_ETH_FRAME_SIZE = 160 ; size of ethernet frame + bytes alignment
|
|
|
|
e3c59x_rx_buff = 0
|
2010-10-01 11:21:55 +02:00
|
|
|
else
|
2012-03-08 09:33:38 +01:00
|
|
|
E3C59X_MAX_ETH_FRAME_SIZE = 1520 ; size of ethernet frame + bytes alignment
|
|
|
|
e3c59x_rx_buff = eth_data_start
|
2010-10-01 11:21:55 +02:00
|
|
|
end if
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
e3c59x_tx_buff = e3c59x_rx_buff+E3C59X_RX_BUFFER_SIZE
|
|
|
|
e3c59x_dpd_buff = e3c59x_tx_buff+E3C59X_TX_BUFFER_SIZE
|
|
|
|
e3c59x_upd_buff = e3c59x_dpd_buff+(E3C59X_DPD_SIZE*E3C59X_NUM_TX_DESC)
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
uglobal
|
2012-03-08 09:33:38 +01:00
|
|
|
e3c59x_curr_upd:
|
|
|
|
dd 0
|
|
|
|
e3c59x_prev_dpd:
|
|
|
|
dd 0
|
|
|
|
e3c59x_prev_tx_frame:
|
|
|
|
dd 0
|
|
|
|
e3c59x_transmit_function:
|
|
|
|
dd 0
|
|
|
|
e3c59x_receive_function:
|
|
|
|
dd 0
|
2010-10-01 11:21:55 +02:00
|
|
|
endg
|
|
|
|
|
|
|
|
iglobal
|
2012-03-08 09:33:38 +01:00
|
|
|
e3c59x_ver_id:
|
|
|
|
db 17
|
2010-10-01 11:21:55 +02:00
|
|
|
endg
|
|
|
|
|
|
|
|
uglobal
|
2012-03-08 09:33:38 +01:00
|
|
|
e3c59x_full_bus_master:
|
|
|
|
db 0
|
|
|
|
e3c59x_has_hwcksm:
|
|
|
|
db 0
|
|
|
|
e3c59x_preamble:
|
|
|
|
db 0
|
|
|
|
e3c59x_dn_list_ptr_cleared:
|
|
|
|
db 0
|
|
|
|
e3c59x_self_directed_packet:
|
|
|
|
rb 6
|
2010-10-01 11:21:55 +02:00
|
|
|
endg
|
|
|
|
|
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
e3c59x_hw_type_str:
|
|
|
|
db "Detected hardware type : ", 0
|
|
|
|
e3c59x_device_str:
|
|
|
|
db "Device ID : 0x"
|
|
|
|
e3c59x_device_id_str:
|
|
|
|
db "ffff", 13, 10, 0
|
|
|
|
e3c59x_vendor_str:
|
|
|
|
db "Vendor ID : 0x"
|
|
|
|
e3c59x_vendor_id_str:
|
|
|
|
db "ffff", 13, 10, 0
|
|
|
|
e3c59x_io_info_str:
|
|
|
|
db "IO address : 0x"
|
|
|
|
e3c59x_io_addr_str:
|
|
|
|
db "ffff", 13, 10, 0
|
|
|
|
e3c59x_mac_info_str:
|
|
|
|
db "MAC address : "
|
|
|
|
e3c59x_mac_addr_str:
|
|
|
|
db "ff:ff:ff:ff:ff:ff", 13, 10, 0
|
|
|
|
e3c59x_boomerang_str:
|
|
|
|
db " (boomerang)", 13, 10, 0
|
|
|
|
e3c59x_vortex_str:
|
|
|
|
db " (vortex)", 13, 10, 0
|
|
|
|
e3c59x_link_type_str:
|
|
|
|
db "Established link type : ", 0
|
|
|
|
e3c59x_new_line_str:
|
|
|
|
db 13, 10, 0
|
|
|
|
e3c59x_link_type:
|
|
|
|
dd 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
e3c59x_charset:
|
|
|
|
db '0123456789abcdef'
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
strtbl e3c59x_link_str, \
|
2012-03-08 09:33:38 +01:00
|
|
|
"No valid link type detected", \
|
|
|
|
"10BASE-T half duplex", \
|
|
|
|
"10BASE-T full-duplex", \
|
|
|
|
"100BASE-TX half duplex", \
|
|
|
|
"100BASE-TX full duplex", \
|
|
|
|
"100BASE-T4", \
|
|
|
|
"100BASE-FX", \
|
|
|
|
"10Mbps AUI", \
|
|
|
|
"10Mbps COAX (BNC)", \
|
|
|
|
"miiDevice - not supported"
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
strtbl e3c59x_hw_str, \
|
2012-03-08 09:33:38 +01:00
|
|
|
"3c590 Vortex 10Mbps", \
|
|
|
|
"3c592 EISA 10Mbps Demon/Vortex", \
|
|
|
|
"3c597 EISA Fast Demon/Vortex", \
|
|
|
|
"3c595 Vortex 100baseTx", \
|
|
|
|
"3c595 Vortex 100baseT4", \
|
|
|
|
"3c595 Vortex 100base-MII", \
|
|
|
|
"3c900 Boomerang 10baseT", \
|
|
|
|
"3c900 Boomerang 10Mbps Combo", \
|
|
|
|
"3c900 Cyclone 10Mbps TPO", \
|
|
|
|
"3c900 Cyclone 10Mbps Combo", \
|
|
|
|
"3c900 Cyclone 10Mbps TPC", \
|
|
|
|
"3c900B-FL Cyclone 10base-FL", \
|
|
|
|
"3c905 Boomerang 100baseTx", \
|
|
|
|
"3c905 Boomerang 100baseT4", \
|
|
|
|
"3c905B Cyclone 100baseTx", \
|
|
|
|
"3c905B Cyclone 10/100/BNC", \
|
|
|
|
"3c905B-FX Cyclone 100baseFx", \
|
|
|
|
"3c905C Tornado", \
|
|
|
|
"3c980 Cyclone", \
|
|
|
|
"3c982 Dual Port Server Cyclone", \
|
|
|
|
"3cSOHO100-TX Hurricane", \
|
|
|
|
"3c555 Laptop Hurricane", \
|
|
|
|
"3c556 Laptop Tornado", \
|
|
|
|
"3c556B Laptop Hurricane", \
|
|
|
|
"3c575 [Megahertz] 10/100 LAN CardBus", \
|
|
|
|
"3c575 Boomerang CardBus", \
|
|
|
|
"3CCFE575BT Cyclone CardBus", \
|
|
|
|
"3CCFE575CT Tornado CardBus", \
|
|
|
|
"3CCFE656 Cyclone CardBus", \
|
|
|
|
"3CCFEM656B Cyclone+Winmodem CardBus", \
|
|
|
|
"3CXFEM656C Tornado+Winmodem CardBus", \
|
|
|
|
"3c450 HomePNA Tornado", \
|
|
|
|
"3c920 Tornado", \
|
|
|
|
"3c982 Hydra Dual Port A", \
|
|
|
|
"3c982 Hydra Dual Port B", \
|
|
|
|
"3c905B-T4", \
|
|
|
|
"3c920B-EMB-WNM Tornado"
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
end if ; defined E3C59X_DEBUG
|
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_debug
|
|
|
|
; Description
|
|
|
|
; prints debug info to the debug board
|
|
|
|
; Parameters
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, edi, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_debug:
|
2012-03-08 09:33:38 +01:00
|
|
|
pushad
|
2010-10-01 11:21:55 +02:00
|
|
|
; print device type
|
2012-03-08 09:33:38 +01:00
|
|
|
mov esi, e3c59x_hw_type_str
|
|
|
|
call sys_msg_board_str
|
|
|
|
movzx ecx, byte [e3c59x_ver_id]
|
|
|
|
mov esi, [e3c59x_hw_str+ecx*4]
|
|
|
|
call sys_msg_board_str
|
|
|
|
mov esi, e3c59x_boomerang_str
|
|
|
|
cmp dword [e3c59x_transmit_function], e3c59x_boomerang_transmit
|
|
|
|
jz .boomerang
|
|
|
|
mov esi, e3c59x_vortex_str
|
2010-10-01 11:21:55 +02:00
|
|
|
.boomerang:
|
2012-03-08 09:33:38 +01:00
|
|
|
call sys_msg_board_str
|
2010-10-01 11:21:55 +02:00
|
|
|
; print device/vendor
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, [pci_data+2]
|
|
|
|
mov cl, 2
|
|
|
|
mov ebx, e3c59x_device_id_str
|
|
|
|
call e3c59x_print_hex
|
|
|
|
mov esi, e3c59x_device_str
|
|
|
|
call sys_msg_board_str
|
|
|
|
mov ax, [pci_data]
|
|
|
|
mov cl, 2
|
|
|
|
mov ebx, e3c59x_vendor_id_str
|
|
|
|
call e3c59x_print_hex
|
|
|
|
mov esi, e3c59x_vendor_str
|
|
|
|
call sys_msg_board_str
|
2010-10-01 11:21:55 +02:00
|
|
|
; print io address
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, [io_addr]
|
|
|
|
mov ebx, e3c59x_io_addr_str
|
|
|
|
mov cl, 2
|
|
|
|
call e3c59x_print_hex
|
|
|
|
mov esi, e3c59x_io_info_str
|
|
|
|
call sys_msg_board_str
|
2010-10-01 11:21:55 +02:00
|
|
|
; print MAC address
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ebx, e3c59x_mac_addr_str
|
|
|
|
xor ecx, ecx
|
2010-10-01 11:21:55 +02:00
|
|
|
.mac_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
push ecx
|
|
|
|
mov al, [node_addr+ecx]
|
|
|
|
mov cl, 1
|
|
|
|
call e3c59x_print_hex
|
|
|
|
inc ebx
|
|
|
|
pop ecx
|
|
|
|
inc cl
|
|
|
|
cmp cl, 6
|
|
|
|
jne .mac_loop
|
|
|
|
mov esi, e3c59x_mac_info_str
|
|
|
|
call sys_msg_board_str
|
2010-10-01 11:21:55 +02:00
|
|
|
; print link type
|
2012-03-08 09:33:38 +01:00
|
|
|
mov esi, e3c59x_link_type_str
|
|
|
|
call sys_msg_board_str
|
|
|
|
xor eax, eax
|
|
|
|
bsr ax, word [e3c59x_link_type]
|
|
|
|
jz @f
|
|
|
|
sub ax, 4
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov esi, [e3c59x_link_str+eax*4]
|
|
|
|
call sys_msg_board_str
|
|
|
|
mov esi, e3c59x_new_line_str
|
|
|
|
call sys_msg_board_str
|
|
|
|
popad
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_print_hex
|
|
|
|
; Description
|
|
|
|
; prints a hexadecimal value
|
|
|
|
; Parameters
|
|
|
|
; eax - value to be printed out
|
|
|
|
; ebx - where to print
|
|
|
|
; cl - value size (1, 2, 4)
|
|
|
|
; Return value
|
|
|
|
; ebx - end address after the print
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_print_hex:
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp cl, 1
|
|
|
|
je .print_byte
|
|
|
|
cmp cl, 2
|
|
|
|
jz .print_word
|
2010-10-01 11:21:55 +02:00
|
|
|
.print_dword:
|
2012-03-08 09:33:38 +01:00
|
|
|
push eax
|
|
|
|
bswap eax
|
|
|
|
xchg ah, al
|
|
|
|
call .print_word
|
|
|
|
pop eax
|
2010-10-01 11:21:55 +02:00
|
|
|
.print_word:
|
2012-03-08 09:33:38 +01:00
|
|
|
push eax
|
|
|
|
xchg ah, al
|
|
|
|
call .print_byte
|
|
|
|
pop eax
|
2010-10-01 11:21:55 +02:00
|
|
|
.print_byte:
|
2012-03-08 09:33:38 +01:00
|
|
|
movzx eax, al
|
|
|
|
push eax
|
|
|
|
and al, 0xf0
|
|
|
|
shr al, 4
|
|
|
|
mov al, byte [eax+e3c59x_charset]
|
|
|
|
mov [ebx], al
|
|
|
|
inc ebx
|
|
|
|
pop eax
|
|
|
|
and al, 0x0f
|
|
|
|
mov al, byte [eax+e3c59x_charset]
|
|
|
|
mov [ebx], al
|
|
|
|
inc ebx
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
end if ; defined E3C59X_DEBUG
|
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_try_link_detect
|
|
|
|
; Description
|
|
|
|
; e3c59x_try_link_detect checks if link exists
|
|
|
|
; Parameters
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; al - 0 ; no link detected
|
|
|
|
; al - 1 ; link detected
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, edi, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_try_link_detect:
|
|
|
|
; download self-directed packet
|
2012-03-08 09:33:38 +01:00
|
|
|
mov edi, node_addr
|
|
|
|
mov bx, 0x0608 ; packet type
|
|
|
|
mov esi, e3c59x_self_directed_packet
|
|
|
|
mov ecx, 6 ; 6 + 6 + 2 + 6 = 20 bytes
|
|
|
|
call dword [e3c59x_transmit_function]
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 5
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+5
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; program RxFilter for promiscuous operation
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (10000b shl 11)
|
|
|
|
lea edx, [ebp+E3C59X_REG_RX_FILTER]
|
|
|
|
in al, dx
|
|
|
|
or al, 1111b
|
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 4
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+4
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; check loop
|
2012-03-08 09:33:38 +01:00
|
|
|
xor ebx, ebx
|
|
|
|
mov ecx, 0xffff ; 65535 tries
|
2010-10-01 11:21:55 +02:00
|
|
|
.loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
push ecx ebx
|
|
|
|
call dword [e3c59x_receive_function]
|
|
|
|
pop ebx ecx
|
|
|
|
test al, al
|
|
|
|
jnz .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
.no_packet_received:
|
|
|
|
; switch to register window 4
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+4
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; read linkbeatdetect
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MEDIA_STATUS]
|
|
|
|
in ax, dx
|
|
|
|
test ah, 1000b ; test linkBeatDetect
|
|
|
|
jnz .link_detected
|
|
|
|
xor al, al
|
|
|
|
jmp .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
.link_detected:
|
|
|
|
; test carrierSense
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, 100000b
|
|
|
|
jz .no_carrier_sense
|
|
|
|
inc ebx
|
2010-10-01 11:21:55 +02:00
|
|
|
.no_carrier_sense:
|
2012-03-08 09:33:38 +01:00
|
|
|
dec ecx
|
|
|
|
jns .loop
|
2010-10-01 11:21:55 +02:00
|
|
|
; assume the link is good if 0 < ebx < 25 %
|
2012-03-08 09:33:38 +01:00
|
|
|
test ebx, ebx
|
|
|
|
setnz al
|
|
|
|
jz .finish
|
|
|
|
cmp ebx, 16384 ; 25%
|
|
|
|
setb al
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, al
|
|
|
|
jz @f
|
|
|
|
or byte [e3c59x_link_type+1], 100b
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
|
|
|
end if ; defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_try_phy
|
|
|
|
; Description
|
|
|
|
; e3c59x_try_phy checks the auto-negotiation function
|
|
|
|
; in the PHY at PHY index. It can also be extended to
|
|
|
|
; include link detection for non-IEEE 802.3u
|
|
|
|
; auto-negotiation devices, for instance the BCM5000.
|
|
|
|
; Parameters
|
|
|
|
; ah - PHY index
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; al - 0 link is auto-negotiated
|
|
|
|
; al - 1 no link is auto-negotiated
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_try_phy:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov al, E3C59X_REG_MII_BMCR
|
|
|
|
push eax
|
|
|
|
call e3c59x_mdio_read ; returns with window #4
|
|
|
|
or ah, 0x80 ; software reset
|
|
|
|
mov ebx, eax
|
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
call e3c59x_mdio_write ; returns with window #4
|
2010-10-01 11:21:55 +02:00
|
|
|
; wait for reset to complete
|
2012-03-08 09:33:38 +01:00
|
|
|
mov esi, 2000 ; 2000ms = 2s
|
|
|
|
call delay_ms
|
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
call e3c59x_mdio_read ; returns with window #4
|
|
|
|
test ah, 0x80
|
|
|
|
jnz .fail_finish
|
|
|
|
pop eax
|
|
|
|
push eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; wait for a while after reset
|
2012-03-08 09:33:38 +01:00
|
|
|
mov esi, 20 ; 20ms
|
|
|
|
call delay_ms
|
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
mov al, E3C59X_REG_MII_BMSR
|
|
|
|
call e3c59x_mdio_read ; returns with window #4
|
|
|
|
test al, 1 ; extended capability supported?
|
|
|
|
jz .no_ext_cap
|
2010-10-01 11:21:55 +02:00
|
|
|
; auto-neg capable?
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, 1000b
|
|
|
|
jz .fail_finish ; not auto-negotiation capable
|
2010-10-01 11:21:55 +02:00
|
|
|
; auto-neg complete?
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, 100000b
|
|
|
|
jnz .auto_neg_ok
|
2010-10-01 11:21:55 +02:00
|
|
|
; restart auto-negotiation
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
mov al, E3C59X_REG_MII_ANAR
|
|
|
|
push eax
|
|
|
|
call e3c59x_mdio_read ; returns with window #4
|
|
|
|
or ax, (1111b shl 5) ; advertise only 10base-T and 100base-TX
|
|
|
|
mov ebx, eax
|
|
|
|
pop eax
|
|
|
|
call e3c59x_mdio_write ; returns with window #4
|
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
call e3c59x_mdio_read ; returns with window #4
|
|
|
|
mov ebx, eax
|
|
|
|
or bh, 10010b ; restart auto-negotiation
|
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
call e3c59x_mdio_write ; returns with window #4
|
|
|
|
mov esi, 4000 ; 4000ms = 4 seconds
|
|
|
|
call delay_ms
|
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
mov al, E3C59X_REG_MII_BMSR
|
|
|
|
call e3c59x_mdio_read ; returns with window #4
|
|
|
|
test al, 100000b ; auto-neg complete?
|
|
|
|
jnz .auto_neg_ok
|
|
|
|
jmp .fail_finish
|
2010-10-01 11:21:55 +02:00
|
|
|
.auto_neg_ok:
|
|
|
|
; compare advertisement and link partner ability registers
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
mov al, E3C59X_REG_MII_ANAR
|
|
|
|
call e3c59x_mdio_read ; returns with window #4
|
|
|
|
xchg eax, [esp]
|
|
|
|
mov al, E3C59X_REG_MII_ANLPAR
|
|
|
|
call e3c59x_mdio_read ; returns with window #4
|
|
|
|
pop ebx
|
|
|
|
and eax, ebx
|
|
|
|
and eax, 1111100000b
|
|
|
|
push eax
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
mov word [e3c59x_link_type], ax
|
2010-10-01 11:21:55 +02:00
|
|
|
end if ; defined E3C59X_DEBUG
|
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; set full-duplex mode
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MAC_CONTROL]
|
|
|
|
in ax, dx
|
|
|
|
and ax, not 0x120 ; clear full duplex and flow control
|
|
|
|
pop ebx
|
|
|
|
test ebx, (1010b shl 5) ; check for full-duplex
|
|
|
|
jz .half_duplex
|
|
|
|
or ax, 0x120 ; set full duplex and flow control
|
2010-10-01 11:21:55 +02:00
|
|
|
.half_duplex:
|
2012-03-08 09:33:38 +01:00
|
|
|
out dx, ax
|
|
|
|
mov al, 1
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
.no_ext_cap:
|
|
|
|
; not yet implemented BCM5000
|
|
|
|
.fail_finish:
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
xor al, al
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_try_mii
|
|
|
|
; Description
|
|
|
|
; e3c59x_try_MII checks the on-chip auto-negotiation logic
|
|
|
|
; or an off-chip MII PHY, depending upon what is set in
|
|
|
|
; xcvrSelect by the caller.
|
|
|
|
; It exits when it finds the first device with a good link.
|
|
|
|
; Parameters
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; al - 0
|
|
|
|
; al - 1
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_try_mii:
|
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
|
|
|
lea edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]
|
|
|
|
in eax, dx
|
|
|
|
and eax, (1111b shl 20)
|
|
|
|
cmp eax, (1000b shl 20) ; is auto-negotiation set?
|
|
|
|
jne .mii_device
|
2010-10-01 11:21:55 +02:00
|
|
|
; auto-negotiation is set
|
|
|
|
; switch to register window 4
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+4
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; PHY==24 is the on-chip auto-negotiation logic
|
|
|
|
; it supports only 10base-T and 100base-TX
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ah, 24
|
|
|
|
call e3c59x_try_phy
|
|
|
|
test al, al
|
|
|
|
jz .fail_finish
|
|
|
|
mov cl, 24
|
|
|
|
jmp .check_preamble
|
2010-10-01 11:21:55 +02:00
|
|
|
.mii_device:
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp eax, (0110b shl 20)
|
|
|
|
jne .fail_finish
|
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+4
|
|
|
|
out dx, ax
|
|
|
|
lea edx, [ebp+E3C59X_REG_PHYSICAL_MGMT]
|
|
|
|
in ax, dx
|
|
|
|
and al, (1 shl E3C59X_BIT_MGMT_DIR) or (1 shl E3C59X_BIT_MGMT_DATA)
|
|
|
|
cmp al, (1 shl E3C59X_BIT_MGMT_DATA)
|
|
|
|
je .serch_for_phy
|
|
|
|
xor al, al
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
.serch_for_phy:
|
|
|
|
; search for PHY
|
2012-03-08 09:33:38 +01:00
|
|
|
mov cl, 31
|
2010-10-01 11:21:55 +02:00
|
|
|
.search_phy_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp cl, 24
|
|
|
|
je .next_phy
|
|
|
|
mov ah, cl ; ah = phy
|
|
|
|
mov al, E3C59X_REG_MII_BMCR ; al = Basic Mode Status Register
|
|
|
|
push ecx
|
|
|
|
call e3c59x_mdio_read
|
|
|
|
pop ecx
|
|
|
|
test ax, ax
|
|
|
|
jz .next_phy
|
|
|
|
cmp ax, 0xffff
|
|
|
|
je .next_phy
|
|
|
|
mov ah, cl ; ah = phy
|
|
|
|
push ecx
|
|
|
|
call e3c59x_try_phy
|
|
|
|
pop ecx
|
|
|
|
test al, al
|
|
|
|
jnz .check_preamble
|
2010-10-01 11:21:55 +02:00
|
|
|
.next_phy:
|
2012-03-08 09:33:38 +01:00
|
|
|
dec cl
|
|
|
|
jns .search_phy_loop
|
2010-10-01 11:21:55 +02:00
|
|
|
.fail_finish:
|
2012-03-08 09:33:38 +01:00
|
|
|
xor al, al
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
; epilog
|
|
|
|
.check_preamble:
|
2012-03-08 09:33:38 +01:00
|
|
|
push eax ; eax contains the return value of e3c59x_try_phy
|
2010-10-01 11:21:55 +02:00
|
|
|
; check hard coded preamble forcing
|
2012-03-08 09:33:38 +01:00
|
|
|
movzx eax, byte [e3c59x_ver_id]
|
|
|
|
test word [eax*4+e3c59x_hw_versions+2], EXTRA_PREAMBLE
|
|
|
|
setnz [e3c59x_preamble] ; force preamble
|
|
|
|
jnz .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
; check mii for preamble suppression
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ah, cl
|
|
|
|
mov al, E3C59X_REG_MII_BMSR
|
|
|
|
call e3c59x_mdio_read
|
|
|
|
test al, 1000000b ; preamble suppression?
|
|
|
|
setz [e3c59x_preamble] ; no
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_test_packet
|
|
|
|
; Description
|
|
|
|
; e3c59x_try_loopback try a loopback packet for 10BASE2 or AUI port
|
|
|
|
; Parameters
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; al - 0
|
|
|
|
; al - 1
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, edi, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_test_packet:
|
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; set fullDuplexEnable in MacControl register
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MAC_CONTROL]
|
|
|
|
in ax, dx
|
|
|
|
or ax, 0x120
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 5
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+5
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; set RxFilter to enable individual address matches
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (10000b shl 11)
|
|
|
|
lea edx, [ebp+E3C59X_REG_RX_FILTER]
|
|
|
|
in al, dx
|
|
|
|
or al, 1
|
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; issue RxEnable and TxEnable
|
2012-03-08 09:33:38 +01:00
|
|
|
call e3c59x_rx_reset
|
|
|
|
call e3c59x_tx_reset
|
2010-10-01 11:21:55 +02:00
|
|
|
; download a self-directed test packet
|
2012-03-08 09:33:38 +01:00
|
|
|
mov edi, node_addr
|
|
|
|
mov bx, 0x0608 ; packet type
|
|
|
|
mov esi, e3c59x_self_directed_packet
|
|
|
|
mov ecx, 6 ; 6 + 6 + 2 + 6 = 20 bytes
|
|
|
|
call dword [e3c59x_transmit_function]
|
2010-10-01 11:21:55 +02:00
|
|
|
; wait for 2s
|
2012-03-08 09:33:38 +01:00
|
|
|
mov esi, 2000 ; 2000ms = 2s
|
|
|
|
call delay_ms
|
2010-10-01 11:21:55 +02:00
|
|
|
; check if self-directed packet is received
|
2012-03-08 09:33:38 +01:00
|
|
|
call dword [e3c59x_receive_function]
|
|
|
|
test al, al
|
|
|
|
jnz .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; clear fullDuplexEnable in MacControl register
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MAC_CONTROL]
|
|
|
|
in ax, dx
|
|
|
|
and ax, not 0x120
|
|
|
|
out dx, ax
|
|
|
|
xor al, al
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
2012-03-08 09:33:38 +01:00
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_try_loopback
|
|
|
|
; Description
|
|
|
|
; tries a loopback packet for 10BASE2 or AUI port
|
|
|
|
; Parameters
|
|
|
|
; al - 0: 10Mbps AUI connector
|
|
|
|
; 1: 10BASE-2
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; al - 0
|
|
|
|
; al - 1
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, edi, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_try_loopback:
|
2012-03-08 09:33:38 +01:00
|
|
|
push eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
|
|
|
pop eax
|
|
|
|
push eax
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
mov bl, al
|
|
|
|
inc bl
|
|
|
|
shl bl, 3
|
|
|
|
or byte [e3c59x_link_type+1], bl
|
2010-10-01 11:21:55 +02:00
|
|
|
end if ; defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, al ; aui or coax?
|
|
|
|
jz .complete_loopback
|
2010-10-01 11:21:55 +02:00
|
|
|
; enable 100BASE-2 DC-DC converter
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (10b shl 11) ; EnableDcConverter
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
.complete_loopback:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov cl, 2 ; give a port 3 chances to complete a loopback
|
2010-10-01 11:21:55 +02:00
|
|
|
.next_try:
|
2012-03-08 09:33:38 +01:00
|
|
|
push ecx
|
|
|
|
call e3c59x_test_packet
|
|
|
|
pop ecx
|
|
|
|
test al, al
|
|
|
|
jnz .finish
|
|
|
|
dec cl
|
|
|
|
jns .next_try
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
2012-03-08 09:33:38 +01:00
|
|
|
xchg eax, [esp]
|
|
|
|
test al, al
|
|
|
|
jz .aui_finish
|
2010-10-01 11:21:55 +02:00
|
|
|
; issue DisableDcConverter command
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (10111b shl 11)
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
.aui_finish:
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax ; al contains the result of operation
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, al
|
|
|
|
jnz @f
|
|
|
|
and byte [e3c59x_link_type+1], not 11000b
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
|
|
|
end if ; defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_set_available_media
|
|
|
|
; Description
|
|
|
|
; sets the first available media
|
|
|
|
; Parameters
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; al - 0
|
|
|
|
; al - 1
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, edx
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_set_available_media:
|
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
|
|
|
lea edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]
|
|
|
|
in eax, dx
|
|
|
|
push eax
|
|
|
|
lea edx, [ebp+E3C59X_REG_MEDIA_OPTIONS]
|
|
|
|
in ax, dx
|
|
|
|
test al, 10b
|
|
|
|
jz @f
|
2010-10-01 11:21:55 +02:00
|
|
|
; baseTXAvailable
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (100b shl 20)
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG & defined E3C59X_FORCE_FD
|
2012-03-08 09:33:38 +01:00
|
|
|
mov word [e3c59x_link_type], (1 shl 8)
|
2010-10-01 11:21:55 +02:00
|
|
|
else if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
mov word [e3c59x_link_type], (1 shl 7)
|
2010-10-01 11:21:55 +02:00
|
|
|
end if
|
2012-03-08 09:33:38 +01:00
|
|
|
jmp .set_media
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, 100b
|
|
|
|
jz @f
|
2010-10-01 11:21:55 +02:00
|
|
|
; baseFXAvailable
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (101b shl 20)
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
mov word [e3c59x_link_type], (1 shl 10)
|
2010-10-01 11:21:55 +02:00
|
|
|
end if
|
2012-03-08 09:33:38 +01:00
|
|
|
jmp .set_media
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, 1000000b
|
|
|
|
jz @f
|
2010-10-01 11:21:55 +02:00
|
|
|
; miiDevice
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (0110b shl 20)
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
mov word [e3c59x_link_type], (1 shl 13)
|
2010-10-01 11:21:55 +02:00
|
|
|
end if
|
2012-03-08 09:33:38 +01:00
|
|
|
jmp .set_media
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, 1000b
|
|
|
|
jz @f
|
2010-10-01 11:21:55 +02:00
|
|
|
.set_default:
|
|
|
|
; 10bTAvailable
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
and eax, not (1111b shl 20)
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG & defined E3C59X_FORCE_FD
|
2012-03-08 09:33:38 +01:00
|
|
|
mov word [e3c59x_link_type], (1 shl 6)
|
2010-10-01 11:21:55 +02:00
|
|
|
else if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
mov word [e3c59x_link_type], (1 shl 5)
|
2010-10-01 11:21:55 +02:00
|
|
|
end if ; E3C59X_FORCE_FD
|
2012-03-08 09:33:38 +01:00
|
|
|
jmp .set_media
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, 10000b
|
|
|
|
jz @f
|
2010-10-01 11:21:55 +02:00
|
|
|
; coaxAvailable
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (10b shl 11) ; EnableDcConverter
|
|
|
|
out dx, ax
|
|
|
|
pop eax
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (11b shl 20)
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
mov word [e3c59x_link_type], (1 shl 12)
|
2010-10-01 11:21:55 +02:00
|
|
|
end if ; defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
jmp .set_media
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
test al, 10000b
|
|
|
|
jz .set_default
|
2010-10-01 11:21:55 +02:00
|
|
|
; auiAvailable
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (1 shl 20)
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
mov word [e3c59x_link_type], (1 shl 11)
|
2010-10-01 11:21:55 +02:00
|
|
|
end if ; defined E3C59X_DEBUG
|
|
|
|
.set_media:
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]
|
|
|
|
out dx, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_FORCE_FD
|
|
|
|
; set fullDuplexEnable in MacControl register
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MAC_CONTROL]
|
|
|
|
in ax, dx
|
|
|
|
or ax, 0x120
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
end if ; E3C59X_FORCE_FD
|
2012-03-08 09:33:38 +01:00
|
|
|
mov al, 1
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_set_active_port
|
|
|
|
; Description
|
|
|
|
; It selects the media port (transceiver) to be used
|
|
|
|
; Parameters:
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value:
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, edi, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_set_active_port:
|
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
|
|
|
lea edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]
|
|
|
|
in eax, dx
|
|
|
|
test eax, (1 shl 24) ; check if autoselect enable
|
|
|
|
jz .set_first_available_media
|
2010-10-01 11:21:55 +02:00
|
|
|
; check 100BASE-TX and 10BASE-T
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MEDIA_OPTIONS]
|
|
|
|
in ax, dx
|
|
|
|
test al, 1010b ; check whether 100BASE-TX or 10BASE-T available
|
|
|
|
jz .mii_device ; they are not available
|
2010-10-01 11:21:55 +02:00
|
|
|
; set auto-negotiation
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]
|
|
|
|
in eax, dx
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (1000b shl 20)
|
|
|
|
out dx, eax
|
|
|
|
call e3c59x_try_mii
|
|
|
|
test al, al
|
|
|
|
jz .mii_device
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
.mii_device:
|
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; check for off-chip mii device
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MEDIA_OPTIONS]
|
|
|
|
in ax, dx
|
|
|
|
test al, 1000000b ; check miiDevice
|
|
|
|
jz .base_fx
|
|
|
|
lea edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]
|
|
|
|
in eax, dx
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (0110b shl 20) ; set MIIDevice
|
|
|
|
out dx, eax
|
|
|
|
call e3c59x_try_mii
|
|
|
|
test al, al
|
|
|
|
jz .base_fx
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
.base_fx:
|
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; check for 100BASE-FX
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MEDIA_OPTIONS]
|
|
|
|
in ax, dx ; read media option register
|
|
|
|
test al, 100b ; check 100BASE-FX
|
|
|
|
jz .aui_enable
|
|
|
|
lea edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]
|
|
|
|
in eax, dx
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (0101b shl 20) ; set 100base-FX
|
|
|
|
out dx, eax
|
|
|
|
call e3c59x_try_link_detect
|
|
|
|
test al, al
|
|
|
|
jz .aui_enable
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
.aui_enable:
|
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; check for 10Mbps AUI connector
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MEDIA_OPTIONS]
|
|
|
|
in ax, dx ; read media option register
|
|
|
|
test al, 100000b ; check 10Mbps AUI connector
|
|
|
|
jz .coax_available
|
|
|
|
lea edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]
|
|
|
|
in eax, dx
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (0001b shl 20) ; set 10Mbps AUI connector
|
|
|
|
out dx, eax
|
|
|
|
xor al, al ; try 10Mbps AUI connector
|
|
|
|
call e3c59x_try_loopback
|
|
|
|
test al, al
|
|
|
|
jz .coax_available
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
.coax_available:
|
|
|
|
; switch to register window 3
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+3
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; check for coaxial 10BASE-2 port
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MEDIA_OPTIONS]
|
|
|
|
in ax, dx ; read media option register
|
|
|
|
test al, 10000b ; check 10BASE-2
|
|
|
|
jz .set_first_available_media
|
|
|
|
lea edx, [ebp+E3C59X_REG_INTERNAL_CONFIG]
|
|
|
|
in eax, dx
|
|
|
|
and eax, not (1111b shl 20)
|
|
|
|
or eax, (0011b shl 20) ; set 10BASE-2
|
|
|
|
out dx, eax
|
|
|
|
mov al, 1
|
|
|
|
call e3c59x_try_loopback
|
|
|
|
test al, al
|
|
|
|
jz .set_first_available_media
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
.set_first_available_media:
|
2012-03-08 09:33:38 +01:00
|
|
|
jmp e3c59x_set_available_media
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_wake_up
|
|
|
|
; Description
|
|
|
|
; set the power state to D0
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, edi, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_wake_up:
|
|
|
|
; wake up - we directly do it by programming PCI
|
|
|
|
; check if the device is power management capable
|
2012-03-08 09:33:38 +01:00
|
|
|
mov al, 2
|
|
|
|
mov ah, [pci_bus]
|
|
|
|
mov bl, PCI_REG_STATUS
|
|
|
|
mov bh, [pci_dev]
|
|
|
|
push eax ebx
|
|
|
|
call pci_read_reg
|
|
|
|
test al, 10000b ; is there "new capabilities" linked list?
|
|
|
|
pop ebx eax
|
|
|
|
jz .device_awake
|
2010-10-01 11:21:55 +02:00
|
|
|
; search for power management register
|
2012-03-08 09:33:38 +01:00
|
|
|
mov al, 1
|
|
|
|
mov bl, PCI_REG_CAP_PTR
|
|
|
|
push eax ebx
|
|
|
|
call pci_read_reg
|
|
|
|
mov cl, al
|
|
|
|
cmp cl, 0x3f
|
|
|
|
pop ebx eax
|
|
|
|
jbe .device_awake
|
2010-10-01 11:21:55 +02:00
|
|
|
; traverse the list
|
2012-03-08 09:33:38 +01:00
|
|
|
mov al, 2
|
2010-10-01 11:21:55 +02:00
|
|
|
.pm_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov bl, cl
|
|
|
|
push eax ebx
|
|
|
|
call pci_read_reg
|
|
|
|
cmp al, 1
|
|
|
|
je .set_pm_state
|
|
|
|
test ah, ah
|
|
|
|
mov cl, ah
|
|
|
|
pop ebx eax
|
|
|
|
jnz .pm_loop
|
|
|
|
jmp .device_awake
|
2010-10-01 11:21:55 +02:00
|
|
|
; waku up the device if necessary
|
|
|
|
.set_pm_state:
|
2012-03-08 09:33:38 +01:00
|
|
|
pop ebx eax
|
|
|
|
add bl, PCI_REG_PM_CTRL
|
|
|
|
push eax ebx
|
|
|
|
call pci_read_reg
|
|
|
|
mov cx, ax
|
|
|
|
test cl, 3
|
|
|
|
pop ebx eax
|
|
|
|
jz .device_awake
|
|
|
|
and cl, not 11b ; set state to D0
|
|
|
|
call pci_write_reg
|
2010-10-01 11:21:55 +02:00
|
|
|
.device_awake:
|
2012-03-08 09:33:38 +01:00
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_probe
|
|
|
|
; Description
|
|
|
|
; Searches for an ethernet card, enables it and clears the rx buffer
|
|
|
|
; If a card was found, it enables the ethernet -> TCPIP link
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, edi, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_probe:
|
2012-03-08 09:33:38 +01:00
|
|
|
movzx ebp, word [io_addr]
|
|
|
|
mov al, 2
|
|
|
|
mov ah, [pci_bus]
|
|
|
|
mov bh, [pci_dev]
|
|
|
|
mov bl, PCI_REG_COMMAND
|
|
|
|
push ebp eax ebx
|
|
|
|
call pci_read_reg
|
|
|
|
mov cx, ax
|
|
|
|
or cl, (1 shl PCI_BIT_MASTER) or (1 shl PCI_BIT_PIO)
|
|
|
|
and cl, not (1 shl PCI_BIT_MMIO)
|
|
|
|
pop ebx eax
|
|
|
|
call pci_write_reg
|
2010-10-01 11:21:55 +02:00
|
|
|
; wake up the card
|
2012-03-08 09:33:38 +01:00
|
|
|
call e3c59x_wake_up
|
|
|
|
pop ebp
|
2010-10-01 11:21:55 +02:00
|
|
|
; get chip version
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, [pci_data+2]
|
|
|
|
mov ecx, E3C59X_HW_VERSIONS_SIZE/4-1
|
2010-10-01 11:21:55 +02:00
|
|
|
.chip_ver_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp ax, [e3c59x_hw_versions+ecx*4]
|
|
|
|
jz .chip_ver_found
|
|
|
|
dec ecx
|
|
|
|
jns .chip_ver_loop
|
|
|
|
xor ecx, ecx
|
2010-10-01 11:21:55 +02:00
|
|
|
.chip_ver_found:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov [e3c59x_ver_id], cl
|
|
|
|
test word [e3c59x_hw_versions+2+ecx*4], HAS_HWCKSM
|
|
|
|
setnz [e3c59x_has_hwcksm]
|
2010-10-01 11:21:55 +02:00
|
|
|
; set pci latency for vortex cards
|
2012-03-08 09:33:38 +01:00
|
|
|
test word [e3c59x_hw_versions+2+ecx*4], IS_VORTEX
|
|
|
|
jz .not_vortex
|
|
|
|
mov cx, 11111000b ; 248 = max latency
|
|
|
|
mov al, 1
|
|
|
|
mov ah, [pci_bus]
|
|
|
|
mov bl, PCI_REG_LATENCY
|
|
|
|
mov bh, [pci_dev]
|
|
|
|
call pci_write_reg
|
2010-10-01 11:21:55 +02:00
|
|
|
.not_vortex:
|
|
|
|
; set RX/TX functions
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, E3C59X_EEPROM_REG_CAPABILITIES
|
|
|
|
call e3c59x_read_eeprom
|
|
|
|
test al, 100000b ; full bus master?
|
|
|
|
setnz [e3c59x_full_bus_master]
|
|
|
|
jnz .boomerang_func
|
|
|
|
mov dword [e3c59x_transmit_function], e3c59x_vortex_transmit
|
|
|
|
mov dword [e3c59x_receive_function], e3c59x_vortex_poll
|
|
|
|
jmp @f
|
2010-10-01 11:21:55 +02:00
|
|
|
.boomerang_func: ; full bus master, so use boomerang functions
|
2012-03-08 09:33:38 +01:00
|
|
|
mov dword [e3c59x_transmit_function], e3c59x_boomerang_transmit
|
|
|
|
mov dword [e3c59x_receive_function], e3c59x_boomerang_poll
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
|
|
|
; read MAC from eeprom
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ecx, 2
|
2010-10-01 11:21:55 +02:00
|
|
|
.mac_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
lea ax, [E3C59X_EEPROM_REG_OEM_NODE_ADDR+ecx]
|
|
|
|
call e3c59x_read_eeprom
|
|
|
|
xchg ah, al ; htons
|
|
|
|
mov [node_addr+ecx*2], ax
|
|
|
|
dec ecx
|
|
|
|
jns .mac_loop
|
|
|
|
test byte [e3c59x_full_bus_master], 0xff
|
|
|
|
jz .set_preamble
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 2
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+2
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; activate xcvr by setting some magic bits
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_RESET_OPTIONS]
|
|
|
|
in ax, dx
|
|
|
|
and ax, not 0x4010
|
|
|
|
movzx ebx, byte [e3c59x_ver_id]
|
|
|
|
test word [ebx*4+e3c59x_hw_versions+2], INVERT_LED_PWR
|
|
|
|
jz @f
|
|
|
|
or al, 0x10
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
test word [ebx*4+e3c59x_hw_versions+2], INVERT_MII_PWR
|
|
|
|
jz @f
|
|
|
|
or ah, 0x40
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
.set_preamble:
|
|
|
|
; use preamble as default
|
2012-03-08 09:33:38 +01:00
|
|
|
mov byte [e3c59x_preamble], 1 ; enable preamble
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_reset
|
|
|
|
; Description
|
|
|
|
; Place the chip (ie, the ethernet card) into a virgin state
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, edi, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
|
|
|
e3c59x_reset:
|
|
|
|
; issue global reset
|
2012-03-08 09:33:38 +01:00
|
|
|
call e3c59x_global_reset
|
2010-10-01 11:21:55 +02:00
|
|
|
; disable interrupts
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (1110b shl 11)
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; enable Statistics
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (10101b shl 11)
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; set indication
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (1111b shl 11) or 0x6c6
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; acknowledge (clear) every interrupt indicator
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (1101b shl 11) or 0x661
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 2
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+2
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; write MAC addres back into the station address registers
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_STATION_ADDRESS_LO]
|
|
|
|
mov esi, node_addr
|
|
|
|
cld
|
|
|
|
outsw
|
|
|
|
add edx, 2
|
|
|
|
outsw
|
|
|
|
add edx, 2
|
|
|
|
outsw
|
|
|
|
add edx, 2
|
2010-10-01 11:21:55 +02:00
|
|
|
; clear station mask
|
2012-03-08 09:33:38 +01:00
|
|
|
xor eax, eax
|
|
|
|
out dx, ax
|
|
|
|
add edx, 2
|
|
|
|
out dx, ax
|
|
|
|
add edx, 2
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 6
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+6
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; clear all statistics by reading
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_CARRIER_LOST]
|
|
|
|
mov cl, 9
|
2010-10-01 11:21:55 +02:00
|
|
|
.stat_clearing_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
in al, dx
|
|
|
|
inc edx
|
|
|
|
dec cl
|
|
|
|
jns .stat_clearing_loop
|
|
|
|
in ax, dx
|
|
|
|
add dx, 2
|
|
|
|
in ax, dx
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 4
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+4
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; clear BadSSD
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_BAD_SSD]
|
|
|
|
in al, dx
|
2010-10-01 11:21:55 +02:00
|
|
|
; clear extra statistics bit in NetworkDiagnostic
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_NETWORK_DIAGNOSTIC]
|
|
|
|
in ax, dx
|
|
|
|
or ax, 0x0040
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; SetRxEarlyThreshold
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (10001b shl 11)+(E3C59X_MAX_ETH_PKT_SIZE shr 2)
|
|
|
|
out dx, ax
|
|
|
|
test byte [e3c59x_full_bus_master], 0xff
|
|
|
|
jz .skip_boomerang_setting
|
2010-10-01 11:21:55 +02:00
|
|
|
; set upRxEarlyEnable
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_DMA_CTRL]
|
|
|
|
in eax, dx
|
|
|
|
or eax, 0x20
|
|
|
|
out dx, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; TxFreeThreshold
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_TX_FREE_THRESH]
|
|
|
|
mov al, (E3C59X_MAX_ETH_PKT_SIZE / 256)
|
|
|
|
out dx, al
|
2010-10-01 11:21:55 +02:00
|
|
|
; program DnListPtr
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_DN_LIST_PTR]
|
|
|
|
xor eax, eax
|
|
|
|
out dx, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
.skip_boomerang_setting:
|
|
|
|
; initialization
|
2012-03-08 09:33:38 +01:00
|
|
|
call e3c59x_rx_reset
|
|
|
|
call e3c59x_tx_reset
|
|
|
|
call e3c59x_set_active_port
|
|
|
|
call e3c59x_rx_reset
|
|
|
|
call e3c59x_tx_reset
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 5
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+5
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; program RxFilter for promiscuous operation
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (10000b shl 11)
|
|
|
|
lea edx, [ebp+E3C59X_REG_RX_FILTER]
|
|
|
|
in al, dx
|
|
|
|
or al, 1111b
|
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 4
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+4
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; wait for linkDetect
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MEDIA_STATUS]
|
|
|
|
mov cl, 20 ; wait for max 2s
|
|
|
|
mov esi, 100 ; 100ms
|
2010-10-01 11:21:55 +02:00
|
|
|
.link_detect_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
call delay_ms
|
|
|
|
in ax, dx
|
|
|
|
test ah, 1000b ; linkDetect
|
|
|
|
jnz @f
|
|
|
|
dec cl
|
|
|
|
jnz .link_detect_loop
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
|
|
|
; Indicate that we have successfully reset the card
|
2012-03-08 09:33:38 +01:00
|
|
|
mov eax, [pci_data]
|
|
|
|
mov [eth_status], eax
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
call e3c59x_debug
|
2010-10-01 11:21:55 +02:00
|
|
|
end if ; defined E3C59X_DEBUG
|
2012-03-08 09:33:38 +01:00
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_global_reset
|
|
|
|
; Description
|
|
|
|
; resets the device
|
|
|
|
; Parameters:
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value:
|
|
|
|
; Destroyed registers
|
|
|
|
; ax, ecx, edx, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_global_reset:
|
|
|
|
; GlobalReset
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
xor eax, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; or al, 0x14
|
2012-03-08 09:33:38 +01:00
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; wait for GlobalReset to complete
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ecx, 64000
|
2010-10-01 11:21:55 +02:00
|
|
|
.global_reset_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
in ax, dx
|
|
|
|
test ah, 10000b ; check CmdInProgress
|
|
|
|
jz .finish
|
|
|
|
dec ecx
|
|
|
|
jnz .global_reset_loop
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
|
|
|
; wait for 2 seconds for NIC to boot
|
2012-03-08 09:33:38 +01:00
|
|
|
mov esi, 2000 ; 2000ms = 2s
|
|
|
|
push ebp
|
|
|
|
call delay_ms
|
|
|
|
pop ebp
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_tx_reset
|
|
|
|
; Description
|
|
|
|
; resets and enables transmitter engine
|
|
|
|
; Parameters:
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value:
|
|
|
|
; Destroyed registers
|
|
|
|
; ax, ecx, edx
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_tx_reset:
|
|
|
|
; TxReset
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (01011b shl 11)
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; Wait for TxReset to complete
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ecx, 200000
|
2010-10-01 11:21:55 +02:00
|
|
|
.tx_reset_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
in ax, dx
|
|
|
|
test ah, 10000b ; check CmdInProgress
|
|
|
|
jz .tx_set_prev
|
|
|
|
dec ecx
|
|
|
|
jns .tx_reset_loop
|
2010-10-01 11:21:55 +02:00
|
|
|
.tx_set_prev:
|
2012-03-08 09:33:38 +01:00
|
|
|
test byte [e3c59x_full_bus_master], 0xff
|
|
|
|
jz .tx_enable
|
2010-10-01 11:21:55 +02:00
|
|
|
; init last_dpd
|
2012-03-08 09:33:38 +01:00
|
|
|
mov dword [e3c59x_prev_dpd], e3c59x_dpd_buff+(E3C59X_NUM_TX_DESC-1)*E3C59X_DPD_SIZE
|
|
|
|
mov dword [e3c59x_prev_tx_frame], e3c59x_tx_buff+(E3C59X_NUM_TX_DESC-1)*E3C59X_MAX_ETH_FRAME_SIZE
|
2010-10-01 11:21:55 +02:00
|
|
|
.tx_enable:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (01001b shl 11) ; TxEnable
|
|
|
|
out dx, ax
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_rx_reset
|
|
|
|
; Description
|
|
|
|
; resets and enables receiver engine
|
|
|
|
; Parameters:
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value:
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, edi, esi
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_rx_reset:
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (0101b shl 11) or 0x4 ; RxReset
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; wait for RxReset to complete
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ecx, 200000
|
2010-10-01 11:21:55 +02:00
|
|
|
.rx_reset_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
in ax, dx
|
|
|
|
test ah, 10000b ; check CmdInProgress
|
|
|
|
jz .setup_upd
|
|
|
|
dec ecx
|
|
|
|
jns .rx_reset_loop
|
2010-10-01 11:21:55 +02:00
|
|
|
.setup_upd:
|
|
|
|
; check if full bus mastering
|
2012-03-08 09:33:38 +01:00
|
|
|
test byte [e3c59x_full_bus_master], 0xff
|
|
|
|
jz .rx_enable
|
2010-10-01 11:21:55 +02:00
|
|
|
; create upd ring
|
2012-03-08 09:33:38 +01:00
|
|
|
mov eax, e3c59x_upd_buff
|
|
|
|
zero_to_virt eax
|
|
|
|
mov [e3c59x_curr_upd], eax
|
|
|
|
mov esi, eax
|
|
|
|
virt_to_dma esi
|
|
|
|
mov edi, e3c59x_rx_buff
|
|
|
|
zero_to_dma edi
|
|
|
|
mov ebx, e3c59x_upd_buff+(E3C59X_NUM_RX_DESC-1)*E3C59X_UPD_SIZE
|
|
|
|
zero_to_virt ebx
|
|
|
|
mov cl, E3C59X_NUM_RX_DESC-1
|
2010-10-01 11:21:55 +02:00
|
|
|
.upd_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov [ebx+E3C59X_UPD_UP_NEXT_PTR], esi
|
|
|
|
and dword [eax+E3C59X_UPD_PKT_STATUS], 0
|
|
|
|
mov [eax+E3C59X_UPD_UP_FRAG_ADDR], edi
|
|
|
|
mov dword [eax+E3C59X_UPD_UP_FRAG_LEN], E3C59X_MAX_ETH_FRAME_SIZE or (1 shl 31)
|
|
|
|
add edi, E3C59X_MAX_ETH_FRAME_SIZE
|
|
|
|
add esi, E3C59X_UPD_SIZE
|
|
|
|
mov ebx, eax
|
|
|
|
add eax, E3C59X_UPD_SIZE
|
|
|
|
dec cl
|
|
|
|
jns .upd_loop
|
|
|
|
mov eax, e3c59x_upd_buff
|
|
|
|
zero_to_dma eax
|
|
|
|
lea edx, [ebp+E3C59X_REG_UP_LIST_PTR]
|
|
|
|
out dx, eax ; write E3C59X_REG_UP_LIST_PTR
|
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
2010-10-01 11:21:55 +02:00
|
|
|
.rx_enable:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (00100b shl 11) ; RxEnable
|
|
|
|
out dx, ax
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_write_eeprom
|
|
|
|
; Description
|
|
|
|
; reads eeprom
|
|
|
|
; Note : the caller must switch to the register window 0
|
|
|
|
; before calling this function
|
|
|
|
; Parameters:
|
|
|
|
; ax - register to be read (only the first 63 words can be read)
|
|
|
|
; cx - value to be read into the register
|
|
|
|
; Return value:
|
|
|
|
; ax - word read
|
|
|
|
; Destroyed registers
|
|
|
|
; ax, ebx, edx
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
|
|
|
; align 4
|
|
|
|
;e3c59x_write_eeprom:
|
|
|
|
; mov edx, [io_addr]
|
|
|
|
; add edx, E3C59X_REG_EEPROM_COMMAND
|
|
|
|
; cmp ah, 11b
|
|
|
|
; ja .finish ; address may have a value of maximal 1023
|
|
|
|
; shl ax, 2
|
|
|
|
; shr al, 2
|
|
|
|
; push eax
|
|
|
|
;; wait for busy
|
|
|
|
; mov ebx, 0xffff
|
|
|
|
;@@:
|
|
|
|
; in ax, dx
|
|
|
|
; test ah, 0x80
|
|
|
|
; jz .write_enable
|
|
|
|
; dec ebx
|
|
|
|
; jns @r
|
|
|
|
;; write enable
|
|
|
|
;.write_enable:
|
|
|
|
; xor eax, eax
|
|
|
|
; mov eax, (11b shl 4)
|
|
|
|
; out dx, ax
|
|
|
|
;; wait for busy
|
|
|
|
; mov ebx, 0xffff
|
|
|
|
;@@:
|
|
|
|
; in ax, dx
|
|
|
|
; test ah, 0x80
|
|
|
|
; jz .erase_loop
|
|
|
|
; dec ebx
|
|
|
|
; jns @r
|
|
|
|
;.erase_loop:
|
|
|
|
; pop eax
|
|
|
|
; push eax
|
|
|
|
; or ax, (11b shl 6) ; erase register
|
|
|
|
; out dx, ax
|
|
|
|
; mov ebx, 0xffff
|
|
|
|
;@@:
|
|
|
|
; in ax, dx
|
|
|
|
; test ah, 0x80
|
|
|
|
; jz .write_reg
|
|
|
|
; dec ebx
|
|
|
|
; jns @r
|
|
|
|
;.write_reg:
|
|
|
|
; add edx, E3C59X_REG_EEPROM_DATA-E3C59X_REG_EEPROM_COMMAND
|
|
|
|
; mov eax, ecx
|
|
|
|
; out dx, ax
|
|
|
|
;; write enable
|
|
|
|
; add edx, E3C59X_REG_EEPROM_COMMAND-E3C59X_REG_EEPROM_DATA
|
|
|
|
; xor eax, eax
|
|
|
|
; mov eax, (11b shl 4)
|
|
|
|
; out dx, ax
|
|
|
|
; wait for busy
|
|
|
|
; mov ebx, 0xffff
|
|
|
|
;@@:
|
|
|
|
; in ax, dx
|
|
|
|
; test ah, 0x80
|
|
|
|
; jz .issue_write_reg
|
|
|
|
; dec ebx
|
|
|
|
; jns @r
|
|
|
|
;.issue_write_reg:
|
|
|
|
; pop eax
|
|
|
|
; or ax, 01b shl 6
|
|
|
|
; out dx, ax
|
|
|
|
;.finish:
|
|
|
|
; ret
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_read_eeprom
|
|
|
|
; Description
|
|
|
|
; reads eeprom
|
|
|
|
; Parameters:
|
|
|
|
; ax - register to be read (only the first 63 words can be read)
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value:
|
|
|
|
; ax - word read
|
|
|
|
; Destroyed registers
|
|
|
|
; ax, ebx, edx, ebp
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_read_eeprom:
|
2012-03-08 09:33:38 +01:00
|
|
|
push eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 0
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+0
|
|
|
|
out dx, ax
|
|
|
|
pop eax
|
|
|
|
and ax, 111111b ; take only the first 6 bits into account
|
|
|
|
movzx ebx, byte [e3c59x_ver_id]
|
|
|
|
test word [ebx*4+e3c59x_hw_versions+2], EEPROM_8BIT
|
|
|
|
jz @f
|
|
|
|
add ax, 0x230 ; hardware constant
|
|
|
|
jmp .read
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
add ax, E3C59X_EEPROM_CMD_READ
|
|
|
|
test word [ebx*4+e3c59x_hw_versions+2], EEPROM_OFFSET
|
|
|
|
jz .read
|
|
|
|
add ax, 0x30
|
2010-10-01 11:21:55 +02:00
|
|
|
.read:
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_EEPROM_COMMAND]
|
|
|
|
out dx, ax
|
|
|
|
mov ebx, 0xffff ; duration of about 162 us ;-)
|
2010-10-01 11:21:55 +02:00
|
|
|
.wait_for_reading:
|
2012-03-08 09:33:38 +01:00
|
|
|
in ax, dx
|
|
|
|
test ah, 0x80 ; check bit eepromBusy
|
|
|
|
jz .read_data
|
|
|
|
dec ebx
|
|
|
|
jns .wait_for_reading
|
2010-10-01 11:21:55 +02:00
|
|
|
.read_data:
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_EEPROM_DATA]
|
|
|
|
in ax, dx
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_mdio_sync
|
|
|
|
; Description
|
|
|
|
; initial synchronization
|
|
|
|
; Parameters
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; Destroyed registers
|
|
|
|
; ax, edx, cl
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_mdio_sync:
|
|
|
|
; switch to register window 4
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+4
|
|
|
|
out dx, ax
|
|
|
|
cmp byte [e3c59x_preamble], 0
|
|
|
|
je .no_preamble
|
2010-10-01 11:21:55 +02:00
|
|
|
; send 32 logic ones
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_PHYSICAL_MGMT]
|
|
|
|
mov cl, 31
|
2010-10-01 11:21:55 +02:00
|
|
|
.loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (1 shl E3C59X_BIT_MGMT_DATA) or (1 shl E3C59X_BIT_MGMT_DIR)
|
|
|
|
out dx, ax
|
|
|
|
in ax, dx ; delay
|
|
|
|
mov ax, (1 shl E3C59X_BIT_MGMT_DATA) \
|
|
|
|
or (1 shl E3C59X_BIT_MGMT_DIR) \
|
|
|
|
or (1 shl E3C59X_BIT_MGMT_CLK)
|
|
|
|
out dx, ax
|
|
|
|
in ax, dx ; delay
|
|
|
|
dec cl
|
|
|
|
jns .loop
|
2010-10-01 11:21:55 +02:00
|
|
|
.no_preamble:
|
2012-03-08 09:33:38 +01:00
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_mdio_read
|
|
|
|
; Description
|
|
|
|
; read MII register
|
|
|
|
; see page 16 in D83840A.pdf
|
|
|
|
; Parameters
|
|
|
|
; ah - PHY addr
|
|
|
|
; al - register addr
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; ax - register read
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, cx, edx
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_mdio_read:
|
2012-03-08 09:33:38 +01:00
|
|
|
push eax
|
|
|
|
call e3c59x_mdio_sync ; returns with window #4
|
|
|
|
pop eax
|
|
|
|
lea edx, [ebp+E3C59X_REG_PHYSICAL_MGMT]
|
|
|
|
shl al, 3
|
|
|
|
shr ax, 3
|
|
|
|
and ax, not E3C59X_MII_CMD_MASK
|
|
|
|
or ax, E3C59X_MII_CMD_READ
|
|
|
|
mov ebx, eax
|
|
|
|
xor ecx, ecx
|
|
|
|
mov cl, 13
|
2010-10-01 11:21:55 +02:00
|
|
|
.cmd_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (1 shl E3C59X_BIT_MGMT_DIR) ; write mii
|
|
|
|
bt ebx, ecx
|
|
|
|
jnc .zero_bit
|
|
|
|
or al, (1 shl E3C59X_BIT_MGMT_DATA)
|
2010-10-01 11:21:55 +02:00
|
|
|
.zero_bit:
|
2012-03-08 09:33:38 +01:00
|
|
|
out dx, ax
|
|
|
|
push eax
|
|
|
|
in ax, dx ; delay
|
|
|
|
pop eax
|
|
|
|
or al, (1 shl E3C59X_BIT_MGMT_CLK) ; write
|
|
|
|
out dx, ax
|
|
|
|
in ax, dx ; delay
|
|
|
|
dec cl
|
|
|
|
jns .cmd_loop
|
2010-10-01 11:21:55 +02:00
|
|
|
; read data (18 bits with the two transition bits)
|
2012-03-08 09:33:38 +01:00
|
|
|
mov cl, 17
|
|
|
|
xor ebx, ebx
|
2010-10-01 11:21:55 +02:00
|
|
|
.read_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
shl ebx, 1
|
|
|
|
xor eax, eax ; read comand
|
|
|
|
out dx, ax
|
|
|
|
in ax, dx ; delay
|
|
|
|
in ax, dx
|
|
|
|
test al, (1 shl E3C59X_BIT_MGMT_DATA)
|
|
|
|
jz .dont_set
|
|
|
|
inc ebx
|
2010-10-01 11:21:55 +02:00
|
|
|
.dont_set:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (1 shl E3C59X_BIT_MGMT_CLK)
|
|
|
|
out dx, ax
|
|
|
|
in ax, dx ; delay
|
|
|
|
dec cl
|
|
|
|
jns .read_loop
|
|
|
|
mov eax, ebx
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_mdio_write
|
|
|
|
; Description
|
|
|
|
; write MII register
|
|
|
|
; see page 16 in D83840A.pdf
|
|
|
|
; Parameters
|
|
|
|
; ah - PHY addr
|
|
|
|
; al - register addr
|
|
|
|
; bx - word to be written
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; ax - register read
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, cx, edx
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_mdio_write:
|
2012-03-08 09:33:38 +01:00
|
|
|
push eax
|
|
|
|
call e3c59x_mdio_sync
|
|
|
|
pop eax
|
|
|
|
lea edx, [ebp+E3C59X_REG_PHYSICAL_MGMT]
|
|
|
|
shl al, 3
|
|
|
|
shr ax, 3
|
|
|
|
and ax, not E3C59X_MII_CMD_MASK
|
|
|
|
or ax, E3C59X_MII_CMD_WRITE
|
|
|
|
shl eax, 2
|
|
|
|
or eax, 10b ; transition bits
|
|
|
|
shl eax, 16
|
|
|
|
mov ax, bx
|
|
|
|
mov ebx, eax
|
|
|
|
mov ecx, 31
|
2010-10-01 11:21:55 +02:00
|
|
|
.cmd_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ax, (1 shl E3C59X_BIT_MGMT_DIR) ; write mii
|
|
|
|
bt ebx, ecx
|
|
|
|
jnc .zero_bit
|
|
|
|
or al, (1 shl E3C59X_BIT_MGMT_DATA)
|
2010-10-01 11:21:55 +02:00
|
|
|
.zero_bit:
|
2012-03-08 09:33:38 +01:00
|
|
|
out dx, ax
|
|
|
|
push eax
|
|
|
|
in ax, dx ; delay
|
|
|
|
pop eax
|
|
|
|
or al, (1 shl E3C59X_BIT_MGMT_CLK) ; write
|
|
|
|
out dx, ax
|
|
|
|
in ax, dx ; delay
|
|
|
|
dec ecx
|
|
|
|
jns .cmd_loop
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_transmit
|
|
|
|
; Description
|
|
|
|
; Transmits a packet of data via the ethernet card
|
|
|
|
; edi - Pointer to 48 bit destination address
|
|
|
|
; bx - Type of packet
|
|
|
|
; ecx - size of packet
|
|
|
|
; esi - pointer to packet data
|
|
|
|
; ebp - io_addr
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ecx, edx, ebp
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_transmit:
|
2012-03-08 09:33:38 +01:00
|
|
|
jmp dword [e3c59x_transmit_function]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_check_tx_status
|
|
|
|
; Description
|
|
|
|
; Checks TxStatus queue.
|
|
|
|
; Return value
|
|
|
|
; al - 0 no error was found
|
|
|
|
; al - 1 error was found TxReset is needed
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ecx, edx, ebp
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
|
|
|
e3c59x_check_tx_status:
|
2012-03-08 09:33:38 +01:00
|
|
|
movzx ebp, word [io_addr] ; to be implemented in ETHERNET.INC
|
2010-10-01 11:21:55 +02:00
|
|
|
; clear TxStatus queue
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_TX_STATUS]
|
|
|
|
mov cl, 31 ; max number of queue entries
|
2010-10-01 11:21:55 +02:00
|
|
|
.tx_status_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
in al, dx
|
|
|
|
test al, al
|
|
|
|
jz .finish ; no error
|
|
|
|
test al, 0x3f
|
|
|
|
jnz .finish ; error
|
2010-10-01 11:21:55 +02:00
|
|
|
.no_error_found:
|
|
|
|
; clear current TxStatus entry which advances the next one
|
2012-03-08 09:33:38 +01:00
|
|
|
xor al, al
|
|
|
|
out dx, al
|
|
|
|
dec cl
|
|
|
|
jns .tx_status_loop
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
2012-03-08 09:33:38 +01:00
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_vortex_transmit
|
|
|
|
; Description
|
|
|
|
; Transmits a packet of data via the ethernet card
|
|
|
|
; edi - Pointer to 48 bit destination address
|
|
|
|
; bx - Type of packet
|
|
|
|
; ecx - size of packet
|
|
|
|
; esi - pointer to packet data
|
|
|
|
; ebp - io_addr
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, edx, ecx, edi, esi, ebp
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_vortex_transmit:
|
2012-03-08 09:33:38 +01:00
|
|
|
push ecx
|
|
|
|
call e3c59x_check_tx_status
|
|
|
|
pop ecx
|
|
|
|
test al, al
|
|
|
|
jz .no_error_found
|
|
|
|
jmp e3c59x_tx_reset
|
2010-10-01 11:21:55 +02:00
|
|
|
.no_error_found:
|
|
|
|
; switch to register window 7
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+7
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; check for master operation in progress
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MASTER_STATUS]
|
|
|
|
in ax, dx
|
|
|
|
test ah, 0x80
|
|
|
|
jnz .finish ; no DMA for sending
|
2010-10-01 11:21:55 +02:00
|
|
|
; dword boundary correction
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp ecx, E3C59X_MAX_ETH_FRAME_SIZE
|
|
|
|
ja .finish ; packet is too long
|
2010-10-01 11:21:55 +02:00
|
|
|
; write Frame Start Header
|
2012-03-08 09:33:38 +01:00
|
|
|
mov eax, ecx
|
2010-10-01 11:21:55 +02:00
|
|
|
; add header length and extend the complete length to dword boundary
|
2012-03-08 09:33:38 +01:00
|
|
|
add eax, ETH_HLEN+3
|
|
|
|
and eax, not 3
|
|
|
|
lea edx, [ebp+E3C59X_REG_TX_DATA]
|
|
|
|
out dx, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; prepare the complete frame
|
2012-03-08 09:33:38 +01:00
|
|
|
push esi
|
|
|
|
mov esi, edi
|
|
|
|
mov edi, e3c59x_tx_buff
|
|
|
|
zero_to_virt edi
|
|
|
|
cld
|
2010-10-01 11:21:55 +02:00
|
|
|
; copy destination address
|
2012-03-08 09:33:38 +01:00
|
|
|
movsd
|
|
|
|
movsw
|
2010-10-01 11:21:55 +02:00
|
|
|
; copy source address
|
2012-03-08 09:33:38 +01:00
|
|
|
mov esi, node_addr
|
|
|
|
movsd
|
|
|
|
movsw
|
2010-10-01 11:21:55 +02:00
|
|
|
; copy packet type
|
2012-03-08 09:33:38 +01:00
|
|
|
mov [edi], bx
|
|
|
|
add edi, 2
|
2010-10-01 11:21:55 +02:00
|
|
|
; copy packet data
|
2012-03-08 09:33:38 +01:00
|
|
|
pop esi
|
|
|
|
push ecx
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
|
|
|
pop ecx
|
|
|
|
and ecx, 3
|
|
|
|
rep movsb
|
|
|
|
mov ecx, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; program frame address to be sent
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MASTER_ADDRESS]
|
|
|
|
mov eax, e3c59x_tx_buff
|
|
|
|
zero_to_dma eax
|
|
|
|
out dx, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; program frame length
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MASTER_LEN]
|
|
|
|
mov eax, ecx
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; start DMA Down
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (10100b shl 11) + 1 ; StartDMADown
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
2012-03-08 09:33:38 +01:00
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_boomerang_transmit
|
|
|
|
; Description
|
|
|
|
; Transmits a packet of data via the ethernet card
|
|
|
|
; edi - Pointer to 48 bit destination address
|
|
|
|
; bx - Type of packet
|
|
|
|
; ecx - size of packet
|
|
|
|
; esi - pointer to packet data
|
|
|
|
; ebp - io_addr
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, ecx, edx, esi, edi, ebp
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_boomerang_transmit:
|
2012-03-08 09:33:38 +01:00
|
|
|
push ecx
|
|
|
|
call e3c59x_check_tx_status
|
|
|
|
pop ecx
|
|
|
|
test al, al
|
|
|
|
jz .no_error_found
|
|
|
|
jmp e3c59x_tx_reset
|
2010-10-01 11:21:55 +02:00
|
|
|
.no_error_found:
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp ecx, E3C59X_MAX_ETH_FRAME_SIZE
|
|
|
|
ja .finish ; packet is too long
|
2010-10-01 11:21:55 +02:00
|
|
|
; calculate descriptor address
|
2012-03-08 09:33:38 +01:00
|
|
|
mov eax, [e3c59x_prev_dpd]
|
|
|
|
cmp eax, e3c59x_dpd_buff+(E3C59X_NUM_TX_DESC-1)*E3C59X_DPD_SIZE
|
|
|
|
jb @f
|
2010-10-01 11:21:55 +02:00
|
|
|
; wrap around
|
2012-03-08 09:33:38 +01:00
|
|
|
mov eax, e3c59x_dpd_buff-E3C59X_DPD_SIZE
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
add eax, E3C59X_DPD_SIZE
|
|
|
|
zero_to_virt eax
|
|
|
|
push eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; check DnListPtr
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_DN_LIST_PTR]
|
|
|
|
in eax, dx
|
2010-10-01 11:21:55 +02:00
|
|
|
; mark if Dn_List_Ptr is cleared
|
2012-03-08 09:33:38 +01:00
|
|
|
test eax, eax
|
|
|
|
setz [e3c59x_dn_list_ptr_cleared]
|
2010-10-01 11:21:55 +02:00
|
|
|
; finish if no more free descriptor is available - FIXME!
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp eax, [esp]
|
|
|
|
pop eax
|
|
|
|
jz .finish
|
|
|
|
push eax esi
|
|
|
|
mov esi, edi
|
2010-10-01 11:21:55 +02:00
|
|
|
; calculate tx_buffer address
|
2012-03-08 09:33:38 +01:00
|
|
|
mov edi, [e3c59x_prev_tx_frame]
|
|
|
|
cmp edi, e3c59x_tx_buff+(E3C59X_NUM_TX_DESC-1)*E3C59X_MAX_ETH_FRAME_SIZE
|
|
|
|
jb @f
|
2010-10-01 11:21:55 +02:00
|
|
|
; wrap around
|
2012-03-08 09:33:38 +01:00
|
|
|
mov edi, e3c59x_tx_buff-E3C59X_MAX_ETH_FRAME_SIZE
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
add edi, E3C59X_MAX_ETH_FRAME_SIZE
|
|
|
|
zero_to_virt edi
|
|
|
|
mov eax, edi
|
|
|
|
cld
|
2010-10-01 11:21:55 +02:00
|
|
|
; copy destination address
|
2012-03-08 09:33:38 +01:00
|
|
|
movsd
|
|
|
|
movsw
|
2010-10-01 11:21:55 +02:00
|
|
|
; copy source address
|
2012-03-08 09:33:38 +01:00
|
|
|
mov esi, node_addr
|
|
|
|
movsd
|
|
|
|
movsw
|
2010-10-01 11:21:55 +02:00
|
|
|
; copy packet type
|
2012-03-08 09:33:38 +01:00
|
|
|
mov [edi], bx
|
|
|
|
add edi, 2
|
2010-10-01 11:21:55 +02:00
|
|
|
; copy packet data
|
2012-03-08 09:33:38 +01:00
|
|
|
pop esi
|
|
|
|
push ecx
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
|
|
|
pop ecx
|
|
|
|
push ecx
|
|
|
|
and ecx, 3
|
|
|
|
rep movsb
|
2010-10-01 11:21:55 +02:00
|
|
|
; padding, do we really need it?
|
2012-03-08 09:33:38 +01:00
|
|
|
pop ecx
|
|
|
|
add ecx, ETH_HLEN
|
|
|
|
cmp ecx, ETH_ZLEN
|
|
|
|
jae @f
|
|
|
|
mov ecx, ETH_ZLEN
|
2010-10-01 11:21:55 +02:00
|
|
|
@@:
|
|
|
|
; calculate
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ebx, ecx
|
|
|
|
;test byte [e3c59x_has_hwcksm], 0xff
|
|
|
|
;jz @f
|
|
|
|
;or ebx, (1 shl 26) ; set AddTcpChecksum
|
2010-10-01 11:21:55 +02:00
|
|
|
;@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
or ebx, 0x8000 ; transmission complete notification
|
|
|
|
or ecx, 0x80000000 ; last fragment
|
2010-10-01 11:21:55 +02:00
|
|
|
; program DPD
|
2012-03-08 09:33:38 +01:00
|
|
|
mov edi, eax
|
|
|
|
pop eax
|
|
|
|
and dword [eax+E3C59X_DPD_DN_NEXT_PTR], 0
|
|
|
|
mov dword [eax+E3C59X_DPD_FRAME_START_HDR], ebx
|
|
|
|
virt_to_dma edi
|
|
|
|
mov dword [eax+E3C59X_DPD_DN_FRAG_ADDR], edi
|
|
|
|
mov [eax+E3C59X_DPD_DN_FRAG_LEN], ecx
|
2010-10-01 11:21:55 +02:00
|
|
|
; calculate physical address
|
2012-03-08 09:33:38 +01:00
|
|
|
virt_to_dma eax
|
|
|
|
push eax
|
|
|
|
cmp byte [e3c59x_dn_list_ptr_cleared], 0
|
|
|
|
jz .add_to_list
|
2010-10-01 11:21:55 +02:00
|
|
|
; write Dn_List_Ptr
|
2012-03-08 09:33:38 +01:00
|
|
|
out dx, eax
|
|
|
|
jmp .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
.add_to_list:
|
|
|
|
; DnStall
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, ((110b shl 11)+2)
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; wait for DnStall to complete
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ecx, 6000
|
2010-10-01 11:21:55 +02:00
|
|
|
.wait_for_stall:
|
2012-03-08 09:33:38 +01:00
|
|
|
in ax, dx ; read E3C59X_REG_INT_STATUS
|
|
|
|
test ah, 10000b
|
|
|
|
jz .dnstall_ok
|
|
|
|
dec ecx
|
|
|
|
jnz .wait_for_stall
|
2010-10-01 11:21:55 +02:00
|
|
|
.dnstall_ok:
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
mov ebx, [e3c59x_prev_dpd]
|
|
|
|
zero_to_virt ebx
|
|
|
|
mov [ebx], eax
|
|
|
|
lea edx, [ebp+E3C59X_REG_DN_LIST_PTR]
|
|
|
|
in eax, dx
|
|
|
|
test eax, eax
|
|
|
|
jnz .dnunstall
|
2010-10-01 11:21:55 +02:00
|
|
|
; if Dn_List_Ptr has been cleared fill it up
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
push eax
|
|
|
|
out dx, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
.dnunstall:
|
|
|
|
; DnUnStall
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, ((110b shl 11)+3)
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
dma_to_zero eax
|
|
|
|
mov [e3c59x_prev_dpd], eax
|
|
|
|
dma_to_zero edi
|
|
|
|
mov [e3c59x_prev_tx_frame], edi
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_poll
|
|
|
|
; Description
|
|
|
|
; Polls the ethernet card for a received packet
|
|
|
|
; Received data, if any, ends up in Ether_buffer
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, edx, ecx, edi, esi, ebp
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_poll:
|
2012-03-08 09:33:38 +01:00
|
|
|
jmp dword [e3c59x_receive_function]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_vortex_poll
|
|
|
|
; Description
|
|
|
|
; Polls the ethernet card for a received packet
|
|
|
|
; Received data, if any, ends up in Ether_buffer
|
|
|
|
; Parameters
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; al - 0 ; no packet received
|
|
|
|
; al - 1 ; packet received
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, ebx, edx, ecx, edi, esi, ebp
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_vortex_poll:
|
2012-03-08 09:33:38 +01:00
|
|
|
and word [eth_rx_data_len], 0 ; assume no packet received
|
|
|
|
movzx ebp, word [io_addr] ; to be implemented in ETHERNET.INC
|
2010-10-01 11:21:55 +02:00
|
|
|
.rx_status_loop:
|
|
|
|
; examine RxStatus
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_RX_STATUS]
|
|
|
|
in ax, dx
|
|
|
|
test ax, ax
|
|
|
|
jz .finish
|
|
|
|
test ah, 0x80 ; rxIncomplete
|
|
|
|
jz .check_error
|
|
|
|
jmp .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
.check_error:
|
2012-03-08 09:33:38 +01:00
|
|
|
test ah, 0x40
|
|
|
|
jz .check_length
|
2010-10-01 11:21:55 +02:00
|
|
|
; discard the top frame received advancing the next one
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (01000b shl 11)
|
|
|
|
out dx, ax
|
|
|
|
jmp .rx_status_loop
|
2010-10-01 11:21:55 +02:00
|
|
|
.check_length:
|
2012-03-08 09:33:38 +01:00
|
|
|
and eax, 0x1fff
|
|
|
|
cmp eax, E3C59X_MAX_ETH_PKT_SIZE
|
|
|
|
ja .discard_frame ; frame is too long discard it
|
2010-10-01 11:21:55 +02:00
|
|
|
.check_dma:
|
2012-03-08 09:33:38 +01:00
|
|
|
push eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; switch to register window 7
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, E3C59X_SELECT_REGISTER_WINDOW+7
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; check for master operation in progress
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MASTER_STATUS]
|
|
|
|
in ax, dx
|
|
|
|
test ah, 0x80
|
|
|
|
jz .read_frame ; no DMA for receiving
|
|
|
|
pop eax
|
|
|
|
jmp .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
.read_frame:
|
|
|
|
; program buffer address to read in
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MASTER_ADDRESS]
|
2010-10-01 11:21:55 +02:00
|
|
|
if defined E3C59X_LINUX
|
2012-03-08 09:33:38 +01:00
|
|
|
mov eax, e3c59x_rx_buff
|
|
|
|
zero_to_dma eax
|
2010-10-01 11:21:55 +02:00
|
|
|
else
|
2012-03-08 09:33:38 +01:00
|
|
|
mov eax, Ether_buffer
|
2010-10-01 11:21:55 +02:00
|
|
|
end if
|
2012-03-08 09:33:38 +01:00
|
|
|
out dx, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
; program frame length
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MASTER_LEN]
|
|
|
|
mov ax, 1560
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; start DMA Up
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (10100b shl 11) ; StartDMAUp
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; check for master operation in progress
|
|
|
|
.dma_loop:
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_MASTER_STATUS]
|
|
|
|
in ax, dx
|
|
|
|
test ah, 0x80
|
|
|
|
jnz .dma_loop
|
2010-10-01 11:21:55 +02:00
|
|
|
; registrate the received packet length
|
2012-03-08 09:33:38 +01:00
|
|
|
pop eax
|
|
|
|
mov word [eth_rx_data_len], ax
|
2010-10-01 11:21:55 +02:00
|
|
|
; discard the top frame received
|
|
|
|
.discard_frame:
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, (01000b shl 11)
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
|
|
|
; set return value
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp word [eth_rx_data_len], 0
|
|
|
|
setne al
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; e3c59x_boomerang_poll
|
|
|
|
; Description
|
|
|
|
; Polls the ethernet card for a received packet
|
|
|
|
; Received data, if any, ends up in Ether_buffer
|
|
|
|
; Parameters
|
|
|
|
; ebp - io_addr
|
|
|
|
; Return value
|
|
|
|
; al - 0 ; no packet received
|
|
|
|
; al - 1 ; packet received
|
|
|
|
; Destroyed registers
|
|
|
|
; eax, edx, ecx, edi, esi, ebp
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
align 4
|
2010-10-01 11:21:55 +02:00
|
|
|
e3c59x_boomerang_poll:
|
2012-03-08 09:33:38 +01:00
|
|
|
and word [eth_rx_data_len], 0 ; assume no packet received
|
|
|
|
movzx ebp, word [io_addr] ; to be implemented in ETHERNET.INC
|
2010-10-01 11:21:55 +02:00
|
|
|
; check if packet is uploaded
|
2012-03-08 09:33:38 +01:00
|
|
|
mov eax, [e3c59x_curr_upd]
|
|
|
|
test byte [eax+E3C59X_UPD_PKT_STATUS+1], 0x80 ; upPktComplete
|
|
|
|
jnz .check_error
|
|
|
|
jmp .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
; packet is uploaded check for any error
|
|
|
|
.check_error:
|
2012-03-08 09:33:38 +01:00
|
|
|
test byte [eax+E3C59X_UPD_PKT_STATUS+1], 0x40 ; upError
|
|
|
|
jz .copy_packet_length
|
|
|
|
and dword [eax+E3C59X_UPD_PKT_STATUS], 0
|
|
|
|
jmp .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
.copy_packet_length:
|
2012-03-08 09:33:38 +01:00
|
|
|
mov ecx, [eax+E3C59X_UPD_PKT_STATUS]
|
|
|
|
and ecx, 0x1fff
|
|
|
|
cmp ecx, E3C59X_MAX_ETH_PKT_SIZE
|
|
|
|
jbe .copy_packet
|
|
|
|
and dword [eax+E3C59X_UPD_PKT_STATUS], 0
|
|
|
|
jmp .finish
|
2010-10-01 11:21:55 +02:00
|
|
|
.copy_packet:
|
2012-03-08 09:33:38 +01:00
|
|
|
push ecx
|
|
|
|
mov word [eth_rx_data_len], cx
|
|
|
|
mov esi, [eax+E3C59X_UPD_UP_FRAG_ADDR]
|
|
|
|
dma_to_virt esi
|
|
|
|
mov edi, Ether_buffer
|
|
|
|
shr ecx, 2 ; first copy dword-wise
|
|
|
|
cld
|
|
|
|
rep movsd ; copy the dwords
|
|
|
|
pop ecx
|
|
|
|
and ecx, 3
|
|
|
|
rep movsb ; copy the rest bytes
|
|
|
|
mov eax, [e3c59x_curr_upd]
|
|
|
|
and dword [eax+E3C59X_UPD_PKT_STATUS], 0
|
|
|
|
virt_to_zero eax
|
|
|
|
cmp eax, e3c59x_upd_buff+(E3C59X_NUM_RX_DESC-1)*E3C59X_UPD_SIZE
|
|
|
|
jb .no_wrap
|
2010-10-01 11:21:55 +02:00
|
|
|
; wrap around
|
2012-03-08 09:33:38 +01:00
|
|
|
mov eax, e3c59x_upd_buff-E3C59X_UPD_SIZE
|
2010-10-01 11:21:55 +02:00
|
|
|
.no_wrap:
|
2012-03-08 09:33:38 +01:00
|
|
|
add eax, E3C59X_UPD_SIZE
|
|
|
|
zero_to_virt eax
|
|
|
|
mov [e3c59x_curr_upd], eax
|
2010-10-01 11:21:55 +02:00
|
|
|
.finish:
|
|
|
|
; check if the NIC is in the upStall state
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_UP_PKT_STATUS]
|
|
|
|
in eax, dx
|
|
|
|
test ah, 0x20 ; UpStalled
|
|
|
|
jz .noUpUnStall
|
2010-10-01 11:21:55 +02:00
|
|
|
; issue upUnStall command
|
2012-03-08 09:33:38 +01:00
|
|
|
lea edx, [ebp+E3C59X_REG_COMMAND]
|
|
|
|
mov ax, ((110b shl 11)+1) ; upUnStall
|
|
|
|
out dx, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
.noUpUnStall:
|
|
|
|
; set return value
|
2012-03-08 09:33:38 +01:00
|
|
|
cmp word [eth_rx_data_len], 0
|
|
|
|
setnz al
|
|
|
|
ret
|