Specifications

Sample Driver Written in C
B.1 LRDRIVER Example
/*
* DRIVER$INIT_TABLES - Initialize Driver Tables
*
* Functional description:
*
* This routine completes the initialization of the DPT, DDT, and FDT
* structures. If a driver image contains a routine named DRIVER$INIT_TABLES
* then this routine is called once by the $LOAD_DRIVER service immediately
* after the driver image is loaded or reloaded and before any validity checks
* are performed on the DPT, DDT, and FDT. A prototype version of these
* structures is built into this image at link time from the
* VMS$VOLATILE_PRIVATE_INTERFACES.OLB library. Note that the device related
* data structures (e.g. DDB, UCB, etc.) have not yet been created when this
* routine is called. Thus the actions of this routine must be confined to
* the initialization of the DPT, DDT, and FDT structures which are contained
* in the driver image.
*
* Calling convention:
*
* status = driver$init_tables ();
*
* Input parameters:
*
* None.
*
* Output parameters:
*
* None.
*
* Return value:
*
* status If the status is not successful, then the driver image will
* be unloaded. Note that the ini_* macros used below will
* result in a return from this routine with an error status if
* an initialization error is detected.
*
* Implicit inputs:
*
* driver$dpt, driver$ddt, driver$fdt
* These are the externally defined names for the prototype
* DPT, DDT, and FDT structures that are linked into this driver.
*
* Environment:
*
* Kernel mode, system context.
*/
int driver$init_tables () {
/* Prototype driver DPT, DDT, and FDT will be pulled in from the
* VMS$VOLATILE_PRIVATE_INTERFACES.OLB library at link time.
*/
extern DPT driver$dpt;
extern DDT driver$ddt;
extern FDT driver$fdt;
/* Finish initialization of the Driver Prologue Table (DPT) */
ini_dpt_name (&driver$dpt, "LRDRIVER");
ini_dpt_adapt (&driver$dpt, AT$_KA0602);
ini_dpt_defunits (&driver$dpt, 1);
ini_dpt_ucbsize (&driver$dpt, sizeof(LR_UCB));
ini_dpt_struc_init (&driver$dpt, lr$struc_init );
ini_dpt_struc_reinit(&driver$dpt, lr$struc_reinit );
ini_dpt_ucb_crams (&driver$dpt, NUMBER_CRAMS);
ini_dpt_end (&driver$dpt);
B–5