Specifications
Sample Driver Written in C
B.1 LRDRIVER Example
*
* Environment:
*
* Kernel mode, system context, IPL 31.
*/
int lr$unit_init (IDB *idb, LR_UCB *ucb) {
static int combo_initialized = 0; /* First unit is on system bus */
CRAM *cram;
ADP *adp;
int isa_io_addr; /* Slot I/O address if ISA option */
int device_data; /* Data from or for CRAM */
int status;
#if defined DEBUG
/* If a debug version of this driver is being built then invoke the loaded
* system debugger. This could either be the High Level Language System
* Debugger, XDELTA, or nothing.
*/
{
extern void ini$brk (void);
ini$brk ();
}
#endif
/* Set device initially offline (for error exits) and initialize other
* UCB cells.
*/
ucb->ucb$r_ucb.ucb$v_online = 0;
ucb->ucb$l_lr_msg_tmo = LR_OFFLINE_TMO;
/* This driver can service only a single unit per DDB and IDB. Thus,
* make the single unit the permanent owner of the IDB. This facilitates
* getting the UCB address in our interrupt service routine.
*/
idb->idb$ps_owner = &(ucb->ucb$r_ucb);
/* Initialize the three CRAMs that were requested in our DPT and allocated
* before this unit initialization routine was called.
*/
adp = ucb->ucb$r_ucb.ucb$ps_adp; /* Pointer to our ADP */
cram = ucb->ucb$r_ucb.ucb$ps_cram; /* Pointer to first CRAM */
/* Note that this driver assumes that the first unit that it initializes
* is the VL82C106 on the system bus. All subsequent units are for ISA
* option cards.
*/
if ( ! combo_initialized ) {
combo_initialized = 1; /* Unit on system bus initialized */
ucb->ucb$l_lr_combo = 1; /* This unit is for VL82C106 on system bus */
/* Initialize CRAM used to write the data register */
cram->cram$v_der = 1;
ucb->ucb$ps_cram_lwd = cram;
ioc$cram_cmd (CRAMCMD$K_WTLONG32, LR_COMBO_LWD, adp, cram, 0);
/* Initialize CRAM used to read the status register */
cram = cram->cram$l_flink;
cram->cram$v_der = 1;
ucb->ucb$ps_cram_lps = cram;
ioc$cram_cmd (CRAMCMD$K_RDLONG32, LR_COMBO_LPS, adp, cram, 0);
/* Initialize CRAM used to write the control register */
B–9