Specifications

Writing a User-Level Device Drive
r
17-35
1. Provide for communication between the user-level interrupt process and
other processes to which the driver is linked by attaching the driver status
and device register regions and other shared memory regions as
appropriate.
2. Determine the interrupt vector to which the user-level interrupt process
connects. You can do so by using one of the following methods:
If the device controlled by the user-level driver has a kernel device
driver that supports the IOCTLVECNUM ioctl command, use the
ioctl system call, and specify the IOCTLVECNUM command.
Kernel device drivers for the following devices support this
command: high-speed data enhanced device (hsde), real-time clock
(rtc), and edge-triggered interrupts (eti).
If the device controlled by the user-level driver allows its interrupt
vector number to be programmed and does not have a kernel device
driver that supports the IOCTLVECNUM ioctl command, use the
ICON_IVEC iconnect library routine to allocate an interrupt vector.
Note that after using this method to allocate an interrupt vector, you
must program the device so that it interrupts at that vector.
If the device controlled by the user-level driver interrupts at a fixed
vector number and does not have a kernel device driver that supports
the IOCTLVECNUM ioctl(2) command, you must reserve an
interrupt vector by modifying the interrupt vector table associated
with your machine. On Series 6000 systems, it is contained in the
/etc/conf/cf.d/ivt.s file.
3. Set up an interrupt connection structure, and define a connection between
the user-level interrupt process and the interrupt vector.
The interrupt connection structure is defined in the header file
<sys/iconnect.h>. The ic_vector field of this structure contains
the number of the interrupt vector to be connected to the user-level
interrupt process. The ic_routine field of this structure contains the
virtual address of the process’s interrupt-handling routine.
Use an ICON_CONN iconnect(3C) library routine call to define the
connection. Note that to use the ICON_CONN command, the calling process
or thread must have the P_USERINT privilege.
4. Lock the necessary portions of the user-level interrupt process’s virtual
address space in physical memory. (See “User-Level Interrupts and Mem-
ory Locking” on page 17-36 for details.)
5. Enable the user-level interrupt process’s interrupt vector connection. Use
the ienable(3C) library routine call to do so.
Note that the user-level interrupt process does not return from this call
unless an error occurs during the ienable(3C) library routine call or
another process disconnects it from the interrupt vector. The ienable
library routine call places the calling process in a blocked state in the
kernel and then enables the process’s interrupt vector connection. While