Technical Summary of USB driver development (2)

Source: Internet
Author: User

2. Development of USB interface drivers

1. Hierarchy of devices and drivers


The WDM model uses a layered structure. The right side of the figure is a device object stack. A device object is a data structure created by the system to help software manage hardware. A physical hardware can have multiple such data structures.

Fdo and PdO are introduced in WDM to describe hardware. A pdo corresponds to a real hardware. A hardware can have only one PDO, but can have multiple fdo. In the driver, the corresponding PDO and fdo are not the hardware devices. Both PDO and fdo are at the lowest layer of the stack. There are some filter device objects in the above and below of fdo ). The filter device object on the fdo is called the upper-layer filter, and the filter device object on the fdo (but still on the PDO) is called the lower-layer filter. In terms of user-state and kernel-State communication, the system packs an IRP structure for each user request and sends it to the driver, identify the PDO in the IRP to identify the device to which the message is sent.

2. Basic Steps for writing a driver

(1) first write a DriverEntry routine. In this routine, you must set a series of callback routines to process IRP. DriverEntry is a common name for the main entry point of the kernel-mode driver. The main task of this routine is to fill in various function pointers with driver objects. These pointers indicate the locations of various subroutines in the driver container for the operating system.

(2) write an adddevice routine. Its basic function is to create a device object and connect it to the device stack whose bottom is PDO. The related steps are as follows: Call iocreatedevice to create a device object and create a private device extension object. Store one or more device interfaces so that the application can know the existence of the device. In addition, you can also give a device name and create a symbolic connection. initialize the flag Member of the device extension and the device object. Call ioattachdevicetodevicestack to put the new device object on the stack.

(3) Compile the connection driver.

(4) Test the driver.

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.