Handling PnP Initialization in a Storage Class Driver

Initialization of a storage class driver is much the same as initialization of any PnP driver.

Storage class driver initialization begins when the PnP manager calls the driver's DriverEntry routine to load and initialize the driver. Then the PnP manager calls the storage class driver's AddDevice routine, passing a pointer to a physical device object (PDO) that represents the target device.

In its AddDevice routine, the class driver calls IoGetAttachedDeviceReference and issues an SRB_FUNCTION_CLAIM_DEVICE command (see SCSI_REQUEST_BLOCK) to the device object returned, to prevent legacy class drivers from claiming the device. The class driver must send no other commands to the device during this phase of initialization.

If the class driver successfully claims the device, it creates a functional device object (FDO) and attaches it to the device stack by calling IoAttachDeviceToDeviceStack with the input PDO. When AddDevice returns, the driver must be ready to handle a PnP start request (IRP_MJ_PNP with an IRP_MN_START_DEVICE). After the PnP manager has finished constructing the driver stack (which might include one or more filter drivers layered above and below the class driver) it issues a start request to the topmost driver in the driver stack for the target device.

If the class driver cannot successfully claim the device, it must not attempt to attach an FDO to the device stack, and should simply return a success status from its AddDevice routine. Such a driver will not receive a PnP start request for the device, although the PnP manager might call its AddDevice routine again for the same or a different device.

For more information about initializing storage class drivers, see the following:

Storage Class Driver's DriverEntry Routine

Storage Class Driver's AddDevice Routine

Also see Plug and Play.



Send comments about this topic to Microsoft

© 2014 Microsoft