Converting an Existing SCSI Class Driver for Plug and Play

To run successfully as a PnP driver, an existing SCSI class driver must be modified as follows:

  • Driver initialization code must follow the rules for initialization of a Plug and Play driver. Functionality in the DriverEntry routine of an existing SCSI driver is divided among the DriverEntry, AddDevice, and DispatchPnP routines of a storage class driver, as described in Storage Class Driver's DriverEntry Routine, Storage Class Driver's AddDevice Routine, and Handling PnP Start in a Storage Class Driver.

  • Code that builds SRBs must not set PathId, TargetId, and Lun fields to a target device address, and should initialize these fields to 0xFF. The device address is implicit in the PDO that represents a device and the driver must communicate only with such a device object, so it is unnecessary for the class driver to provide the device address.

  • Code that gets SCSI inquiry and capabilities data by issuing IOCTL_SCSI_GET_INQUIRY_DATA and IOCTL_SCSI_GET_CAPABILITIES requests should issue IOCTL_STORAGE_QUERY_PROPERTY requests to retrieve device and adapter descriptors instead.

  • The driver must handle PnP requests to start, stop, and remove the device, and must have a mechanism to fail such a request if handling it would interfere with data transfers or system operations. For example, a driver should fail a query-remove, query-stop, or stop request if its device contains a system page file. Such a driver should handle paging notification requests (IRP_MJ_PNP with IRP_MN_DEVICE_USAGE_NOTIFICATION and notification type of DeviceUsageTypePaging) to maintain the count of page files on its device.

  • The driver must handle requests to change the power state of the device (IRP_MJ_POWER with IRP_MN_QUERY_POWER and IRP_MN_SET_POWER), and must block I/O to the device during power state transitions.