Specifications
Writing a User-Level Device Drive
r
17-39
-i create the user-level interrupt process
-d display debug and status information
-x remove the user-level device driver’s association with the device, and restore
the device to its initial state
These functions are performed for each device for which a valid device special file name is
specified as an argument to the program. The -c option is required of all user-level
drivers. The -i option is required of a user-level driver that supports interrupt-driven I/O.
The other options are recommended but not required. Each option is described in greater
detail in the sections that follow.
Create Shared Memory Regions and Initialize the Device 17
The -c option tells the device configuration program to create the structures required to
open a user-level driver for a specified device. It creates the shared memory regions that
are attached on a call to the driver’s open routine.
The arguments that are specified with the -c option are a device name and the physical
address of the device that is to be associated with the name. The device name must be a
valid device path name. The following example shows how to specify the -c option to the
configuration program for the DR11W emulator:
dr11wconfig -c /dev/dr11w0 0xffff9500 /dev/dr11w1 0xffff9520
If you are using a device that contains control registers at one address and a pool of
memory at another, you must design the configuration program to accept all of the
necessary device addresses. The following example shows how to specify the -c option to
the configuration program for such a device:
abcconfig -c /dev/abc0 0xffff0000 0xe0000000
To support the -c option, the device configuration program must perform the following
functions:
1. Create and initialize a driver status region for maintaining device and driver
status information.
Use ftok to obtain a key that is based on the path name of the device.
(Note that this assumes that a file exists on the system corresponding to the
name of the device.) Use the shmget(2) and shmat(2) system calls to
create and attach the shared memory region.
2. Create a device register region, and bind it to the location of the device’s
registers in I/O memory.
Use ftok to obtain a key that is based on the path name of the device. Use
shmget(2) to create the register region, shmbind(2) to bind it to the
physical location of the registers, and shmat(2) to attach it. Note that to
use shmbind, the calling process or thread must have P_SHMBIND
privilege.