// storport.h
HW_BUILDIO HwBuildio;
BOOLEAN HwBuildio(
PVOID DeviceExtension,
PSCSI_REQUEST_BLOCK Srb
)
{...}
View the official Windows Driver Kit DDI referenceNo description available.
The HwStorBuildIo routine processes the SRB with unsynchronized access to shared system data structures before passing it to HwStorStartIo.
DeviceExtensionA pointer to the miniport driver's per HBA storage area.
SrbA pointer to the SCSI request block (SRB) to be processed.
HwStorBuildIo returns TRUE to inform the caller that StorPort should call the HwStorStartIo routine if StorPort considers the LUN ready to receive I/O. HwStorBuildIo returns FALSE to inform the caller that the SRB should not be passed to HwStorStartIo. In such cases, the miniport driver must complete the SRB by calling StorPortNotification with a notification type of RequestComplete. This can be done in HwStorBuildIo or elsewhere in the miniport driver, as long as the SRB is completed before the timeout that is specified in the TimeOutValue field of the SRB structure.
The name HwStorBuildIo is just a placeholder for the miniport function that is pointed to by the HwBuildIo member in the HW_INITIALIZATION_DATA structure. The actual prototype of this routine is defined in Storport.h as follows:
typedef
BOOLEAN
HW_BUILDIO (
_In_ PVOID DeviceExtension,
_In_ PSCSI_REQUEST_BLOCK Srb
);
The port driver calls the HwStorBuildIo routine at DISPATCH IRQL without holding any spin locks. Because of this, memory allocation using StorPortAllocatePool and mutual exclusion via StorPortAcquireSpinLock are allowed in HwStorBuildIo. In a multiprocessor environment, more than one HwStorBuildIo can be active at a time, so the miniport driver is required to synchronize access to system resources, which may be in contention if more than one instance of HwStorBuildIo is active at any given time.
By completed time-consuming I/O setup activities in HwStorBuildIo instead of in HwStorStartIo, the miniport driver enables greater I/O concurrency and therefore improves I/O throughput. For highest performance, miniport drivers are expected to do as much preprocessing as possible in HwStorBuildIo so that it can send requests to the HBA via HwStorStartIo in as short amount of time as possible. Preprocessed data and state can be stored in either the DeviceExtension or SrbExtension structures. Only modifications to unique portions of the DeviceExtension must occur since no locks are held. HwStorBuildIo and HwStorStartIo receive the following Srb function types:
SRB_FUNCTION_EXECUTE_SCSI: Sends a CDB to the specified bus/target/lun.
SRB_FUNCTION_IO_CONTROL: Miniport defined.
SRB_FUNCTION_RESET_LOGICAL_UNIT: Reset the specified logical unit (if the device is capable).
SRB_FUNCTION_RESET_DEVICE: Reset the specified Scsi Target.
SRB_FUNCTION_RESET_BUS: Reset all of the targets on the specified SCSI bus.
SRB_FUNCTION_FLUSH: Instructs the miniport driver to flush all cached data.
SRB_FUNCTION_SHUTDOWN: Instructs the miniport driver to flush all cached data preparatory to shut down.
SRB_FUNCTION_DUMP_POINTERS: Supplies information needed for the miniport driver to support crash dump and hibernation.
SRB_FUNCTION_FREE_DUMP_POINTERS: Starting with Windows 8, this request is sent to the miniport to free resources allocated during the SRB_FUNCTION_DUMP_POINTERS request.
Starting in Windows 8, the Srb parameter may point to either SCSI_REQUEST_BLOCK or STORAGE_REQUEST_BLOCK. If the function identifier in the Function field of Srb is SRB_FUNCTION_STORAGE_REQUEST_BLOCK, the SRB is a STORAGE_REQUEST_BLOCK request structure.
For more information about what you can and cannot do safely in this miniport driver routine, see Unsynchronized HwStorBuildIo Routine.
To define a HwStorBuildIo callback function, you must first provide a function declaration that identifies the type of callback function you’re defining. Windows provides a set of callback function types for drivers. Declaring a function using the callback function types helps Code Analysis for Drivers, Static Driver Verifier (SDV), and other verification tools find errors, and it’s a requirement for writing drivers for the Windows operating system.
For example, to define a HwStorBuildIo callback routine that is named MyHwBuildIo, use the HW_BUILDIO type as shown in this code example:
HW_BUILDIO MyHwBuildIo;
Then, implement your callback routine as follows:
_Use_decl_annotations_
BOOLEAN
MyHwBuildIo (
_In_ PVOID DeviceExtension,
_In_ PSCSI_REQUEST_BLOCK Srb
);
{
...
}
The HW_BUILDIO function type is defined in the Storport.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the _Use_decl_annotations_ annotation to your function definition. The _Use_decl_annotations_ annotation ensures that the annotations that are applied to the HW_BUILDIO function type in the header file are used. For more information about the requirements for function declarations, see Declaring Functions Using Function Role Types for Storport Drivers. For information about _Use_decl_annotations_, see Annotating Function Behavior.
PORT_CONFIGURATION_INFORMATION