Specifications
Sample Driver Written in C
B.1 LRDRIVER Example
/* Define system data structure types and constants */
#include <ccbdef.h> /* Channel control block */
#include <crbdef.h> /* Controller request block */
#include <cramdef.h> /* Controller register access method */
#include <dcdef.h> /* Device codes */
#include <ddbdef.h> /* Device data block */
#include <ddtdef.h> /* Driver dispatch table */
#include <devdef.h> /* Device characteristics */
#include <dptdef.h> /* Driver prologue table */
#include <fdtdef.h> /* Function decision table */
#include <fkbdef.h> /* Fork block */
#include <idbdef.h> /* Interrupt data block */
#include <iocdef.h> /* IOC constants */
#include <iodef.h> /* I/O function codes */
#include <irpdef.h> /* I/O request packet */
#include <ka0602def.h> /* DEC 2000 Model 300 AXP specific defs */
#include <lpdef.h> /* Line printer definitions */
#include <orbdef.h> /* Object rights block */
#include <pcbdef.h> /* Process control block */
#include <msgdef.h> /* System-wide mailbox message codes */
#include <mtxdef.h> /* Longword mutex */
#include <ssdef.h> /* System service status codes */
#include <stsdef.h> /* Status value fields */
#include <ucbdef.h> /* Unit control block */
#include <vecdef.h> /* IDB interrupt transfer vector */
/* Define function prototypes for system routines */
#include <exe_routines.h> /* Prototypes for exe$ and exe_std$ routines */
#include <ioc_routines.h> /* Prototypes for ioc$ and ioc_std$ routines */
#include <sch_routines.h> /* Prototypes for sch$ and sch_std$ routines */
/* Define various device driver macros */
#include <vms_drivers.h> /* Device driver support macros, including */
/* table initialization macros and prototypes*/
/* Define the DEC C functions used by this driver */
#include <builtins.h> /* OpenVMS AXP specific C builtin functions */
#include <string.h> /* String routines provided by "kernel CRTL" */
/* Define constants specific to this driver */
enum { /* Miscellaneous constants */
DEVICE_IPL = 21, /* Interrupt priority level of device */
NUMBER_CRAMS = 3, /* Number of CRAMs needed */
LINES_PER_PAGE = 66, /* Default paper size */
DATA_EXPND_CUSHION = 32 /* Extra room in system buffer for expansion */
};
enum { /* Define various timeout constants */
LR_WFI_TMO = 15, /* Interrupt timeout value in seconds */
LR_OFFLINE_TMO = 60, /* Initial interval between offline messages */
ONE_HOUR = (60*60) /* One hour in seconds */
};
enum { /* Define names for some ASCII characters */
CR = ’\x0d’, /* Carriage return character */
LF = ’\x0a’ /* Line feed character */
};
B–2