Necessary Changes to DriverEntry for PCI SCSI Miniport Driver

Last reviewed: September 28, 1995
Article ID: Q137383
The information in this article applies to:
  • Microsoft Win32 Device Driver Kit (DDK) version 3.5

SUMMARY

Minimal changes are necessary to modify a SCSI miniport's DriverEntry routine to support a PCI adapter because the SCSIPORT driver is responsible for locating and configuring the PCI device specified. This article describes the changes that do need to be made.

MORE INFORMATION

For each PCI device that matches the specified Vendor and Device ID, the SCSIPORT driver calls the miniport's HwScsiFindAdapter routine. If there are four devices that match the Vendor and Device ID, the HwScsiFindAdapter routine is called four times.

The following sample SCSI miniport DriverEntry routine shows how to set up and call ScsiPortInitialize assuming the Vendor ID is 0x1999 and the Device ID is 0x0000. Note that this driver expect two access ranges - one for a memory range and one for an I/O range. When the HwScsiFindAdapter is called, these access ranges are already filled in and should be mapped by calling ScsiPortGetDeviceBase. Usually, no other PCI-specific configuration needs to be done.

DriverEntry Code Sample

ULONG DriverEntry(

        IN PVOID DriverObject,
        IN PVOID Argument2
        )
/*++

Routine Description:
    Installable driver initialization entry point for system.

Arguments:
    Driver Object

Return Value:
    Status from ScsiPortInitialize()

--*/ {
    HW_INITIALIZATION_DATA hwInitData;

    UCHAR vendorId[4] = {'1', '9', '9', '9'};
    UCHAR deviceId[4] = {'0', '0', '0', '0'};

    //
    // Initialize the hardware initialization data structure.
    //

    for ( i = 0; i < sizeof( HW_INITIALIZATION_DATA); i++) {
        ((PUCHAR)&hwInitData)[i] = 0;
    }

    //
    // Set size of hardware initialization structure.
    //

    hwInitData.HwInitializationDataSize = sizeof(HW_INITIALIZATION_DATA);

    //
    // Identify required miniport entry point routines.
    //

    hwInitData.HwInitialize = XyzInitialize;
    hwInitData.HwStartIo = XyzStartIo;
    hwInitData.HwInterrupt = XyzISR;
    hwInitData.HwFindAdapter = XyzFindAdapter;
    hwInitData.HwResetBus = XyzReset;
    hwInitData.HwAdapterState = XyzAdapterState;

    //
    // Specify adapter specific information.
    //

    hwInitData.NeedPhysicalAddresses = TRUE;

    //
    // Indicate how many I/O or memory ranges will be used.
    //

    hwInitData.NumberOfAccessRanges = 2;

    //
    // Set up PCI-specific information.
    //

    hwInitData.AdapterInterfaceType = PCIBus;
    hwInitData.VendorId = &vendorId;
    hwInitData.VendorIdLength = 4;
    hwInitData.DeviceId = &deviceId;
    hwInitData.DeviceIdLength = 4;

    //
    // Set required extension sizes.
    //

    hwInitData.DeviceExtensionSize = sizeof(HW_DEVICE_EXTENSION);
    hwInitData.SrbExtensionSize = sizeof(SRB_EXTENSION);
    hwInitData.SpecificLuExtensionSize =
      sizeof(SPECIFIC_LOGICAL_UNIT_EXTENSION);

    return ( ScsiPortInitialize(DriverObject,
                                Argument2,
                                &hwInitializationData,
                                NULL
                                ) );

} // end DriverEntry()

NOTE: Occasionally, a SCSI miniport will need to read or write the PCI configuration space. The miniport can use the ScsiPortGetBusData and ScsiPortSetBusDataByOffset functions to accomplish this task. Please see the DDK documentation for details on these calls.


Additional reference words: 3.50
KBCategory: kbprg kbcode
KBSubcategory: ntddkstorage


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 28, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.