Negotiating Claim and Release Device Requests with SCSI Port

Storage class drivers must request permission from SCSI Port 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 SCSI Port driver mediates between pre-PNP and PnP drivers that attempt to control the same device. Therefore, a storage device driver must obtain permission from SCSI Port before interacting with its device.

To obtain permission to use a device, the device driver sends a claim request to SCSI Port, usually in its AddDevice routine. 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.

SCSI Port maintains a flag for each device that indicates whether the device has been claimed. SCSI Port sets this flag in response to a SRB_FUNCTION_CLAIM_DEVICE request; SCSI Port 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, SCSI Port 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, SCSI Port fails the claim request IRP and returns status of STATUS_DEVICE_BUSY.

If the claim request succeeds, SCSI Port 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 SCSI Port 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.