Share via


Device Manager (Compact 2013)

3/26/2014

Device Manager manages the stream device drivers on the system. The following figure illustrates how Device Manager interacts with stream drivers and other OS components.

Device Manager

During the boot process, the OEM Adaptation Layer (OAL) loads the kernel, and the kernel loads Device Manager. After Device Manager starts, it runs continuously. Device Manager loads and unloads device drivers, tracks loaded device drivers and their interfaces, notifies the kernel when it loads or unloads a stream device driver, and notifies the user when device interfaces become available and unavailable. (For more information about device interfaces, see Support Device Interfaces.) Device Manager also notifies the kernel when it discovers a device interface that supports file operations (such as CreateFile). Device Manager sends power notification callbacks to device drivers as part of platform power management. For more about power management, see Power Management Architecture.

When a user application calls CreateFile to create a handle to a device driver and then calls file I/O functions like ReadFile and WriteFile on this handle, the file system routes these calls to corresponding Device Manager functions like XXX_Read (Device Manager) and XXX_Write (Device Manager). Device Manager, in turn, calls the corresponding entry points in the device driver, such as XXX_Read and XXX_Write. Similarly, the file system routes all IOControl operations on that handle to Device Manager, and Device Manager forwards these calls by calling the XXX_IOControl entry point in the device driver.

Note

Neither the file system nor the user application calls the driver’s XXX_ functions directly. Instead, the file system routes each of these calls through Device Manager, as shown in the previous figure.

You can configure Device Manager to load a driver automatically at boot time by configuring registry settings specific to that device driver, or you can load a driver dynamically by calling Device Manager’s ActivateDeviceEx function from an application. In either case, Device Manager loads the device driver using the same registry flags and settings. If the driver is a user-mode driver, the call to ActivateDeviceEx will result in Device Manager calling the User Mode Driver Reflector.

Device Manager consists of two DLLs that are loaded by the kernel: Device.dll and Devmgr.dll. The kernel loads Device.dll, which is a thin shell that loads Devmgr.dll, and Devmgr.dll implements the core Device Manager functionality. Because Device Manager is implemented as two DLLs, a device driver can link directly with the Device Manager and invoke Device Manager functions without incurring the overhead of a system call.

Registry Settings

If you are loading a device driver automatically, you must configure that device driver’s settings in a subkey under Device Manager’s RootKey, which, by default is set to HKEY_LOCAL_MACHINE\Drivers\BuiltIn. For example, to load MyDriver automatically at boot time, create this subkey:

HKEY_LOCAL_MACHINE\Drivers\BuiltIn\MyDriver

If you are loading a device driver dynamically, you can configure your registry settings in any location you like, for example:

HKEY_LOCAL_MACHINE\MyDriver

The registry path that you select is what you pass to ActivateDeviceEx to load the driver. The following table lists the settings that you configure at this registry location.

Registry setting

Description

Dll

Required. Specifies the driver file name.

Prefix

Optional. Defines the prefix of the stream driver and part of the device name for accessing the driver through the file system. It must match the prefix that is used for implementing driver functions if the DEVFLAGS_NAKEDENTRIES bit of the Flags field is not set (see the Flags field, later in this topic). DEVFLAGS_NAKEDENTRIES means that driver functions were implemented without a prefix (for example, Init, Deinit, Write, and so on).

Order

Optional. Determines the load order of the device driver. Device Manager loads device drivers in the order specified by this parameter. If you do not declare this parameter, the driver will be loaded after all drivers that declare this parameter. You can use this parameter to arrange dependencies between automatically-loaded drivers during system start.

Index

Optional. The index is part of the device name for accessing the driver through the file system. The index is appended to the right of the prefix to create a unique driver name (see Device Driver Access). If you do not specify this parameter, Device Manager will automatically assign sequential index values for each new device instance.

IClass

Optional. Specifies the device class, which is a GUID that refers to a device interface. For more information about IClass registry subkeys, see Device Interface Notifications.

Flags

Optional. Specifies how Device Manager loads the driver. For the flag values that you can set, see ActivateDeviceEx.

Windows Embedded Compact 2013 uses the following procedure to load device drivers that are configured to be loaded automatically:

  1. Device Manager reads the HKEY_LOCAL_MACHINE\Drivers\BuiltIn registry key to determine the list of drivers to load.
  2. Device Manager calls ActivateDeviceEx to load the driver specified in the Dll setting of the registry key HKEY_LOCAL_MACHINE\Drivers\BuiltIn. By default, this driver is the bus enumerator (BusEnum.dll).
  3. The bus enumerator scans HKEY_LOCAL_MACHINE\Drivers\BuiltIn for subkeys that refer to additional buses and devices, examining the Order value in each subkey to determine the load order of each corresponding device driver.
  4. Starting with the lowest Order values, the bus enumerator steps through each subkey and calls ActivateDeviceEx, passing in the registry path for that driver.
  5. Each call to ActivateDeviceEx causes Device Manager to load the device driver file specified by the Dll value in the registry path passed to ActivateDeviceEx.
  6. Device Manager creates an additional subkey under HKEY_LOCAL_MACHINE\Drivers\Active to keep track of the loaded device driver.

Device Manager controls the Active key; only Device Manager can directly access this key for read or write access. The device driver can indirectly access the Active key through the pContext parameter that is passed to the device driver when its XXX_Init entry point is called. For more information about the Active registry key, see Device Manager Registry Keys. For information about Device Manager enumerations, functions, structures, and registry keys, see Device Manager in the Device Drivers Reference.

See Also

Concepts

Device Driver Loading