Windows Drivers Documentation

Microsoft Developer Network (MSDN)

PNP Device Nodes

This document provides an in-depth overview of Plug and Play (PnP) device nodes within the Windows operating system. Understanding device nodes is crucial for developing robust and efficient device drivers.

What is a Device Node?

A device node, often represented internally as a DEVICE_OBJECT or related structures, is a fundamental data structure used by the Windows operating system to represent a hardware device. The Plug and Play manager dynamically manages these nodes throughout the device lifecycle.

Each device node contains information about a particular device, including its characteristics, resources it requires, and its relationship with other devices. The hierarchical structure of device nodes reflects the physical and logical connections between devices.

Key Components of a Device Node

  • Device Description: Information identifying the hardware.
  • Resource Requirements: Details about I/O ports, memory addresses, interrupts, and DMA channels.
  • Driver Association: Links to the driver(s) responsible for managing the device.
  • Device Relationships: Pointers to parent, child, and sibling device nodes, forming a tree structure.
  • Device State: Current status of the device (e.g., present, absent, enabled, disabled).

The PnP Manager and Device Nodes

The Plug and Play manager is the core component responsible for discovering, configuring, and managing devices. It uses device nodes as its primary mechanism for tracking and interacting with hardware.

When a new device is detected or an existing device changes its state, the PnP manager:

  1. Creates or updates a device node.
  2. Queries the device for its hardware IDs and compatible IDs.
  3. Searches for appropriate drivers.
  4. Assigns resources to the device.
  5. Starts the device by loading and attaching the driver.

Device Node Tree Structure

Device nodes are organized into a tree-like structure. The root of this tree is typically the PnP manager itself, with branches extending to represent various controllers and ultimately individual devices.

A typical device node tree might look like:


Root
└── PCI Bus
    ├── Network Adapter
    ├── Graphics Card
    └── USB Controller
        ├── USB Hub
        │   ├── Keyboard
        │   └── Mouse
        └── External Storage Device

                

Driver Interaction with Device Nodes

Device drivers interact extensively with device nodes throughout their operation.

  • Driver Initialization: When a driver is loaded for a device, it receives a pointer to the device's device object, which is closely associated with its device node.
  • Resource Management: Drivers use information from the device node to request and access hardware resources.
  • Device State Changes: Drivers respond to PnP events signaled by the manager, which often involve modifications to the device node's state.
Important: Direct manipulation of device node structures by user-mode applications is not supported and can lead to system instability. Driver development should exclusively use the Kernel-Mode Driver Framework (KMDF) or Windows Driver Model (WDM) APIs provided by the Windows Driver Kit (WDK).

Further Reading

This documentation is a conceptual overview. For specific API details and implementation guidance, please refer to the official Windows Driver Kit (WDK) documentation.