Specifications

Sample Driver Written in C
B.1 LRDRIVER Example
/* If we successfully sent a character to the device then we’re back in
* business. Set up a wait for the completion of the I/O via wfikpch
* just like our start I/O routine. Wfikpch will restore the device lock
* and restore IPL. But first, clear the offline count and set the offline
* message interval to its initial value. And, return from this routine.
*/
if ( $VMS_STATUS_SUCCESS(status) ) {
ucb->ucb$l_lr_msg_tmo = LR_OFFLINE_TMO;
ucb->ucb$l_lr_oflcnt = 0;
wfikpch (lr$iodone_fork, lr$wfi_timeout, irp, 0, ucb,
LR_WFI_TMO, orig_ipl);
return;
}
/* Otherwise, the device is still offline. Increment the offline time. */
ucb->ucb$l_lr_oflcnt++;
/* Restore the device lock, return to the original entry IPL */
device_unlock (ucb->ucb$r_ucb.ucb$l_dlck, orig_ipl, SMP_RESTORE);
/* If the offline count has reached the "device offline" message interval
* then it’s time to send it to OPCOM and start a new offline interval.
* If this message interval was less than an hour, double the next one.
*/
if (ucb->ucb$l_lr_oflcnt >= ucb->ucb$l_lr_msg_tmo) {
extern MB_UCB *sys$ar_oprmbx; /* Pointer to OPCOM mbx ucb */
exe_std$sndevmsg (sys$ar_oprmbx, MSG$_DEVOFFLIN, &(ucb->ucb$r_ucb));
ucb->ucb$l_lr_oflcnt = 0;
if (ucb->ucb$l_lr_msg_tmo < ONE_HOUR)
ucb->ucb$l_lr_msg_tmo *= 2;
}
/* Setup to check the device again in one second via the fork-wait queue */
fork_wait (lr$check_ready_fork, irp, 0, ucb);
return;
}
B–22