VxWorks Reference Manual : Libraries
mbcEnd - Motorola 68302fads END network interface driver
mbcEndLoad( ) - initialize the driver and device
mbcParse( ) - parse the init string
mbcMemInit( ) - initialize memory for the chip
mbcAddrFilterSet( ) - set the address filter for multicast addresses
This is a driver for the Ethernet controller on the 68EN302 chip. The device supports a 16-bit interface, data rates up to 10 Mbps, a dual-ported RAM, and transparent DMA. The dual-ported RAM is used for a 64-entry CAM table, and a 128-entry buffer descriptor table. The CAM table is used to set the Ethernet address of the Ethernet device or to program multicast addresses. The buffer descriptor table is partitioned into fixed-size transmit and receive tables. The DMA operation is transparent and transfers data between the internal FIFOs and external buffers pointed to by the receive and transmit-buffer descriptors during transmits and receives.
The driver requires that the memory used for transmit and receive buffers be allocated in cache-safe RAM area.
Up to 61 multicast addresses are supported. Multicast addresses are supported by adding the multicast ethernet addresses to the address table in the ethernet part. If more than 61 multicast addresses are desired, address hashing must be used (the address table holds 62 entries at most). However, address hashing does not appear to work in this ethernet part.
A glitch in the EN302 Rev 0.1 device causes the Ethernet transmitter to lock up from time to time. The driver uses a watchdog timer to reset the Ethernet device when the device runs out of transmit buffers and cannot recover within 20 clock ticks.
This device is on-chip. No jumpering diagram is necessary.
The only external interface is the mbcEndLoad( ) routine, which expects the initString parameter as input. This parameter passes in a colon-delimited string of the format:
unit:memAddr:ivec:txBdNum:rxBdNum:dmaParms:bufBase:offset
- unit
- A convenient holdover from the former model. This parameter is used only in the string name for the driver.
- memAddr
- This parameter is the base address of the Ethernet module. The driver addresses all other Ethernet device registers as offsets from this address.
- ivec
- The interrupt vector to be used in connecting the interrupt handler.
- txBdNum
- The number of transmit buffer descriptors to use.
- rxBdNum
- The number of receive buffer descriptors to use.
The number of transmit and receive buffer descriptors (BDs) used is configurable by the user while attaching the driver. Each BD is 8 bytes in size and resides in the chip's dual-ported memory, while its associated buffer, 1520 bytes in size, resides in cache-safe conventional RAM. A minimum of 2 receive and 2 transmit BDs should be allocated. If this parameter is 0, a default of 32 BDs will be used. The maximum number of BDs depends on how the dual-ported BD RAM is partitioned. The 128 BDs in the dual-ported BD RAM can partitioned into transmit and receive BD regions with 8, 16, 32, or 64 transmit BDs and corresponding 120, 112, 96, or 64 receive BDs.
- dmaParms
- Ethernet DMA parameters.
This parameter is used to specify the settings of burst limit, water-mark, and transmit early, which control the Ethernet DMA, and is used to set the EDMA register.
- bufBase
- Base address of the buffer pool.
This parameter is used to notify the driver that space for the transmit and receive buffers need not be allocated, but should be taken from a cache-coherent private memory space provided by the user at the given address. The user should be aware that memory used for buffers must be 4-byte aligned and non-cacheable. All the buffers must fit in the given memory space; no checking will be performed. Each buffer is 1520 bytes. If this parameter is "NULL", space for buffers will be obtained by calling cacheDmaMalloc( ) in mbcMemInit( ).
- offset
- Specifies the memory alignment offset.
This driver requires several external support functions, defined as macros:
SYS_INT_CONNECT(pDrvCtrl, routine, arg) SYS_INT_DISCONNECT (pDrvCtrl, routine, arg) SYS_INT_ENABLE(pDrvCtrl) SYS_OUT_SHORT(pDrvCtrl, reg, data) SYS_IN_SHORT(pDrvCtrl, reg, pData)There are default values in the source code for these macros. They presume memory-mapped accesses to the device registers and the normal intConnect( ), and intEnable( ) BSP functions. The first argument to each is the device controller structure. Thus, each has access back to all the device-specific information. Having the pointer in the macro facilitates the addition of new features to this driver.
The driver requires the following system resources:
- one watchdog timer
- one interrupt vector
- 52 bytes in the initialized data section (data)
- 0 bytes in the uninitialized data section (bss)The above data and BSS requirements are for the MC68000 architecture and can vary for other architectures. Code size (text) varies greatly between architectures and is therefore not quoted here.
If the driver allocates the memory shared with the Ethernet device unit, it does so by calling the cacheDmaMalloc( ) routine. For the default case of 32 transmit buffers, 32 receive buffers, the total size requested is roughly 100,000 bytes. If a memory region is provided to the driver, the size of this region is adjustable to suit user needs.
This driver can only operate if the shared memory region is non-cacheable, or if the hardware implements bus snooping. The driver cannot maintain cache coherency for the device because the buffers are asynchronously modified by both the driver and the device, and these fields may share the same cache line. Additionally, the chip's dual-ported RAM must be declared as non-cacheable memory where applicable.
end.h endLib.h etherMultiLib.h
mbcEnd, muxLib, endLib Writing and Enhanced Network Driver
mbcEndLoad( ) - initialize the driver and device
END_OBJ* mbcEndLoad ( char * initString /* String to be parsed by the driver. */ )
This routine initializes the driver and the device to the operational state. All of the device specific parameters are passed in the initString.
The string contains the target specific parameters like this:
"unit:memAddr:ivec:txBdNum:rxBdNum:dmaParms:bufBase:offset"
An END object pointer or NULL on error.
mbcParse( ) - parse the init string
STATUS mbcParse ( MBC_DEVICE * pDrvCtrl, /* device pointer */ char * initString /* information string */ )
Parse the input string. Fill in values in the driver control structure.
The initialization string format is:
"unit:memAddr:ivec:txBdNum:rxBdNum:dmaParms:bufBase:offset"
- unit
- Device unit number, a small integer.
- memAddr
- ethernet module base address.
- ivec
- Interrupt vector number (used with sysIntConnect)
- txBdNum
- transmit buffer descriptor
- rxBdNum
- receive buffer descriptor
- dmaParms
- dma parameters
- bufBase
- address of memory pool
- offset
- packet data offset
OK or ERROR for invalid arguments.
mbcMemInit( ) - initialize memory for the chip
STATUS mbcMemInit ( MBC_DEVICE * pDrvCtrl /* device to be initialized */ )
Allocates and initializes the memory pools for the mbc device.
OK or ERROR.
mbcAddrFilterSet( ) - set the address filter for multicast addresses
void mbcAddrFilterSet ( MBC_DEVICE * pDrvCtrl /* device to be updated */ )
This routine goes through all of the multicast addresses on the list of addresses (added with the endAddrAdd( ) routine) and sets the device's filter correctly.
N/A.