Specifications

Sample Driver Written in C
B.1 LRDRIVER Example
typedef struct {
UCB ucb$r_ucb; /* Generic UCB */
MTX ucb$l_lr_mutex; /* Line printer UCB mutex */
int ucb$l_lr_msg_tmo; /* Time out value for device offline msg */
int ucb$l_lr_oflcnt; /* Offline time, print msg when reaches lr_msg_tmo */
int ucb$l_lr_cursor; /* Current horizontal position */
int ucb$l_lr_lincnt; /* Current line count on page */
int ucb$l_lr_combo; /* Unit is on system bus, not ISA option */
int ucb$l_lr_isa_io_address[2]; /* ISA I/O address range */
int ucb$l_lr_isa_irq[2]; /* IRQ returned from ioc$node_data */
CRAM *ucb$ps_cram_lwd; /* Line printer write data register */
CRAM *ucb$ps_cram_lps; /* Line printer status register */
CRAM *ucb$ps_cram_lcw; /* Line printer control register write */
} LR_UCB;
/* Define the packet header for a system buffer for buffered I/O data */
typedef struct _sysbuf_hdr {
char *pkt_datap; /* Pointer to start of data in packet */
char *usr_bufp; /* User VA of user buffer */
short pkt_size; /* Size of the system buffer packet */
short :16;
} SYSBUF_HDR;
/* Prototypes for driver routines defined in this module */
/* Driver table initialization routine */
int driver$init_tables ();
/* Device I/O database structure initialization routine */
void lr$struc_init (CRB *crb, DDB *ddb, IDB *idb, ORB *orb, LR_UCB *ucb);
/* Device I/O database structure re-initialization routine */
void lr$struc_reinit (CRB *crb, DDB *ddb, IDB *idb, ORB *orb, LR_UCB *ucb);
/* Unit initialization routine */
int lr$unit_init (IDB *idb, LR_UCB *ucb);
/* FDT routine for write functions */
int lr$write (IRP *irp, PCB *pcb, LR_UCB *ucb, CCB *ccb);
/* FDT routine for set mode and set characteristics functions */
int lr$setmode (IRP *irp, PCB *pcb, LR_UCB *ucb, CCB *ccb);
/* Start I/O routine */
void lr$startio (IRP *irp, LR_UCB *ucb);
/* Local routine that sends the next character to the device */
static int lr$send_char_dev (LR_UCB *ucb);
/* Interrupt service routine */
void lr$interrupt (IDB *idb);
/* Driver fork routine entered when all I/O completed by interrupt service */
void lr$iodone_fork (IRP *irp, void *not_used, LR_UCB *ucb);
/* Wait-for-interrupt timeout routine */
void lr$wfi_timeout (IRP *irp, void *not_used, LR_UCB *ucb);
/* Periodic Check for Device Ready via Fork-wait mechanism */
void lr$check_ready_fork (IRP *irp, void *not_used, LR_UCB *ucb);
B–4