HwStorInitialize routine

The HwStorInitialize routine initializes the miniport driver after a system reboot or power failure occurs. It is called by StorPort after HwStorFindAdapter successfully returns. HwStorInitialize initializes the HBA and finds all devices that are of interest to the miniport driver.

Syntax


HW_INITIALIZE HwStorInitialize;

BOOLEAN HwStorInitialize(
  IN PVOID DeviceExtension
)
{ ... }

Parameters

DeviceExtension

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

Return value

If the initialization succeeds, HwStorInitialize returns TRUE.

Remarks

The name HwStorInitialize is just a placeholder. The actual prototype of this routine is defined in Storport.h as follows:


typedef
BOOLEAN
HW_INITIALIZE (
  _In_ PVOID  DeviceExtension
  );

Because HwStorInitialize is called at DIRQL, as much of the initialization process as possible should be performed by HwStorPassiveInitializeRoutine. If so, you must enable the passive initialization routine via StorPortEnablePassiveInitialization.

If interrupts are generated by the hardware initialization, the HwStorInterrupt routine will be called. In this case, the HwStorInitialize routine should set up any data that HwStorInterrupt expects (including a HwStorDpcRoutine, if one is used) before it begins to initialize the hardware.

The following responsibilities are shared between HwStorInitialize and HwStorPassiveInitializeRoutine:

  • Initialize hardware for the HBA registers and buffers.

  • Initialize and allocate all DeviceExtension fields.

  • Set up and initialize all events and DPCs that are used by the miniport driver.

Examples

To define an HwStorInitialize 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 HwStorInitialize callback routine that is named MyHwInitialize, use the HW_INITIALIZE type as shown in this code example:


HW_INITIALIZE MyHwInitialize;

Then, implement your callback routine as follows:


_Use_decl_annotations_
BOOLEAN 
  MyHwInitialize( _In_ PVOID DeviceExtension )
  {
      ...
  }

The HW_INITIALIZE 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_INITIALIZE 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.

Requirements

Header

Storport.h (include Storport.h)

IRQL

DIRQL (See Remarks section.)

See also

HwStorFindAdapter
HwStorPassiveInitializeRoutine
HwStorInterrupt
HwStorDpcRoutine

 

 

Send comments about this topic to Microsoft

Anzeigen:
© 2014 Microsoft