VxWorks Reference Manual : Libraries
if_cs - Crystal Semiconductor CS8900 network interface driver
csAttach( ) - publish the cs network interface and initialize the driver.
csShow( ) - shows statistics for the cs network interface
This module implements a driver for a Crystal Semiconductor CS8900 Ethernet controller chip.
The CS8900 is a single chip Ethernet controller with a direct ISA bus interface which can operate in either memory space or I/O space. It also supports a direct interface to a host DMA controller to transfer receive frames to host memory. The device has a 4K RAM which is used for transmit, and receive buffers; a serial EEPROM interface; and both 10BASE-T/AUI port support.
This driver is capable of supporting both memory mode and I/O mode operations of the chip. When configured for memory mode, the intenal RAM of the chip is mapped to a contiguous 4K address block, providing the CPU direct access to the internal registers and frame buffers. When configured for I/O mode, the internal registers are accessible through eight contiguous, 16-bit I/O ports. The driver also supports an interface to an EEPROM containing device configuration.
While the DMA slave mode is supported by the device for receive frame transfers, this driver does not enable DMA.
This network interface driver does not support output hook routines, because to do so requires that an image of the transmit packet be built in memory before the image is copied to the CS8900 chip. It is much more efficient to copy the image directly from the mbuf chain to the CS8900 chip. However, this network interface driver does support input hook routines.
The defined I/O address and IRQ in config.h must match the one stored in EEPROM by the vendor's DOS utility program.
The I/O Address parameter is the only required csAttach( ) parameter. If the CS8900 chip has a EEPROM attached, then the I/O Address parameter, passed to the csAttach( ) routine, must match the I/O address programmed into the EEPROM. If the CS8900 chip does not have a EEPROM attached, then the I/O Address parameter must be 0x300.
The Interrupt Level parameter must have one of the following values:
0 - Get interrupt level from EEPROM
5 - IRQ 5
10 - IRQ 10
11 - IRQ 11
12 - IRQ 12If the Interrupt Vector parameter is zero, then the network interface driver derives the interrupt vector from the interrupt level if possible. It is possible to derive the interrupt vector in an IBM PC compatible system. This parameter is present for systems which are not IBM PC compatible.
The Memory Address parameter specifies the base address of the CS8900 chip's memory buffer (PacketPage). If the Memory Address parameter is not zero, then the CS8900 chip operates in memory mode at the specified address. If the Memory Address parameter is zero, then the CS8900 chip operates in the mode specified by the EEPROM or the Configuration Flags parameter.
The Media Type parameter must have one of the following values:
0 - Get media type from EEPROM 1 - AUI (Thick Cable) 2 - BNC 10Base2 (Thin Cable) 3 - RJ45 10BaseT (Twisted Pair)The Configuration Flags parameter is usually passed to the csAttach( ) routine as zero and the Configuration Flags information is retrieved from the EEPROM. The bits in the Configuration Flags parameter are usually specified by a hardware engineer and not by the end user. However, if the CS8900 chip does not have a EEPROM attached, then this information must be passed as a parameter to the csAttach( ) routine. The Configuration Flags are:0x8000 - CS_CFGFLG_NOT_EEPROM Don't get Config. Flags from the EEPROM 0x0001 - CS_CFGFLG_MEM_MODE Use memory mode to access the chip 0x0002 - CS_CFGFLG_USE_SA Use system addr to qualify MEMCS16 signal 0x0004 - CS_CFGFLG_IOCHRDY Use IO Channel Ready signal to slow access 0x0008 - CS_CFGFLG_DCDC_POL The DC/DC conv. enable pin is active high 0x0010 - CS_CFGFLG_FDX 10BaseT is full duplexIf configuration flag information is passed to the csAttach( ) routine, then the CS_CFGFLG_NOT_EEPROM flag should be set. This ensures that the Configuration Flags parameter is not zero, even if all specified flags are zero.If the Memory Address parameter is not zero and the Configuration Flags parameter is zero, then the CS8900 network interface driver implicitly sets the CS_CFGFLG_MEM_MODE flag and the CS8900 chip operates in memory mode. However, if the Configuration Flags parameter is not zero, then the CS8900 chip operates in memory mode only if the CS_CFGFLG_MEM_MODE flag is explicitly set. If the Configuration Flags parameter in not zero and the CS_CFGFLG_MEM_MODE flag is not set, then the CS8900 chip operates in I/O mode.
The Ethernet Address parameter is usually passed to the csAttach( ) routine as zero and the Ethernet address is retrieved from the EEPROM. The Ethernet address (also called hardware address and individual address) is usually supplied by the adapter manufacturer and is stored in the EEPROM. However, if the CS8900 chip does not have a EEPROM attached, then the Ethernet address must be passed as a parameter to the csAttach( ) routine. The Ethernet Address parameter, passed to the csAttach( ) routine, contains the address of a NULL terminated string. The string consists of 6 hexadecimal numbers separated by colon characters. Each hexadecimal number is in the range 00 - FF. An example of this string is:
"00:24:20:10:FF:2A"
This device is soft-configured. No jumpering diagram is required.
The only user-callable routines are csAttach( ):
- csAttach( )
- publishes the cs interface and initializes the driver and device.
The network interface driver includes a show routine, called csShow( ), which displays driver configuration and statistics information. To invoke the show routine, type at the shell prompt:
-> csShowTo reset the statistics to zero, type at the shell prompt:-> csShow 0, 1Another routine that you may find useful is:-> ifShow "cs0"
For debugging purposes, this driver calls logMsg( ) to print error and debugging information. This will cause the logLib library to be linked with any image containing this driver.
This driver needs the following macros defined for proper execution. Each has a default definition that assumes a PC386/PC486 system and BSP.
The macro CS_IN_BYTE(reg,pAddr) reads one byte from the I/O address reg, placing the result at address pAddr. There is no status result from this operation, we assume the operation completes normally, or a bus exception will occur. By default, this macro assumes there is a BSP routine sysInByte( ) to perform the I/O operation.
The macro CS_IN_WORD(reg,pAddr) read a short word (2 bytes) from the I/O address reg, storing the result at address pAddr. We assume this completes normally, or causes a bus exception. The default declaration assumes a BSP routine sysInWord( ) to perform the operation.
The macro CS_OUT_WORD(reg,data) writes a short word value data at the I/O address reg. The default declaration assumes a BSP routine sysOutWord( ).
The macro CS_INT_ENABLE(level, pResult) is used to enable the interrupt level passed as an argument to csAttach. The default definition call the BSP routine sysIntEnablePIC(level). The STATUS return value from the actual routine is stored at pResult for the driver to examine.
The macro CS_INT_CONNECT(ivec,rtn,arg,pResult) macro is used to connect the driver interrupt routine to the vector provided as an argument to csAttach (after translaction by INUM_TO_IVEC). The default definition calls the cpu architecture routine intConnect( ).
The macro CS_IRQ0_VECTOR(pAddr) is used to fetch the base vector for the interrupt level mechanism. If the int vector argument to csAttach is zero, then the driver will compute a vector number by adding the interrupt level to the value returned by this macro. If the user supplies a non-zero interrupt vector number, then this macro is not used. The default definition of this macro fetches the base vector number from a global value called sysVectorIRQ0.
The macro CS_MSEC_DELAY(msec) is used to delay execution for a specified number of milliseconds. The default definition uses taskDelay to suspend task for some number of clock ticks. The resolution of the system clock is usually around 16 milliseconds (msecs), which is fairly coarse.
csAttach( ) - publish the cs network interface and initialize the driver.
STATUS csAttach ( int unit, /* unit number */ int ioAddr, /* base IO address */ int intVector, /* interrupt vector, or zero */ int intLevel, /* interrupt level */ int memAddr, /* base memory address */ int mediaType, /* 0: Autodetect 1: AUI 2: BNC 3: RJ45 */ int configFlags, /* configuration flag */ char * pEnetAddr /* ethernet address */ )
This routine is a major entry point to this network interface driver and is called only once per operating system reboot by the operating system startup code. This routine is called before the csInit( ) routine.
This routine takes passed-in configuration parameters and parameters from the EEPROM and fills in the instance global variables in the cs_softc structure. These variables are later used by the csChipInit( ) routine.
This routine connects the interrupt handler, csIntr( ), to the specified interrupt vector, initializes the 8259 PIC and resets the CS8900 chip.
Finally, this routine calls the ether_attach( ) routine, to fill in the ifnet structure and attach this network interface driver to the system. The driver's main entry points (csInit( ), csIoctl( ), csOutput( ), csReset( )) are made visable to the protocol stack.
Refer to "man if_cs" for detailed description of the configuration flags.
OK or ERROR.
csShow( ) - shows statistics for the cs network interface
void csShow ( int unit, /* interface unit */ BOOL zap /* zero totals */ )
This routine displays statistics about the cs Ethernet network interface. It has two parameters:
- unit
- interface unit; should be 0.
- zap
- if 1, all collected statistics are cleared to zero.
N/A