ULONG
HwScsiFindAdapter(
IN PVOID DeviceExtension,
IN PVOID HwContext,
IN PVOID BusInformation,
IN PCHAR ArgumentString,
IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo,
OUT PBOOLEAN Again
);
HwScsiFindAdapter uses supplied configuration information to determine whether it supports a particular HBA and, if so, returns information about its HBA in the given ConfigInfo buffer.
Miniports that scan for supported adapters can define the context in their DriverEntry routine and pass its address to ScsiPortInitialize. ScsiPortInitialize passes the context pointer to HwScsiFindAdapter. Such a miniport driver can use HwContext to store state between calls to HwScsiFindAdapter.
Miniports that use configuration information from the port driver rather than
scanning the I/O bus should not use this pointer. If HwScsiFindAdapter
receives nonzero access range values from the port driver it should not use
the HwContext pointer.
HwScsiFindAdapter must return one of the following status values:
Value |
Meaning |
SP_RETURN_FOUND |
Indicates a supported HBA was found and that the HBA-relevant configuration information was successfully determined and set in the PORT_CONFIGURATION_INFORMATION structure. |
SP_RETURN_ERROR |
Indicates an HBA was found but there was error obtaining the configuration information. If possible, such an error should be logged with ScsiPortLogError. |
SP_RETURN_BAD_CONFIG |
Indicates the supplied configuration information was invalid for the adapter. |
SP_RETURN_NOT_FOUND |
Indicates no supported HBA was found for the supplied configuration information. |
ScsiPortInitialize calls the HwScsiFindAdapter routine after allocating storage according to the DeviceExtensionSize that the miniport specified in the HW_INITIALIZATION_DATA structure.
First, every HwScsiFindAdapter routine should check the value of Length in the input PORT_CONFIGURATION_INFORMATION to determine whether the port driver has allocated a structure with all the configuration information the miniport needs to find and configure its HBA(s).
Next, every HwScsiFindAdapter routine should check the AccessRanges in the PORT_CONFIGURATION_INFORMATION to determine whether the OS-specific port driver collected and set bus-relative range-configuration information for an HBA. If HwScsiFindAdapter finds nonzero access-range values, it must map the supplied values with ScsiPortGetDeviceBase and use the returned logical range addresses to access the HBA.
If the input PORT_CONFIGURATION_INFORMATION contains AccessRanges elements filled with default zeros, the HwScsiFindAdapter routine can use any appropriate search logic, such as calling ScsiPortGetBusData, or use a set of driver-supplied bus-relative default values, to fill in each such access range element and determine its validity.
HwScsiFindAdapter should call ScsiPortValidateRange before it maps any miniport-supplied access range values with ScsiPortGetDeviceBase and uses the mapped logical addresses to access an adapter. ScsiPortValidateRange verifies that the device range has not already been claimed in the registry by another driver. If ScsiPortValidateRange returns FALSE, HwScsiFindAdapter cannot map and use that range and must not attempt to do so.
HwScsiFindAdapter must check the value of NumberOfPhysicalBreaks in the input PORT_CONFIGURATION_INFORMATION. The port driver usually sets this member to a particular value. The miniport driver can set NumberOfPhysicalBreaks to a lower value if its HBA supports fewer breaks between scatter/gather lists, but the miniport must not set it to a higher value than that supplied by the port driver. If NumberOfPhysicalBreaks is set to SP_UNINITIALIZED_VALUE, the miniport must fill in the actual number of breaks between scatter/gather lists that its underlying adapter can support.
HwScsiFindAdapter should also check the input port configuration information for additional port-driver-supplied values, such as interrupt vector or level, and DMA channel or port. Usually, the OS-specific port driver supplies additional configuration information if it supplies nonzero, bus-relative values for AccessRanges elements.
A miniport driver must use any valid configuration information it finds in the input port configuration information to configure the HBA.
The port driver is responsible for doing bus-level configuration programming, particularly of dynamically configurable I/O buses with published standard interfaces, such as PCI and PCMCIA. For an HBA on such an I/O bus, the miniport driver can simply accept the interrupt configuration information provided as values reserved for system use. For an HBA on other types of I/O buses, a miniport should program its HBA to use any supplied interrupt value if its HBA supports programmable interrupt configuration. If no interrupt configuration is supplied, as indicated either by the value zero or the value SP_UNINITIALIZED_VALUE, the miniport should either query its HBA if the HBA supports interrupt selection using jumpers or should supply a nonzero default interrupt configuration unless the HBA does not use interrupts. The miniport should set the interrupt configuration value to zero if it controls its HBA in a polled mode.
A miniport’s HwScsiFindAdapter routine should return with the Again parameter set to TRUE so the OS-specific SCSI port driver will search for additional HBAs on the I/O bus.
ACCESS_RANGE, DriverEntry, HW_INITIALIZATION_DATA, PORT_CONFIGURATION_INFORMATION, ScsiPortGetBusData, ScsiPortGetDeviceBase, ScsiPortInitialize, ScsiPortLogError, ScsiPortValidateRange