A.1.3.4 Setting up Device Extensions
In the device extension of each device object, the class driver provides storage for whatever driver-determined data it uses to manage I/O requests for the device, such as the pointer to the port driver’s HBA-specific device object, a back pointer to its own device object, and so forth.
Most SCSI class drivers also provide storage for the following SCSI-specific information:
·A device-type-specific time-out value
The class driver can pass the time-out value in SRBs it sends to the port driver, which optionally times requests on behalf of each class driver. The port driver returns an SRB with its SrbStatus member set to SRB_STATUS_TIMEOUT if the interval between when the port driver sends the request to the miniport driver and when the request completes exceeds the specified time-out value.
·A pointer to the class driver’s error-handling routine
See Section A.1.5 for more information about error-handling in SCSI class drivers.
·A count that the driver maintains of SCSI protocol errors on the device
·The PathId value
This identifies the SCSI bus on which the device is attached. It is a required value in SRBs.
·The TargetId value
This identifies the TID of the controller or device. It is a required value in SRBs.
·The Lun value
This identifies the logical unit number of the device. It is a required value in SRBs.
·A pointer to a driver-allocated buffer for SCSI request-sense data
A class driver must allocate memory for returned request-sense data from cache-aligned, nonpaged pool. For more information about allocating memory for driver buffers, see Chapter 16.
·A driver-determined default value for SrbFlags that the class driver sets in SRBs
·A pointer to a zone header if the driver sets up a zone buffer for the SRBs it allocates
If the driver calls the ExInterlocked..Zone routines for its SRBs, it also must provide storage for and initialize a spin lock that protects the zone’s free list. For more information about using zones and spin locks, see Chapter 16.
·A spin lock used to guarantee multiprocessor-safe access to a count of driver-allocated IRPs for partial transfer requests
·A pointer to the IO_SCSI_CAPABILITIES-type data that the port driver collected from the miniport driver of the HBA
How class drivers get and use this data was described in Section A.1.3.3.
Note that a SCSI class driver’s original call to IoGetDeviceObjectPointer creates a reference to the handle of the file object associated with the port driver’s generic device object. The class driver must call ObDereferenceObject to release this reference if the class driver is unloaded.
A Windows NT SCSI class driver cannot send requests through the system-supplied port driver to its device without using the port driver’s HBA-specific device object pointer that was stored in the device extension by the ClaimDevice routine.