3 DRIVER FUNCTIONS
3.1 Introduction
This chapter provides a detailed description of the rmn driver module interface to the user, namely functions, commands, include files and tools.
The functions are described in UNIX man-page format and are organized in a functional order. Below is an index of the routines in the same order.
Each of these calls returns a status code which signals the success of the call. A zero value always means "successful completion" while a negative value indicates an error. The value -1 stands for "general error" and origins in VxWorks while other values signal a specific error reason and are returned by the driver itself. Literals of all error codes can be found in the include file rmnErrors.h and in [7].
3.2 Driver and Device Installation Functions
The installation of the rmn driver is according to the VxWorks driver concept described in and [4] and [5]. Two functions are provided:
b. the base-address of the board in the VMEbus A24 or A32 address-space. The value 0xffffffff will create the device in simulation mode1.
The parameters b., c. and d. must be chosen according to the jumper settings made on the board and to the actual amount of memory installed. Standardized base addresses, interrupt vectors and interrupt level are defined in the VLT standard VME boards configuration [8]. All the arguments are stored in the device-descriptor.
The driver performs the following steps at device installation during rmnDevCreate() and report any error or exceptional situation to the caller:
· Verify if the base-address is correct, check if the reflective memory board is present at that address, perform a test of the board's memory.
· Initialize the device-specific data structures, add the device to VxWorks, and allocate the access protection semaphore.
· Configure and initialize the interrupt sources (interrupt vectors, interrupt level, internal hooks
and data structures for user-provided ISRs).
· Reset (switch off) the Fail LED on the front panel to give a visual feedback that the device has been created and initialized successfully
After an OK return, the device is correctly installed under VxWorks and ready to accept open calls.
3.3 Tool Functions
The following tool functions are provided:
· rmnDevShow to print a list of all installed devices with their respective installation parameters to the LCU console;
· rmnDevDump(<device>) to print the content of the board's registers in a convenient format to the LCU console;
· rmnMemDump(<device>) to print the content of the board's register in hexadecimal format to the LCU console;
· rmnDevDescrDump(<device>) to print the content of the device descriptor data structure to the LCU console;
· rmnTestBoard(<device>) to perform a test of the board and of the optical link; it is the tool-function implementation of the corresponding ioctl-command "Test Board and Link" (see § 4.3).
3.4 Device Access Functions
The standard VxWorks functions as described in [4] and [5] are used to request and release access to a rmn device. Driver-specific functions are connected to these calls upon driver installation:
4. read and write - as well as other standard VxWorks driver functions - are not necessary and not supported.
These functions are described in the following sections with respect to their special meaning in the rmn context.
See also the man-pages of the internally used device-specific routines in the Reference chapter 9 for detailed information, especially for an exact error reference. For more general information see the "VxWorks Programmers Guide".
3.4.1 open
This operation opens the device corresponding to deviceName in read-only mode or in one of the read/write modes described below. The read access is granted in all open modes. The argument status receives the completion status of the routine.
Shareable read and write mode. Write access is granted to a defined number of tasks to use this open mode. Exceeding this number or requesting this mode for a device already opened in Exclusive mode returns an error.
Exclusive read write mode. Write access is granted to the task using this open mode. Requesting this mode for a device already opened in Exclusive or Shared mode returns an error.
Test read and write open mode. Write access is granted to the task using this option mode regardless of the status of the device. Requesting this mode for a device already opened in Test mode returns an error.
*status is a pointer to the error-code to be returned. If it is NULL, then nothing is returned. Note that this value is only valid when the function's return-value actually indicates an error.
* A value of -1 signals a general error. The specific error reason is provided in the argument status, as stated in the man-pages of the rmnOpen device-specific routine § 9.5.
* Device names shall not be longer than 15 characters. They are defined by use of the function rmnDevCreate at startup.
* This function is not queued by the driver, it always returns immediately with the file descriptor or an error code.
* Applications can have the same device opened several times, using different file descriptors and with different open modes.
* As only one task can open a device for Exclusive mode at any one time, and the number of channels is limited, applications should issue a close call if no more action on the device has to be performed.
* The VxWorks include file "configAll.h" contains two literals used by iosInit function: NUM_DRIVERS which defines the maximum number of drivers allowed, and NUM_FILES, the maximum number of simultaneously open files.
* The VxWorks command "iosDrvShow" shows all drivers of the system and their basic I/O function entry-points. The command "iosFdShow" shows all currently used file descriptors, and "iosDevShow" (or "devs") all installed devices.
3.4.2 close
This operation closes a channel to an opened device and frees the file descriptor. fileDescriptor must correspond to one of those obtained previously be an open call.
* This function is not queued by the driver, it always returns one of the above status codes immediately.
3.4.3 ioctl
This function commands the driver to perform the specified operation on the device. The commands are divided into read and write commands. Read commands are allowed in each open mode while write commands will be rejected if the channel was not previously opened in Shared, Exclusive or Test mode.
* command is a number, identifying the operation to be performed by the driver. Literals of all commands are provided in rmnCommands.h. and described in chapter 4.
* argument is the address of the command argument, or NULL if no argument is used. For commands, needing multiple arguments it is the address of a data structure which contains those. All argument data structures are defined in the include file rmnCommands.h.
* errors as stated in the man-pages of the rmnIoctl device-specific routine and in each command's description in chapter 4.
* This function is protected by a semaphore, and commands are queued by application priorities rather than by First-in First-out.
2The interrupt-vector is defined only for the first interrupt source. The remaining 3 interrupt sources will be connected to progressively increasing interrupt-vectors.
4Note that the third parameter is declared as (int) in VxWorks. A cast with (int) will therefore always be necessary when this function is called.
5Note that the third parameter is declared as (int) in VxWorks. A cast with (int) will therefore always be necessary when this function is called.
Quadralay Corporation http://www.webworks.com Voice: (512) 719-3399 Fax: (512) 719-3606 sales@webworks.com |