|
Vx/IP-Serial :
tyIpSerDrv
z85C30 tty Driver for
vxWorks
This VxWorks
asynchronous serial driver provides standard support (including the tyLib
options) for up to 4 IP-Serial (z85C30) Industry Packs, on one or more
VMEbus Industry Pack carriers, or the MVME162 board. There are also custom
ioctl operations available to configure non-standard hardware parameters.
Baud rates are supported up to 38400, in a continuous range.
Vx/IP-Serial includes
tyIpSerDrv.c (a "C" language device driver), tyIpSerDrv.h which
chiefly supplies definitions for the custom ioctl's, and a test program in
source form. There is also a sample startup script to initialize devices
for 2 IP-Serial industry packs; along with the test program, it serves as a
model for driver usage.
Installation &
Startup
The binary
tyIpSerDrv.o may be linked with the vxWorks kernel when it is made, or it
can be downloaded (linked) dynamically. Specific hardware dependencies,
such as addressing, associated with the platform, are avoided through the
use of standard sysLib entry points. The IP Serial driver uses the
following entry points for device definition and initialization:
Driver initialization
tyIpSerDrv()
tyIpSerPack(baseAddress,
local, verbose, intVec, intLevel) : IP definition
tyIpSerDevCreate(devName,
channel, bufszRead, bufszWrite) : Device creation
Prior to calling other
driver entry points, initialization must be performed by calling
tyIpSerDrv, without arguments. This returns one of two status values, ERROR
or OK. It installs the driver in the vxWorks I/O system.
It will return ERROR
only if the iosDrvInstall, which places the driver in the kernel driver
tables, should fail. This might occur, for example, if there are too many
drivers installed. The global variable nIpSerChannels will be set to the number
of available IP Serial ports suitable for device creation, initially 0.
Channels corresponding
to several IP-Serial Industry Packs may be added by subsequent calls to
tyIpSerPack. No IP's are probed for or installed by default.
Device Definition (tyIpSerPackRegister)
The driver supports up
to 4 industry packs, for a total of 8 channels. The number of channels
currently defined is stored in the global nIpSerChannels.
The entry tyIpSerPack
when called will attempt to find a single IP Serial Industry Pack and add
its two ports to the list of available channels, thus incrementing
nIpSerChannels by 2. The search consists of a test of the Industry Pack ID
Prom Space to see if the IP exists, is an IP, and has appropriate
manufacturer (Greenspring Computers) and type (IP-Serial).
If tyIpSerPack
succeeds, it is then necessary to create devices for the two additional
channels created. These channels will have channel numbers immediately
following the last previous highest channel number. For example, if the first
tyIpSerPackRegister call establishes two channels on the an IP, they will
be numbered 0 and 1, with nIpSerChannels set at that time to 2. The next
subsequent successful call to tyIpSerPackRegister will set nIpSerChannels
to 4, and the channels on the new IP will be numbered 2 and 3. In all
cases, the A channel of the single Zilog 85C30 serial chip is the lower
(even) numbered channel, and the B port the higher. STATUS
tyIpSerPackRegister(baseAddress, local, verbose, intVec, intLevel) returns
OK if the denoted IP is found and can be used. baseAddress is the VME bus
address in supervisor short I/O space of the IP base if the IP is on a
carrier. Local is set true (non-zero) if the IP is on one of the 4 local IP
slots on the MVME162 processor (running vxWorks). If local, the baseAddress
is a number from 0-3, representing the slot address, as follows slot A 0
slot B 1 slot C 2 slot D 3
Verbose indicates, if
non-zero, that reasons for failure or advisory messages should be printed
to standard output.
intVec and intLevel
are the interrupt number (not multiplied by 4) and VME request level for
the IP. Note that the request level (unlike the vector) is not arbitrary
but is usually a function of the IP carrier board if not local.
tyIpSerPack will
return ERROR if the Industry Pack is not found, if there are already a
maximum number of IP's defined, or if the baseAddress supplied is invalid
(as determined by sysBusToLocalAdrs). tyIpSerPack also, as a side effect,
resets the z85C30 part on the IP and connects the interrupt vector to the
IP-Serial interrupt handler. It is essential that different IP's use
different interrupt vectors, although they can share interrupt levels.
Device Creation
(tyIpSerDevCreate)
Device creation makes
channels previously declared to tyIpSerPack available to the vxWorks I/O
system and tyLib. It also initializes the z85C30 serial channel to the
default setting of 9600 baud, 8 data bits, no parity and 1 stop bit. The
initial setting of the tyLib option bits is 0, which corresponds to raw
mode. Subsequent to device creation, the device name may be used in an open
call, after which read,write and ioctl calls may be made in the normal way.
STATUS
tyIpSerDevCreate(devName, chan, bufszRead, bufszWrite)
where chan is the channel
number from 0 to (n)IpSerChannels-1, and the buffer sizes are for read and
write buffers managed by tyLib (a typical size is 512 bytes). The name is
the usual string argument. This entry returns ERROR if the driver is not
installed, the device is already installed for this channel, or if errors
are found by tyDevInit or iosDevAdd in tyLib and iosLib, respectively.
Ioctl Support
Ioctl's generally are
invoked with a call of the form:
ioctl(fd,operation,arg)
where operation is one
of a range of operations for this driver type, and arg is a value (or
structure pointer) whose meaning is dependent on the operation. In the case
of tty drivers, there is a large class of operations supported in tyLib,
which are merely passed on by the driver. These are described in the
vxWorks manual, defined in ioLib.h, and fully supported in this driver. The
IP Serial driver defines in addition some non standard ioctl's which are
defined, along with associated structures, in tyIpSer.h. These ioctl's are
as follows:
FIOSETHWOPTIONS
This allows the
defined number of data bits and stop bits to be changed, and to invoke the
"local loop" option of the z85C30. The settings are written into
a hw_opt structure; the argument is a pointer to this structure. The
legitimate values for nDataBits are 7 or 8, and for nStopbits, 1 or 2. The
autoLoop variable is non-zero if auto loop mode is desired. In this mode,
serial port output is fed to the receive channel as well as the output
lines. The autoEcho variable is unused and should always be cleared to
zero. It is worth noting that when 7 data bits are used, bit 7 of received
characters is unconditionally set to 1. This bit will be cleared by the
tyLib handlers if the 7bit mode flag of the tyLib options is set.
FIOGETHWOPTIONS
This reads the current
settings of the hardware options for this port into a hw_opt structure; the
argument is a pointer to this structure.
DISPLAY (tyIpSerShow)
The entry tyIpSerShow
conveniently displays the internals of the driver, showing information for
all of the available channels. It is invoked
tyIpSerShow() at any
time, without arguments.
TEST PROGRAMS
The test programs
supplied are primarily useful as examples of serial port usage. They are
briefly described as follows:
exipser: This routine
reads and writes packets to ports in autoloop or cableloop mode. It
illustrates ioctl usage and tests data integrity.
ity: This is a startup
script that initializes 2 IP's.
Copyright (c) 1995
Compware Corporation
|