STREAMS-UX Programmer's Guide (February 2007)

Modules and Drivers
Overview
Chapter 4
60
Overview
Modules and drivers are the processing elements on a stream, below the stream head. STREAMS modules
and drivers are structurally similar. The streamtab, qinit, module_info, and optionally module_stat,
structures must be declared for STREAMS drivers and modules. A STREAMS driver is a required element
but modules are optional.
A STREAMS device driver is similar to a regular UNIX character device driver. It is opened as a regular
driver even if it is a pseudo-driver.
The following are the key differences between a module and driver:
A STREAMS driver, if associated with a hardware device, must be able to handle the interrupts from the
device and include an interrupt handling routine. A STREAMS module does not contain an interrupt
handling routine.
A STREAMS multiplexing driver can have multiple streams connected to it. Multiplexing is not
applicable to STREAMS modules.
A STREAMS driver is initialized or deinitialized when it is opened or closed. A STREAMS module is
initialized/deinitialized when it is pushed onto a stream or popped from a stream (PUSH and POP
operations result in calling the open and close routines of the module).
A STREAMS driver must send a negative acknowledgement if it does not understand the IOCTL
command passed to it. A STREAMS module must pass the IOCTL to the next component in the stream.
Like all UNIX device drivers, a STREAMS driver is also associated with a major device number in the
structure drv_info and a minor device number. The structure drv_info is not applicable for a
STREAMS module, and no major or minor number is associated with it.
Cloning
STREAMS provides a feature called cloning. Using cloning, applications opening the STREAMS driver do
not need to search for an unused minor device. In HP-UX564444466466666666666666664, cloning is
implemented with the help of the clone driver with 72 as its major number.
If a STREAMS driver is implemented as a clonable driver in HP-UX, a single node in the file system may be
opened to access any unused device that the driver controls. This node must be created with its major number
as 72 (the major number of the clone driver). The minor number is the same as the real driver’s major
number. See the “Entry Points” and “STREAMS Driver” sections for more details.
Autopush
Usually, when a STREAMS driver is opened, the stream created as a result has no modules on it. Applications
have to push the required modules explicitly after opening the driver. The autopush feature in STREAMS
allows administrators to specify a list of modules to be automatically pushed when a device is opened by
STREAMS. The command autopush (1M) provides the administrative interface to configure STREAMS
devices for autopush.