A DriverEntry routine is the initial entry point for each driver, including each SCSI miniport driver. A miniport's DriverEntry routine is called with two input arguments (of type PVOID) and must do the following:
1 Initialize a HW_INITIALIZATION_DATA structure (on the stack) with zeros.
2 Set driver-specific and HBA-specific values in the HW_INITIALIZATION_DATA fields, including the miniport driver's entry points. The following entry points must be set:
3 Set up any driver-determined context data that the miniport's HwFindAdapter routine uses.
4 Call ScsiPortInitialize with the pointers that were input to the DriverEntry routine, the address of the filled-in HW_INITIALIZATION_DATA, and the address of the context data, if any.
A miniport driver can have a set of bus-type-specific HwFindAdapter routines if its HBA can be connected on various types of I/O bus. Such a miniport driver must modify the AdapterInterfaceType and HwFindAdapter fields in the HW_INITIALIZATION_DATA after each call to ScsiPortInitialize, possibly modify the context data for the new bus type, and call ScsiPortInitialize for each type of bus on which a supported HBA might be connected.
ScsiPortInitialize 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 a PORT_CONFIGURATION_INFORMATION-type buffer, fills in as much configuration information as it can, and calls the miniport driver's HwFindAdapter routine, described in HwFindAdapter Routines.
If the miniport driver 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 STATUS_DEVICE_DOES_NOT_EXIST. It does not call the driver-supplied HwFindAdapter routine for that bus type. The miniport driver does not remain loaded if its HBA can be connected only to one or more types of bus that are not present in the machine.
Note that ScsiPortInitialize is responsible for the following before it returns control to the miniport's DriverEntry routine:
The 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 device extension is an input argument to every system-defined miniport driver routine except DriverEntry. Many ScsiPortXxx routines require this pointer as an argument.
When ScsiPortInitialize returns control, the DriverEntry routine propagates the return value of ScsiPortInitialize when DriverEntry itself returns control. If the miniport driver calls ScsiPortInitialize more than once, its DriverEntry routine should propagate the lowest return value.
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 Introduction to SCSI Port Driver Services Reference.