State Transitions for PnP Devices

On a PnP system, a device transitions through various PnP states as it is configured, started, possibly stopped to rebalance resources, and possibly removed. This section provides an overview of the PnP device states. The overview is a road map for much of the PnP support required in a driver. Other parts of this documentation describe each state transition in detail.

The following figure shows the PnP states for a device and how a device transitions from one state to another.

Diagram illustrating device states from the Plug and Play perspective

Starting at the top left of the previous figure, a PnP device is physically present in the system because either the user just inserted the device or the device was present at boot time. The device is not yet known to the system software.

To begin software configuration for the device, the PnP manager and the parent bus driver enumerate the device. The PnP manager, possibly with help from user-mode components, identifies the drivers for the device, including the function driver and any optional filter drivers. The PnP manager calls the DriverEntry routine of each driver if the driver is not yet loaded. For more information about reporting and enumerating a PnP device, see Adding a PnP Device to a Running System.

Once a driver is initialized, it must be ready to initialize its devices. The PnP manager calls a driver's AddDevice routine for each device the driver controls.

When a driver receives an IRP_MN_START_DEVICE request from the PnP manager, the driver starts the device and is ready to process I/O requests for the device. For information about handling an IRP_MN_START_DEVICE request, see Starting a Device.

If the PnP manager must reconfigure the hardware resources of an active device, it sends IRP_MN_QUERY_STOP_DEVICE and IRP_MN_STOP_DEVICE requests to the device's drivers. After it reconfigures the hardware resources, the PnP manager directs the drivers to restart the device by sending an IRP_MN_START_DEVICE request. For information about handling stop IRPs, see Stopping a Device. (The drivers for a boot-configured device can receive IRP_MN_QUERY_STOP_DEVICE and IRP_MN_STOP_DEVICE requests before the device has been started, although this step is not shown in the previous figure.)

On Windows 98/Me, the PnP manager also sends IRP_MN_QUERY_STOP_DEVICE and IRP_MN_STOP_DEVICE requests when a device is being disabled. Drivers on these systems also receive an IRP_MN_STOP_DEVICE request after a failed start.

When a PnP device is being physically removed from the system or has already been removed, the PnP manager sends various remove IRPs to the device's drivers, directing them to remove the device's software representation (device objects, and so forth). For information about handling remove IRPs, see Removing a Device.

At some point after all of a driver's devices have been removed, the PnP manager calls the driver's Unload routine and unloads the driver.



Send comments about this topic to Microsoft

© 2015 Microsoft