Storage class drivers must request permission from Storport to claim a device. For more information about how a class driver claims a device, see Storage Class Driver's ClaimDevice Routine.
The process by which new devices are discovered and enumerated differs depending on whether they are PnP devices or pre-PnP storage devices. The Storport driver mediates between pre-PNP and PnP drivers that attempt to control the same device. Therefore, a storage device driver must obtain permission from Storport before interacting with its device. Furthermore, the device in question may be either the HBA itself, or a LUN that is attached to a target that is controlled by the HBA. However, when referring to devices that are claimed by a storage class driver, it is always the LUN that is being claimed, not the HBA.
To obtain permission to use a device, the device driver sends a claim request to Storport. The claim request consists of an IRP with an I/O control code of IOCTL_SCSI_EXECUTE_NONE and a pointer to an SRB at Parameters.Scsi.Srb. The SRB is of the function type SRB_FUNCTION_CLAIM_DEVICE.
Storport maintains a flag for each device that indicates whether the device has been claimed. Storport sets this flag in response to a SRB_FUNCTION_CLAIM_DEVICE request; Storport clears the flag in response to a SRB_FUNCTION_REMOVE_DEVICE request.
If a higher-level driver attempts to claim a device that does not exist, Storport fails the claim request IRP and returns a status of STATUS_DEVICE_DOES_NOT_EXIST.
If a higher-level driver attempts to claim a device that has already been claimed, Storport fails the claim request IRP and returns status of STATUS_DEVICE_BUSY.
If the claim request succeeds, Storport returns the current device object for the device in the data buffer pointer of the SRB.
To release a previously claimed device, higher-level drivers must send a release device request to the Storport driver: The release device request consists of an SRB with a Function value of SRB_FUNCTION_RELEASE_DEVICE.
For a discussion of claim device requests from the point of view of the storage class driver, see Storage Class Driver's ClaimDevice Routine.