Driver Initialization and Registration

The IOS initializes a device driver that has not been previously loaded by sending a SYS_DYNAMIC_DEVICE_INIT message to the driver's control procedure. It sends the message once for each load group to which the driver belongs. When the driver receives the message, it registers itself with the IOS by setting the DRP_aer and DRP_ilb members of its DRP structure and passing the address of the structure to the IOS_Register service. The IOS uses the DRP structure to register the driver and initialize internally-maintained structures, such as the DVT structure, for the driver.

The driver must set the DRP_aer field to the address of the driver's asynchronous event routine. The IOS calls this routine, passing it asynchronous event packets (AEPs), when it wants the driver to carry out specific tasks. For example, to complete driver registration, the IOS calls the routine with a packet for an AEP_INITIALIZE function. This occurs before the IOS_Register service returns, so the driver must be prepared to process the call as part of its registration.

The driver also must set the DRP_ilb field to the address of a ILB structure for the driver. The IOS sets several members in the ILB structure, such as ILB_service_rtn, which the driver can use to call the corresponding IOS service routines to carry out useful tasks.

Because a driver needs the DRP structure only during initialization, the structure is typically defined in the driver's IDATA segment and is discarded after initialization. The ILB structure should not be discarded.

To manage the device drivers, the IOS creates a chain of DVT structures that contain information about the device driver, such as its filename and the address of its asynchronous event routine. The IOS initially adds a DVT structure to the chain for itself. Thereafter, the IOS adds a new DVT structure whenever a new driver or client first registers with the IOS. The IOS places the address of the DVT structure for a driver in the ILB structure, however, drivers should avoid modifying the DVT.

The IOS indicates whether the registration succeeded by setting the DRP_reg_result member. When the IOS_Register service returns, the driver must check the value of this member. If the registration is successful, the driver clears the carry flag and returns from processing the SYS_DYNAMIC_DEVICE_INIT message. Otherwise, the driver must set the carry flag and return.

See also DRP, DVT, ILB, IOS_Register