STREAMS-UX Programmer's Guide (February 2007)
Modules and Drivers
STREAMS Driver
Chapter 4
98
Flow Control in Drivers
In general, the same utilities and mechanisms used in implementing module flow control are used by drivers
too.
STREAMS allows flow control to be used on the driver read-side to handle temporary upstream blocks. The
driver or a module has an option of resetting the stream head read-side flow control limits by sending a
M_SETOPTS message upstream.
Sample Driver Example
The following is an excerpt of the sample driver example:
/* Sample Driver inclusions */
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/stream.h>
#include <sys/stropts.h>
/* Streams data structures for Drivers */
int drv_open __((queue_t *, dev_t *, int, int, cred_t *));
int drv_close __((queue_t *, int, cred_t *));
int drv_wput __((queue_t * q, mblk_t *));
int drv_rsrv __((queue_t * q));
#define MOD_ID 0
static struct module_info minfo = {
MOD_ID, "drv", 0, INFPSZ, 65536, 1024
};
static struct qinit drv_rinit = {
NULL, drv_rsrv, drv_open, drv_close, NULL, &minfo
};
static struct qinit drv_winit = {
drv_wput, NULL, NULL, NULL, NULL, &minfo
};
static drv_info_t drv_info = {
"drv", /* Driver name */
"pseudo", /* Driver Class */