Streaming DEV Structures
Streaming I/O and Device Drivers 7-31
Device driver functions take a DEV_Handle as their first or only parameter,
followed by any additional parameters. The DEV_Handle is a pointer to a
DEV_Obj, which is created and initialized by SIO_create and passed to
Dxx_open for additional initialization. Among other things, a DEV_Obj
contains pointers to the buffer queues that SIO and the device use to
exchange buffers. All driver functions take a DEV_Handle as their first
parameter.
Example 7-21. The DEV_Handle Structure
Example 7-21 has the following parameters:
❏ todevice is used to transfer DEV_Frame frames to the device. In the
SIO_STANDARD (DEV_STANDARD) streaming model, SIO_put puts
full frames on this queue, and SIO_get puts empty frames here. In the
SIO_ISSUERECLAIM (DEV_ISSUERECLAIM) streaming model,
SIO_issue places frames on this queue.
❏ fromdevice is used to transfer DEV_Frame frames from the device. In the
SIO_STANDARD (DEV_STANDARD) streaming model, SIO_put gets
empty frames from this queue, and SIO_get gets full frames from here.
In the SIO_ISSUERECLAIM (DEV_ISSUERECLAIM) streaming model,
SIO_reclaim retrieves frames from this queue.
❏ bufsize specifies the physical size of the buffers in the device queues.
❏ nbufs specifies the number of buffers allocated for this device in the
SIO_STANDARD streaming model, or the maximum number of
outstanding buffers in the SIO_ISSUERECLAIM streaming model.
❏ segid specifies the segment from which device buffers were allocated
(SIO_STANDARD).
typedef DEV_Obj *DEV_Handle;
typedef struct DEV_Obj { /* device object */
QUE_Handle todevice; /* downstream frames here */
QUE_Handle fromdevice; /* upstream frames here */
Uns bufsize; /* buffer size */
Uns nbufs; /* number of buffers */
Int segid; /* buffer segment ID */
Int mode; /* DEV_INPUT/DEV_OUTPUT */
LgInt devid; /* device ID */
Ptr params; /* device parameters */
Ptr object; /* ptr to dev instance obj */
DEV_Fxns fxns; /* driver functions */
Uns timeout; /* SIO_reclaim timeout value */
Uns align; /* buffer alignment */
DEV_Callback *callback; /* pointer to callback */
} DEV_Obj;