Specifications
Sample Driver Written in C
B.1 LRDRIVER Example
* None.
*
* Environment:
*
* Kernel mode, system context, IPL may be as high as 31 and may not be
* altered.
*
*/
void lr$struc_init (CRB *crb, DDB *ddb, IDB *idb, ORB *orb, LR_UCB *ucb) {
/* Initialize the fork lock and device IPL fields */
ucb->ucb$r_ucb.ucb$b_flck = SPL$C_IOLOCK8;
ucb->ucb$r_ucb.ucb$b_dipl = DEVICE_IPL;
/* Device Characteristics are : Record oriented (REC), Available (AVL),
* Carriage control device (CCL), Output device (ODV)
*/
ucb->ucb$r_ucb.ucb$l_devchar = DEV$M_REC | DEV$M_AVL | DEV$M_CCL | DEV$M_ODV;
/* Set to prefix device name with "node$", set device class, device type,
* and default buffer size.
*/
ucb->ucb$r_ucb.ucb$l_devchar2 = DEV$M_NNM;
ucb->ucb$r_ucb.ucb$b_devclass = DC$_LP;
ucb->ucb$r_ucb.ucb$b_devtype = LP$_LP11;
ucb->ucb$r_ucb.ucb$w_devbufsiz = 132;
/* Lines per page in highest byte of ucb$l_devdepend and LP attributes
* in lower three bytes.
*/
ucb->ucb$r_ucb.ucb$l_devdepend = (LINES_PER_PAGE << 24) |
LP$M_MECHFORM | LP$M_TRUNCATE;
/* Initialize LR device mutex as unowned */
ucb->ucb$l_lr_mutex.mtx$w_owncnt = -1;
return;
}
/*
* LR$STRUC_REINIT - Device Data Structure Re-Initialization Routine
*
* Functional description:
*
* This routine is called once for each unit by the $LOAD_DRIVER service
* immediately after the structure initialization routine is called.
*
* Additionally, this routine is called once for each unit by the $LOAD_DRIVER
* service when a driver image is RELOADED. Thus, this routine is
* responsible for filling in the fields in the I/O database structures
* that point into this driver image.
*
* Note that this routine must confine its actions to filling in these I/O
* database structures.
*
* Calling convention:
*
* lr$struc_reinit (crb, ddb, idb, orb, ucb)
*
* Input parameters:
*
* crb Pointer to associated controller request block.
* ddb Pointer to associated device data block.
* idb Pointer to associated interrupt dispatch block.
* orb Pointer to associated object rights block.
B–7