Basic concepts of [Windows drivers]

Source: Internet
Author: User

https://msdn.microsoft.com/zh-cn/library/windows/hardware/ff554721 1, device node and device stack

In Windows, devices are presented in a device node in the tree by using Plug and Play. Typically, when a device receives an I/O request, several drivers help handle the request, which is related to a device object, which is arranged in an orderly manner on the stack. A sequence of device objects and their respective drivers are called device stacks. Each device node has a stack of their own devices.

1.2. Device objects and device stacks

A device object is an instance of a device_object. Each device node in the PNP tree has an ordered list of device objects, and each device object has a related driver. The list of ordered device objects and the related drivers of the device objects make up the device stack of the device node.

We can look at this device stack concept from multiple angles. The most common view is that a device stack is an ordered list of device objects and drives, but in some contexts we think the device stack is a list of ordered device objects, and in other contexts we think the device stack is an ordered list of device drivers.

A Device Object is an instance of a device_object structure. Each device node in the PnP device tree has a ordered list of device objects, and each of the these device objects are Associa Ted with a driver. The ordered list of device objects, along with their associated drivers, was called the device stack for the Devic E node.

You can think the a device stack in several ways. The most formal sense, a device stack is a ordered list of (device object, driver) pairs. However, in certain contexts it might is useful to think of the device stack as an ordered list of device objects. In other contexts, it might is useful to think of the device stack as an ordered list of drivers.

By convention, the a device stack has a top and a bottom. The first device object to being created in the device stack are at the bottom, and the last device object to be created and a Ttached to the device stack are at the top.

In the following diagram, the Proseware Gizmo device node have a device stack that contains three (device object, driver) p Airs. The top device object is associated with the driver Afterthought.sys, the middle device object was associated with the Driv Er Proseware.sys, and the bottom device object is associated with the driver Pci.sys. The PCI Bus node in the center of the diagram have a device stack that contains a (device object, driver) pairs--a device Object associated with Pci.sys and a device object associated with Acpi.sys.

1.3. How to build the device stack:

During the boot process, the PnP manager requests that the driver for each bus enumerate the sub-devices connected to the bus. For example, the PnP manager requests the PCI bus driver (Pci.sys) to enumerate the devices that are connected to the PCI bus. In response to this request, Pci.sys creates a device object for each device connected to the PCI bus. Each of these device objects is called a physical device object (PDO). Shortly after Pci.sys created the group PDO, the device tree resembles a device tree in.

The PnP Manager associates the device node with each newly created PDO and queries the registry to determine which drivers need to be part of the device stack for that node. The device stack must have one (and only one) function driver, and you can choose to have one or more filter drivers. The function driver is the primary driver for the device stack and is responsible for processing read, write, and device control requests. The filter driver plays a secondary role in processing read, write, and device control requests. When each function driver and filter driver is loaded, it creates a device object and attaches itself to the device stack. A device object created by a function driver is called a function device object (FDO), and a device object created by a filter driver is called a Filter device object (filter do). The device tree is now similar to this diagram.

In this diagram, note that in one node, the filter driver is on top of the function driver, and in another node, the filter driver is under the function driver. The filter driver on the device stack that is above the function driver is called the top filter driver. The filter driver under the function driver is called the down filter driver.

PDO is always the bottom device object in the device stack. This is because of how the device stack is constructed. PDO is created first, and when other device objects are attached to the stack, the objects are appended to the top of the existing stack.

[Note]: After installing the device driver, Setup uses the information in the information (INF) file to determine which driver is the function driver and which drivers are filters. Typically, INF files are provided by Microsoft or hardware vendors. After the device driver is installed, the PnP Manager can determine the device's function driver and filter driver by locating the registry.

1.4. Bus driver

In, you can see that the driver Pci.sys plays two roles. First, the Pci.sys is associated with the FDO in the PCI Bus device node. In fact, Pci.sys has created FDO in the PCI Bus device node. Therefore, the Pci.sys is a function driver for the PCI bus. Second, the Pci.sys is associated with the PDO in each child node of the PCI bus node. Remember that Pci.sys has created PDO for the child device. The driver that creates PDO for a device node is called the bus driver for that node.

If your reference point is a PCI bus, then Pci.sys is the function driver. But if your reference point is a Proseware Gizmo device, then Pci.sys is the bus driver. This dual role is typical in the PnP device tree. The driver for the function driver for the bus is also the bus driver for the bus sub-device.

[Windows drivers] Basic concepts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.