Kate Feng wrote:
Szalata, Zenon M. wrote:
I need a device driver for the CAEN V965 module, which works with
vxWorks 6.x. Here at SLAC we have a device driver for this module
which works with rtems only.
Thanks,
Zen
Is the driver written for EPICS 3.14.x ? If so, it should be
easy to port it to vxWorks. It is a good idea to write a driver
for multiple platforms. The "Application Developer's Guide"
provides a good guideline.
1) For the src/Makefile :
Copy the existing Makefile to Makefile.RTEMS. For the vxworks
Makefile, change "PROD_IOC_RTEMS" to "PROD_IOC_vxWorks"
and take out all the RTEMS related include path.
2) For the source code under src/ :
vxworks access the I/O register via a pointer to the address.
For example : for the long data access, which is four bytes, it does:
volatile epicsUInt32 *reg;
epicsUInt32 value;
reg = (volatile epicsUInt32 *) io_address ;
My 2 cents:
Accessing device registers this way is bad practice.
a) it is not obvious where I/O is done. Makes porting this code e.g., to
a CPU of different endianness much more cumbersome.
b) may not synchronize I/O properly; modern CPUs may reorder
instruction execution and need special instructions to enforce
in-order execution of critical code sequences.
Both issues are addressed by the RTEMS inline routines in io.h and
byteorder.h
It certainly would be great to have equivalent functionality available
in EPICS/OSI.
For now, you'll have to find out what vxWorks provides in this area
or ultimately code it yourself.
However, I suggest you *always* perform register access by means
of a macro or inline routine for sake of portability and ease of
maintenance.