A.4.3.3 Setting up ConfigInfo in HwScsiFindAdapter
A HwScsiFindAdapter routine usually calls ScsiPortGetBusData and examines the returned bus-type-specific configuration information, such as POS data, EISA configuration data or PCI configuration data, for a supported HBA. If the input PORT_CONFIGURATION_INFORMATION AccessRanges elements have been filled in from the registry, the HwScsiFindAdapter routine should map the bus-relative access ranges with ScsiPortGetDeviceBase and use the returned logical range addresses to communicate with the HBA. If access range addresses are supplied by the port driver, HwScsiFindAdapter must not scan for adapters at other locations on that I/O bus.
If the port driver supplies access range values, HwScsiFindAdapter should not use the HwContext parameter. Nonzero access range values are usually accompanied by additional configuration information, which can indicate a plug-and-play environment. In such an environment, HwScsiFindAdapter is being called after the miniport's DriverEntry routine has exited and thus the HwContext pointer is no longer valid. Legacy drivers that receive zero access range values from the port driver and that do their own scanning for supported HBAs can use the HwContext pointer.
If the PORT_CONFIGURATION_INFORMATION buffer input to the HwScsiFindAdapter routine has no configuration information from the registry, HwScsiFindAdapter can use values returned by ScsiPortGetBusData or, if necessary, set driver-defined default values for AccessRanges elements, InterruptLevel or BusInterruptVector, DmaChannel or DmaPort if the HBA uses system DMA, and InitiatorBusId.
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 interrupt configuration value zero indicates that the miniport controls its HBA in a polled mode.
The HwScsiFindAdapter routine must call ScsiPortValidateRange to check whether such driver-supplied access ranges can be used safely before it accesses an adapter on the bus. If ScsiPortValidateRange returns TRUE, the miniport can call ScsiPortGetDeviceBase to map the range and use the returned logical addresses in calls to ScsiPortReadXxx and/or ScsiPortWriteXxx to determine whether it supports an HBA on the I/O bus. If ScsiPortValidateRange returns FALSE, the miniport driver must not attempt to map and use those bus-relative access range values.
When the HwScsiFindAdapter routine finds an HBA it can support, this routine must fill in pertinent members, as appropriate for its HBA and the given AdapterInterfaceType, in the input PORT_CONFIGURATION_INFORMATION buffer. Every miniport driver must fill in the AccessRanges information, converting each AccessRanges element's bus-relative RangeStart value with ScsiPortConvertUlongToPhysicalAddress before setting the bus-relative base address for a range in the ConfigInfo buffer.
For a supported HBA, HwScsiFindAdapter also should save the mapped logical range addresses returned by ScsiPortGetDeviceBase in the miniport's device extension. Every miniport driver must call the ScsiPortReadXxx and ScsiPortWriteXxx with these mapped system addresses to communicate with its HBA(s).
For each successfully validated and mapped range in I/O space, the miniport driver calls the ScsiPortRead/WritePortXxx routines to communicate with its HBA. For each such range in memory space, the miniport driver calls the ScsiPortRead/WriteRegisterXxx.
For an "AT-compatible" HBA, the HwScsiFindAdapter routine should check the input Atdisk..Claimed members and attempt to claim an "AT" range by resetting the value to TRUE.