A.4.2.1 Calling ScsiPortInitialize

If its HBA can be connected on more than one type of I/O bus, a miniport driver needs to call ScsiPortInitialize for each bus type and must have a HwScsiFindAdapter routine for each bus type. Such a miniport driver must modify the AdapterInterfaceType and HwScsiFindAdapter members in the HW_INITIALIZATION_DATA after each call to ScsiPortInitialize, possibly modify the miniport-supplied context data for the new bus type, and call ScsiPortInitialize for each type of bus on which a supported HBA might be connected.

Before it calls the miniport's HwScsiFindAdapter routine, ScsiPortInitialize does all of the following:

·Checks the validity of the HW_INITIALIZATION_DATA

·Collects and stores pertinent information in the device extension of a device object that it creates to represent the HBA

·Allocates memory for and initializes with zeros a device extension of the requested size in which the miniport driver can store driver-determined information about the HBA

·Allocates memory for a PORT_CONFIGURATION_INFORMATION-type buffer

·Fills in as much configuration information about an adapter on a particular I/O bus as it can from the registry

Then, ScsiPortInitialize calls the miniport driver's HwScsiFindAdapter routine, described in Section A.4.3.

If the miniport's DriverEntry routine sets a particular AdapterInterfaceType value in the HW_INITIALIZATION_DATA but there is no bus of that type in the machine, the port driver returns an OS-specific status value indicating that such an HBA does not exist in the current machine. It does not call the driver-supplied HwScsiFindAdapter routine for that bus type.

A miniport driver does not remain loaded if the machine has no I/O buses of the type(s) specified by the miniport's DriverEntry routine.

Note that ScsiPortInitialize also is responsible for the following before it returns control to the miniport's DriverEntry routine:

·Setting up all necessary system objects

·Getting configuration information from and setting configuration information in the registry

·Allocating system resources on behalf of the miniport driver, including memory for the miniport-specified DeviceExtensionSize, SpecificLuExtensionSize, and/or SrbExtensionSize in which the miniport driver can maintain HBA-specific state, per-logical-unit state, and/or per-request state, respectively

Each SCSI miniport driver defines the internal structure and contents of its device extension, logical unit extensions (if any), and SRB extensions (if any). A pointer to the HBA-specific device extension is an input argument to every system-defined miniport driver routine except DriverEntry. Many ScsiPortXxx routines require this pointer as an argument.

ScsiPortInitialize can be called only from a miniport driver's DriverEntry routine. For more information about the HW_INITIALIZATION_DATA structure and ScsiPortInitialize, see the Kernel-Mode Driver Reference.