Specifications
Sample Driver Written in C
B.1 LRDRIVER Example
/* Expand the suffix carriage control into the allocated system
* buffer. If the carriage control count is non-zero and the
* carriage control character is 0, this means "new line." Output
* an initial CR, then the counted number of LFs.
*/
carcon_count = ((CARCON *) &irp->irp$b_carcon)->suffix_count;
if (carcon_count != 0) {
carcon_char = ((CARCON *) &irp->irp$b_carcon)->suffix_char;
if (carcon_char == 0) {
*sys_datap++ = CR;
irp->irp$l_bcnt++;
carcon_char = LF;
}
irp->irp$l_bcnt += carcon_count;
for ( ; carcon_count > 0 ; carcon_count--) {
*sys_datap++ = carcon_char;
}
}
}
/* Queue this I/O request to the start I/O routine and return SS$_FDT_COMPL
* back to the FDT dispatcher in the $QIO system service.
*/
return ( call_qiodrvpkt (irp, (UCB *)ucb) );
}
/*
* LR$STARTIO - Start I/O Routine
*
* Functional description:
*
* This routine is the driver start I/O routine. This routine is called
* by ioc_std$initiate to process the next I/O request that has been
* queued to this device. For this driver, the only function that is
* passed to the start I/O routine is a write operation.
*
* Before this routine is called, ucb$v_cancel, ucb$v_int, ucb$v_tim, and
* ucb$v_timout are cleared. The ucb$l_svapte, ucb$l_boff, and ucb$l_bcnt
* cells are set from their corresponding IRP cells. However, unlike their
* IRP counterparts, these UCB cells are working storage and can be changed
* by a driver. This driver uses ucb$l_svapte to point to the next byte
* to output in the system buffer packet, and irp$l_bcnt to keep the count
* of the remaining bytes to output.
*
* This routine acquires the device lock and raises IPL to device IPL.
* The device lock is restored and the original IPL is restored via wfikpch
* before this routine returns to its caller.
*
* Calling convention:
*
* lr$startio (irp, ucb)
*
* Input parameters:
*
* irp Pointer to I/O request packet
* ucb Pointer to unit control block
*
* Output parameters:
*
* None.
*
* Return value:
*
* None.
B–15










