DDI: 8 sample driver

samp_start_io subordinate routine

samp_start_io( ) is a subordinate driver routine that is called by the samp_biostart( ) and samp_ioctl( ) entry point routines to determine whether an I/O operation can be initiated for this device instance. Many processes can queue I/O operations against this device, but I/O should not be initiated for an instance that is not ACTIVE.

After issuing an ASSERT( ) call to verify the priority level, the code calls the LOCK(D3) function to lock the instance's idata structure and then checks the cfg_state (configuration state) member.

If cfg_state is SUSPENDED, it blocks on the synchronization variable which is signaled by the CFG_RESUME or CFG_REMOVE subfunctions to the config(D2) entry point routine. Note that the SV_WAIT_SIG(D3) function is used because this is a long-term wait and must be interruptable by signals.

The driver will keep waiting; eventually the cfg_state should change to either REMOVED or ACTIVE and the code will take the appropriate action.

If cfg_state is set to REMOVED, the I/O operation can not be initiated. The driver unlocks the idata structure then returns the EIO error.

If cfg_state is neither SUSPENDED or REMOVED, it must be ACTIVE, so the driver increments the in_progress counter and calls the UNLOCK(D3) function to unlock the idata structure; control returns to the calling routine to continue with the I/O request.

© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005