Specifications

Sample Driver Written in C
B.1 LRDRIVER Example
/* The caller passes the address of their setmode buffer in the $QIO P1
* parameter.
*/
setmode_bufp = (SETMODE_BUF *) irp->irp$l_qio_p1;
/* Assure that the caller’s setmode buffer is readable by the caller.
* If not, abort the I/O request now with an ACCVIO status and return
* back to the FDT dispatcher in the $QIO system service.
*/
if (! ( __PAL_PROBER (setmode_bufp, sizeof(SETMODE_BUF)-1, irp->irp$b_rmod) ))
return ( call_abortio (irp, pcb, (UCB *)ucb, SS$_ACCVIO) );
/* Lock the UCB longword mutex for write access */
sch_std$lockw (&ucb->ucb$l_lr_mutex, pcb);
/* If function is SETCHAR then set dev class and type */
if (irp->irp$v_fcode == IO$_SETCHAR) {
ucb->ucb$r_ucb.ucb$b_devclass = setmode_bufp->devclass;
ucb->ucb$r_ucb.ucb$b_devtype = setmode_bufp->devtype;
}
/* Set the default buffer and device dependent characteristics */
ucb->ucb$r_ucb.ucb$w_devbufsiz = setmode_bufp->devbufsiz;
ucb->ucb$r_ucb.ucb$l_devdepend = setmode_bufp->devdepend;
/* Unlock the UCB mutex */
sch_std$unlock (&ucb->ucb$l_lr_mutex, pcb);
/* Finish the IO; return SS$_FDT_COMPL to the FDT dispatcher in the $QIO
* system service.
*/
return ( call_finishio (irp, (UCB *)ucb, SS$_NORMAL, 0) );
}
/*
* LR$WRITE - FDT Routine for Write Function Codes
*
* Functional description:
*
* This routine is called by the FDT dispatcher in the $QIO system service
* to process write functions. This FDT routine validates the request,
* allocates a buffered I/O packet, formats and copies the contents of the
* user buffer into the buffered I/O packet, and queues the IRP to this
* driver’s start I/O routine.
*
* When the IRP is successfully queued to the driver’s start I/O routine,
* irp$l_svapte points to the buffered I/O packet, irp$l_boff is the
* number of bytes that have been charged against the process, and irp$l_bcnt
* is the actual count of data bytes in the buffered I/O packet that are
* to be sent to the printer. Note that the contents of the irp$l_svapte
* and irp$l_boff cells must not be changed since I/O post processing will
* use these to deallocate the buffer packet and to credit the process.
*
* Since this is an upper-level FDT routine, this routine always returns
* the SS$_FDT_COMPL status. The $QIO status that is to be returned to
* the caller of the $QIO system service is returned indirectly by the
* FDT completion routines (e. g. exe_std$abortio, exe_std$qiodrvpkt) via
* the FDT context structure.
*
* Calling convention:
*
* status = lr$write (irp, pcb, ucb, ccb)
*
* Input parameters:
*
B–12