4.6 Magazine Support

NWPA also supports magazine devices, and it allows upper layers to control the magazine and the media associated with the device. Before listing NWPA-specific control functions that provide magazine support, it is essential to discuss NWPA's concept of a magazine device:

Because control functions only apply to magazines, NWPA groups them into one CDM message category called Magazine Functions. This is why a CDM can indicate support of these functions by setting a single bit in the device’s controlMask. NWPA assigns 0x0000001D as the NWPA group-function number for the message category, and an individual member in the group is referenced by an NWPA subfunction number. For more details on NWPA numbering of this group and for detailed descriptions of each function in the group, refer to CDM Message Control Functions and CDM Message I/O Functions.

A CDM supporting a magazine binds to a device using the removable device paradigm. However, before the CDM calls CDI_Bind_CDM_To_Object, it should set the acceptsMagazinesFlag field of the device's UpdateInfoStruct to 0x0001, and also the magazineLoadedFlag field if a magazine is currently loaded. Again, all this is done at bind-time during the context of the CDM's CDM_Inquiry routine.

If at bind-time the CDM indicated that a magazine was not loaded in the device, the magazine device remains inactive until one gets loaded. Then, at some later time when a magazine is placed in the device, NWPA informs the CDM by issuing a Magazine Load message. This message function directs the CDM to verify the existence of a magazine and prepare it for use.

After the CDM confirms that the magazine is loaded, or if at bind-time the CDM indicated that a magazine was already loaded in the device, NWPA issues a Return Magazine Info message to the CDM. This message function directs the CDM to return the number of storage slots in the currently loaded magazine.

After the CDM completes the Return Magazine Info message, NWPA issues a Return Magazine Media Mapping message. This message function directs the CDM to inventory the magazine and the device to which the magazine is attached. The CDM then returns a byte-map indicating whether or not media is loaded in the device and which slots in the magazine have media. As an example, suppose the following:

The return byte-map would contain the following information:

Slot / Byte Index

Byte-Map Value

Comment

[ 0 ]

0x00

Indicates that the tape drive, slot[0], is empty.

[ 1 ]

0x01

Indicates that magazine storage slot[1] has media.

[ 2 ]

0x01

Indicates that magazine storage slot[2] has media.

[ 3 ]

0x00

Indicates that magazine storage slot[3] is empty.

[ 4 ]

0x00

Indicates that magazine storage slot[4] is empty.

The slot indexes shown above have particular significance. NWPA uses these indexes as slot indicators in subsequent magazine control functions. Index 0 always indicates the device, and indexes 1 to n indicate the respective storage slots of the magazine, where n is the total number of storage slots.

Successful completion of the Return Magazine Media Mapping message concludes magazine initialization. At this point, an application can select a piece of media and prepare it to receive I/O. The application selects a piece of media by issuing a Magazine Select Media message. When the CDM receives this message, it should move the piece of media indicated by the storage slot index number (specified in one of the message's input parameters) into the device. After the media is in the device, the Mount and Activate sequence described in the removable-media section begins. After the device is activated, the CDM will receive I/O requests for the device.

After an application is done with the media, it can remove the media from the device by issuing a Magazine Deselect Media message. When the CDM receives this message, it should remove the media currently in the device and return it to the storage slot indicated by the slot index number given in the message.

When the CDM receives a Magazine Unload message, it should unload the magazine, clear the magazineLoadedFlag field of the device's UpdateInfoStruct, and update the device object by calling CDI_Object_Update.

A CDM supporting devices with magazines must support the Magazine Eject function. However, for some magazine devices, ejects happen as part of the deselect process. In this case, when the CDM receives this message, it should successfully complete the message without performing any action. For those magazine devices that require an explicit eject, the CDM should issue a magazine eject to the device.