Life Cycle of a Storport Driver

The life cycle of a Storport driver can be described in terms of the callback routines into the miniport driver from the Storport driver. The callback routines can be categorized into several main groups, as shown in Figure 1.

figure illustrating overall storport architecture.

Several examples of each type of callback routine are shown in Figure 2. When the system starts and the driver is first loaded, the miniport driver's DriverEntry routine is called. This routine fills out a data structure that provides Storport with the miniport driver's entry points, also known as its callback routines, or callbacks. Near the end of this routine, the miniport driver calls StorPortInitialize. The Storport driver then calls the miniport callback routine HwStorFindAdapter, or in the case of a virtual miniport driver, VirtualHwStorFindAdapter. After returning from that routine, the miniport driver's HwStorInitialize routine is called.

Storport then obtains the miniport driver's supported control types by calling its HwStorAdapterControl routine with ScsiQuerySupportedControlTypes as a parameter.

figure 2: storport callback routines.

The main I/O path consists of a series of calls to HwStorBuildIo (except in the case of a virtual miniport driver) and HwStorStartIo. For more information, see Unsynchronized HwStorBuildIo Routine.

When the system is shutdown, HwStorStartIo is called with an SRB of type SRB_FUNCTION_SHUTDOWN. When an adapter is removed or disabled while the system is running, or when the system is entering hibernate mode, HwStorAdapterControl is called with ScsiStopAdapter as a parameter. When the system is resuming from hibernate mode, HwStorAdapterControl is called with ScsiRestartAdapter as a parameter.