HW_BUILDIO - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// storport.h

HW_BUILDIO HwBuildio;

BOOLEAN HwBuildio(
  PVOID DeviceExtension,
  PSCSI_REQUEST_BLOCK Srb
)
{...}
View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nc-storport-hw_buildio)

HW_BUILDIO callback function

Description

The HwStorBuildIo routine processes the SRB with unsynchronized access to shared system data structures before passing it to HwStorStartIo.

Parameters

DeviceExtension

A pointer to the miniport driver's per HBA storage area.

Srb

A pointer to the SCSI request block (SRB) to be processed.

Return value

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.

Remarks

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:

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.

Examples

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.

See also

HwStorStartIo

PORT_CONFIGURATION_INFORMATION

SCSI_REQUEST_BLOCK

STORAGE_REQUEST_BLOCK

StorPortAcquireSpinLock

StorPortAllocatePool

StorPortNotification