STREAMS/UX for the HP 9000 Reference Manual

108
How to Compile and Link STREAMS/UX Drivers, Modules, and Applications
Linking STREAMS/UX Drivers and Modules into the Kernel
For a STREAMS driver, your driver install routine will need to call both the
function install_driver (CDIO3) and str_install(). And for a STREAMS
module, your driver install routine will only need to call the str_install()
routine.
The call to install_driver() initializes the cdevsw entry points and d_flags for
your STREAMS driver. The call to the str_install() function fills out either
the dmodsw (for a STREAMS driver) or the fmodsw (for a STREAMS
module) switch tables used by the STREAMS subsystem.
NOTE: The str_install() function will replace the open, close, read, write, ioctl, select, and
option1 cdevsw entry points with the STREAMS/UX-specific entry points. So it
is best to use NULLs in the drv_ops_t structure as illustrated in the example later
in this section.
Keep in mind that you can call your driver_link routine from the driver
install to perform any necessary driver initialization tasks. You should not
perform any operations which require returning error conditions or data.
Plus, it is best to keep driver install routines small and clean to avoid bootup
problems.
If you are writing MP STREAMS drivers and STREAMS modules, refer to
Chapter 4 for specific MP requirements. Chapter 4 provides examples of
driver headers and driver install routines relating to MP drivers and
modules.
The driver header can be declared in either a .h or in the .c file that contains
the driver install entry point. The driver install entry point MUST be in a .c
file.
For both STREAMS drivers and STREAMS modules, the following include
files contain the needed structures and defines:
#include “../h/conf.h”
#include “../h/stream.h”
Streams Driver
For STREAMS drivers, the following data structures will need to be
declared in the .h or .c file: drv_info_t, drv_ops_t and streams_info_t.