STREAMS-UX Programmer's Guide (February 2007)

Modules and Drivers
Data Structures
Chapter 4
68
Configuration Routines
The following are the configuration routines for drivers:
driver
_install():
All STREAMS drivers and modules that are to be statically built into the kernel must
implement a driver_install() function. The variable is the name of the module or driver
as defined in the module_info structure. The driver must match the name specified in
drv_info_t/streams_info_t for drivers.
STREAMS Drivers: STREAMS drivers must call install_driver() and
str_install() to register the driver with the system
and populate the system structures and tables.
STREAMS Modules: STREAMS modules must call str_install() to
register the module with the system and populate the
STREAMS subsystem tables. The install_driver()
routine is not applicable for STREAMS modules.
install_driver()
Initializes the cdevsw[] table with the d_flag and drv_info_t corresponding to the driver
being configured.
str_install()
1. Initializes the entry points specified in the cdevsw[] table with the STREAMS-specific
entry points.
2. Updates dmodsw switch tables for a STREAMS driver or the fmodsw for the STREAMS
modules. These tables are internal to STREAMS subsystem.
Drivers can define additional configuration routines if required, for example, interface drivers (LAN, SLIP, etc
need to define
driver
_attach(),
driver
_init(), etc.). Refer to the HP-UX Driver Development Guide for
more details on how to write a driver.
The
driver
_install() routine must return 0 if the driver is installed successfully, and return the return
value of install_driver() or str_install() in case of failure.
The following code snippet illustrates the installation structures and configuration routines for a dummy
STREAMS driver named drv:
static streams_info_t drv_str_info = {
"drv",
-1,
{ &drv_rinit, &drv_winit, NULL, NULL },
STR_IS_DEVICE | MGR_IS_MP | STR_SYSV4_OPEN,
SQLVL_QUEUEPAIR,
""
};
static drv_info_t drv_drv_info = {
"drv",
"pseudo",
DRV_CHAR | DRV_PSEUDO | DRV_MP_SAFE,