HAI_Object_Update

Updates the information passed back in the DeviceInfoStruct. This is essential for custom HAMs to update the UpdateInfoDef portion of DeviceInfoStruct similar to how the CDM calls the CDI_Object_Update. It can also update information for non-custom HAMs.

Thread Context:Blocking

Syntax

    LONG HAI_Object_Update (
       LONG                     npaBusHandle,
       LONG                     deviceHandle,
       struct DeviceInfoStruct *deviceInfo,
       LONG                     reasonFlag
    );
    
    

Parameters

npaBusHandle
Handle returned by HAI_Activate_Bus in the HAM initialization.
deviceHandle
HAM-generated handle to the device which was passed back in the DeviceInfoStruct during initial and subsequent scans.
deviceInfo
A DeviceInfoStruct containing static and state information on the device. If the device is an haType 3 (custom HAM) device then an UpdateInfoStruct is encapsulated within this structure, which is used to report state information.
reasonFlag
See CDI_Object_Update reasonFlag.

Return Values

The following table lists return values and descriptions.

zero

Successful

nonzero

Unsuccessful

Remarks

If the device is not an haType 3 (custom HAM) device, all the information in the deviceInfo field is updated. This is useful to update scatter-gather, threshold, and other information.

If the device is an haType 3 (custom HAM) device, the changes in state information are passed back in the UpdateInfoStruct member of the DeviceInfoStruct structure. The rules regarding the contents of the UpdateInfoStruct are identical for custom HAMs and standard CDMs. The entire structure should contain 0xFF for each byte except those fields that have changed. In this way, only the fields affected by the state change are updated in the Media Manager database.

Example

The following code fragment shows how a mount event, which was spawned in response to a mount request, could update the state information for the given device. This code demonstrates only the way in which the device state might be updated and overlooks the possibility of aborts during the blocking event which would normally be handled.

    void MountEvent (LONG npaBusHandle, struct DeviceInfoStruct *device,LONG param0) 
    { 
       struct DeviceInfoDef tempInfo;
       LONG ccode = ERROR_NO_ERROR_FOUND;
     
       /* Copy the device info for the current device to the temporary buffer */ 
       CMovB(device, &tempInfo, sizeof(struct DeviceInfoStruct));
       CSetB(0xff , &tempInfo.updateInfo, sizeof(struct UpdateInfoStruct)));
       /* All the unused fields in the update info will contain 0xff */ 
     
       /* Set or reset the activate flag */ 
       switch(param0) 
       { 
       case 0: /* Try to perform a Mount */ 
          if (MountDevice(device) != ERROR) 
          { 
             device->updateInfo.activateFlag = 1;
             HAI_Object_Update(npaBusHandle, device->deviceHandle, device);
             break;
          } 
          else 
          ccode = ERROR_DEVICE_ERROR;
       case 1: /* See if the dismount can be processed */ 
          . 
          . 
          . 
       default: ccode = ERROR_PARAMETER_ERROR;
           break;
       } 
       return(ccode);
       }
    

IMPORTANT:Note that a dismount for a custom HAM requires special attention. The HAI_Object_Update notifying the Media Manager of the dismount must be called after the HACB for the dismount has been completed with HAI_Complete_HACB. Otherwise, during the HACB completion, the device no longer exists and the server abends.