VxWorks Reference Manual : Libraries
if_dc - DEC 21x4x Ethernet LAN network interface driver
dcattach( ) - publish the dc network interface.
dcReadAllRom( ) - read entire serial rom
dcViewRom( ) - display lines of serial ROM for dec21140
dcCsrShow( ) - display dec 21040/21140 status registers 0 thru 15
This module implements an ethernet interface driver for the DEC 21x4x family, and currently supports the following variants -- 21040, 21140, and 21140A.
The DEC 21x4x PCI Ethernet controllers are inherently little-endian since they are designed for a little-endian PCI bus. While the 21040 only supports a 10Mps interface, other members of this family are dual-speed devices which support both 10 and 100 Mbps.
This driver is designed to be moderately generic, operating unmodified across the range of architectures and targets supported by VxWorks; and on multiple versions of the dec21x4x family. To achieve this, the driver takes several parameters, and external support routines which are detailed below. Also stated below are assumptions made by the driver of the hardware, and if any of these assumptions are not true for your hardware, the driver will probably not function correctly.
This driver supports up to 4 ethernet units per CPU, and can be configured for either big-endian or little-endian architectures. It contains error-recovery code to handle known device errata related to DMA activity.
On a dec21040, this driver configures the 10BASE-T interface by default and waits for two seconds to check the status of the link. If the link status is "fail," it then configures the AUI interface.
The dec21140, and dec21140A devices support both 10 and 100Mbps and also a variety of MII and non-MII PHY interfaces. This driver reads a DEC version 2.0 SROM device for PHY initialization information, and automatically configures an apropriate active PHY media.
This device is on-board. No jumpering diagram is necessary.
This driver provides the standard external interface with the following exceptions. All initialization is performed within the attach routine; there is no separate initialization routine. Therefore, in the global interface structure, the function pointer to the initialization routine is NULL.
The only user-callable routine is dcattach( ), which publishes the dc interface and initializes the driver and device.
- bus mode
This parameter is a global variable that can be modified at run-time.
The LAN control register #0 determines the bus mode of the device, allowing the support of big-endian and little-endian architectures. This parameter, defined as "ULONG dcCSR0Bmr", is the value that will be placed into device control register #0. The default is mode is little endian.
For information about changing this parameter, see the manual
DEC Local Area Network Controller DEC21040 or DEC21140 for PCI.
- base address of device registers
This parameter is passed to the driver by dcattach( ).
- interrupt vector
This parameter is passed to the driver by dcattach( ).
This driver configures the device to generate hardware interrupts for various events within the device; thus it contains an interrupt handler routine. The driver calls intConnect( ) to connect its interrupt handler to the interrupt vector generated as a result of the device interrupt.
- interrupt level
This parameter is passed to the driver by dcattach( ).
Some targets use additional interrupt controller devices to help organize and service the various interrupt sources. This driver avoids all board-specific knowledge of such devices. During the driver's initialization, the external routine sysLanIntEnable( ) is called to perform any board-specific operations required to allow the servicing of a device interrupt. For a description of sysLanIntEnable( ), see "External Support Requirements" below.
This parameter is passed to the external routine.
- shared memory address
This parameter is passed to the driver by dcattach( ).
The DEC 21x4x device is a DMA type of device and typically shares access to some region of memory with the CPU. This driver is designed for systems that directly share memory between the CPU and the DEC 21x4x. It assumes that this shared memory is directly available to it without any arbitration or timing concerns.
This parameter can be used to specify an explicit memory region for use by the DEC 21x4x device. This should be done on hardware that restricts the DEC 21x4x device to a particular memory region. The constant NONE can be used to indicate that there are no memory limitations, in which case, the driver attempts to allocate the shared memory from the system space.
- shared memory size
This parameter is passed to the driver by dcattach( ).
This parameter can be used to explicitly limit the amount of shared memory (bytes) this driver will use. The constant NONE can be used to indicate no specific size limitation. This parameter is used only if a specific memory region is provided to the driver.
- shared memory width
This parameter is passed to the driver by dcattach( ).
Some target hardware that restricts the shared memory region to a specific location also restricts the access width to this region by the CPU. On these targets, performing an access of an invalid width will cause a bus error.
This parameter can be used to specify the number of bytes of access width to be used by the driver during access to the shared memory. The constant NONE can be used to indicate no restrictions.
Current internal support for this mechanism is not robust; implementation may not work on all targets requiring these restrictions.
- shared memory buffer size
This parameter is passed to the driver by dcattach( ).
The driver and DEC 21x4x device exchange network data in buffers. This parameter permits the size of these individual buffers to be limited. A value of zero indicates that the default buffer size should be used. The default buffer size is large enough to hold a maximum-size Ethernet packet.
- pci Memory base
This parameter is passed to the driver by dcattach( ). This parameter gives the base address of the main memory on the PCI bus.
- dcOpMode
This parameter is passed to the driver by dcattach( ). This parameter gives the mode of initialization of the device. The mode flags for both the DEC21040 and DEC21140 interfaces are listed below.
DC_PROMISCUOUS_FLAG 0x01 DC_MULTICAST_FLAG 0x02
The mode flags specific to the DEC21140 interface are listed below.
DC_100_MB_FLAG 0x04 DC_21140_FLAG 0x08 DC_SCRAMBLER_FLAG 0x10 DC_PCS_FLAG 0x20 DC_PS_FLAG 0x40
DC_FULLDUPLEX_FLAG 0x10
Loopback mode flags DC_ILOOPB_FLAG 0x100 DC_ELOOPB_FLAG 0x200 DC_HBE_FLAG 0x400
- Ethernet address
This is obtained by the driver by reading an ethernet ROM register or the DEC serial ROM.
This driver requires one external support function:
- void sysLanIntEnable (int level)
This routine provides a target-specific enable of the interrupt for the DEC 21x4x device. Typically, this involves interrupt controller hardware, either internal or external to the CPU.
This routine is called once via the macro SYS_INT_ENABLE( ).
if_dc, ifLib, DECchip 21040 or 21140 Ethernet LAN Controller for PCI.
dcattach( ) - publish the dc network interface.
STATUS dcattach ( int unit, /* unit number */ ULONG devAdrs, /* device I/O address */ int ivec, /* interrupt vector */ int ilevel, /* interrupt level */ char * memAdrs, /* address of memory pool (-1 = malloc it) */ ULONG memSize, /* only used if memory pool is NOT malloc()'d */ int memWidth, /* byte-width of data (-1 = any width) */ ULONG pciMemBase, /* main memory base as seen from PCI bus */ int dcOpMode /* mode of operation */ )
This routine publishes the dc interface by filling in a network interface record and adding this record to the system list. This routine also initializes the driver and the device to the operational state.
The unit parameter is used to specify the device unit to initialize.
The devAdrs is used to specify the I/O address base of the device.
The ivec parameter is used to specify the interrupt vector associated with the device interrupt.
The ilevel parater is used to specify the level of the interrupt which the device would use.
The memAdrs parameter can be used to specify the location of the memory that will be shared between the driver and the device. The value NONE is used to indicate that the driver should obtain the memory.
The memSize parameter is valid only if the memAdrs parameter is not set to NONE, in which case memSize indicates the size of the provided memory region.
The memWidth parameter sets the memory pool's data port width (in bytes); if it is NONE, any data width is used.
The pciMemBase parameter defines the main memory base as seen from PCI bus.
The dcOpMode parameter defines the mode in which the device should be operational.
To zero out DEC 21x4x data structures, this routine uses bzero( ), which ignores the memWidth specification and uses any size data access to write to memory.
OK or ERROR.
dcReadAllRom( ) - read entire serial rom
void dcReadAllRom ( ULONG devAdrs, /* device base I/O address */ UCHAR * buffer, /* destination bufferr */ int cnt /* Amount to extract in bytes */ )
Function to read all of serial rom and store the data in the data structure passed to the function. The count value will indicate how much of the serial rom to read. The routine with also swap the the bytes as the come in.
N/A.
dcViewRom( ) - display lines of serial ROM for dec21140
int dcViewRom ( ULONG devAdrs, /* device base I/O address */ UCHAR lineCnt, /* Serial ROM line Number */ int cnt /* Amount to display */ )
Number of bytes displayed.
dcCsrShow( ) - display dec 21040/21140 status registers 0 thru 15
int dcCsrShow ( int unit )
Display the 16 registers of the DEC 21140 device on the console. Each register is printed in hexadecimal format.
N/A.