How the system Finds and Loads Drivers

From ReactOS Wiki
Jump to: navigation, search


Device types

PnP device

It has an electronic signature that bus driver can detect the new hardware

Legacy device

Initiate the detection by invoking Add New Hardware Wizard.

In the end, in both PnP and Legacy Device situation, system uses the same automatic registry and INF file process to load the right driver.

Driver types

Function driver

It understands the details about how to make the HW work.

It's responsible for initiating IO operations, for handling interrupts, and for providing a way for end user to exercise control over the device.

Bus driver

It's responsible for managing the connection between the Hardware and the computer.

Filter Driver

is to Modify the behavior of an existing function driver in some way. Upper filter driver sees IRPs before function driver. Lower filter can modify the stream of bus operations that the function driver is trying to perform.

PDO stands for Physical Device Object. The bus driver uses it to represent the connection between the device and the bus.

FDO stands for Function Device Object. The function driver uses it to manage the functionality of the device.

Installing a PnP Device

  1. Bus driver detects the insertion or removal of hardware.
  2. Bus driver calls IoInvalidateDeviceRelations to notify PnP manager that the bus's population of child devices has changed.
  3. PnP manager sends IRP_MN_QUERY_DEVICE_RELATIONS to bus driver, to obtain an updated list of the PDOs for the child devices.
  4. PnP manager sends IRP_MN_QUERY_ID to bus driver, to obtain Device ID
  5. PnP manager locates INF install section and initialize driver. Memory Manager then calls DriverEntry routine.
  6. PnP manager calls AddDevice, to inform driver that a new instance of the device has been discovered
  7. PnP manager sends IRP_MN_QUERY_RESOURCE_REQUIREMENTS to bus driver, to ask bus driver report resource requirements.
  8. PnP manager configuire the hardware with as set of resource arbitrators to assign resources to the device.
  9. PnP manager sends IRP_MN_START_DEVICE to your driver (the driver stack). Function driver handles the IRP by configuring and connecting various kernel resources.

Order of AddDevice Calls (Driver Loading)

5. Class upper filters
4. Device upper filters
3. Function driver
2. Class lower filters
1. Device lower filters

IRP Routing

System sends an IRP to the topmost filter dirver in the stack, that driver can decide to process the IRP, to pass the IRP down to the next level, or to do both. Each driver that sees the IRP makes the same decision.

See also