4.5 Removable Media Support

NWPA provides a specific set of control functions to support removable-media devices. NWPA packages these control functions in CDM messages.

This section covers the following topics:

Detailed descriptions of the message control function operations can be found in CDM Message Control Functions and the message I/O function operations can be found in CDM Message I/O Functions. NWPA expects all CDMs managing removable-media devices to support the functions marked Mandatory. The remaining subsections describe the use of these control functions.

4.5.1 Mount, Lock, and Activate Messages

The key difference between CDMs supporting fixed-media devices and CDMs supporting removable-media devices is that the CDM_Inquiry routine of a removable-media CDM can be called at a time when there is no media in the device. As mentioned in Inquiring and Binding to a Device, CDM_Inquiry is the entry point where the CDM queries the device and decides whether it will bind (CDI_Bind_CDM_To_Object) to the device. Part of the bind process requires the CDM to fill out an instance of an UpdateInfoStruct for the device and its media. Because a piece of media might not be loaded at bind-time, it is impossible for the CDM to know all of the information necessary to fill out the UpdateInfoStruct and make the device active.

The purpose of the Mount function is to give a CDM a second opportunity (other than at bind-time) to get the additional information it needs to complete the UpdateInfoStruct after a piece of media gets loaded into the device. The Activate function follows the Mount, and its purpose is to allow the CDM to handshake with NWPA to indicate that the device is active and ready to receive I/O. The following is an outline of the binding and activating paradigm for removable-media devices

  1. The CDM's CDM_Inquiry routine (the bind-time entry point) is called and no media is loaded in the device.
  2. The CDM decides it wants to bind to the removable-media device.
    1. The CDM fills out an instance of an UpdateInfoStruct for the device providing as much information as it can determine at the time. The removableFlag field should be set to 0x0001, the activateFlag field should be set to 0x0000, and the controlMask field should have the appropriate bits set indicating that the CDM supports the removable-media functions introduced in the Scan Completion Codes. At the very least, the bits corresponding to the mandatory functions should be set, and the CDM must provide a routine (or routines) that implement these control functions.
    2. The CDM completes the bind by calling CDI_Bind_CDM_To_Object passing it a pointer to the device's UpdateInfoStruct as an input parameter. Without media in the device, the device remains inactive until a user physically loads media into it and indicates the load to the system by issuing a console command.
  3. At some later time when a piece of media is inserted into the device, NWPA informs the CDM by issuing a Mount message. During the context of the Mount, the CDM issues HACB requests to confirm the existence of the media, get the additional device/media information it needs to complete the device's UpdateInfoStruct, and prepare the media for I/O. The CDM concludes the Mount by reporting the updated information to NWPA by calling CDI_Object_Update.
  4. If the appropriate bit is set in the controlMask field of the device's UpdateInfoStruct, the CDM may (see the following note) receive a Lock message following the Mount. If the CDM receives this message, it should lock the media in the device.

    The Lock function applies only to standalone, removable-media devices, not to changer or magazine type devices. The Lock function is issued at the discretion of the controlling application.

  5. To confirm that the device is ready to receive I/O, NWPA issues an Activate message. During the context of the function, the CDM should make sure that the media is capable of being activated, set the activateFlag field of the device's UpdateInfoStruct to 0x0001, and report the object update to NWPA by calling CDI_Object_Update. Upon completion of the Activate, the CDM must be ready to accept I/O requests for the device.

4.5.2 Dismount and Deactivate Messages

The CDM can receive a media Dismount or device Deactivate message at any time. When the CDM receives either one of these messages, it should set the activateFlag of the device's UpdateInfoStruct to 0x0000 and update the object by calling CDI_Object_Update. For a Dismount, the CDM should reset (set to -1) the other fields of the device's UpdateInfoStructprior to updating the object

4.5.3 Insert and Remove Messages

If the CDM indicates that it supports Insert and Remove functions for a device, the CDM should issue an insert media command if an Insert message is received. If a Remove message is recieved, the CDM should issue an an eject media command to the device.