Loading Installable Device Drivers

This section explains the process by which the Device Manager loads an installable device driver. There are three ways in which an installable device driver can be loaded.

The first method is by the Device Manager at boot time. When the Windows CE platform boots, it starts the Device Manager. In turn, the Device Manager looks in the [HKEY_LOCAL_MACHINE\Drivers\Builtin] registry key and loads any installable device drivers listed there. For example, on many Windows CE platforms the driver for the built-in serial ports (Serial.DLL) is loaded in this way.

The second method is for any peripheral devices that Device Manager can automatically detect when the peripheral is connected to the Windows CE platform. Such devices are typically PC Cards, but in the future this category may be expanded to include other types of peripheral devices. When a PC Card is inserted into a PC Card socket, the PC Card socket driver (a builtin driver) is called to handle the event. It reads the Plug-and-Play ID from the PC Card, and checks the [HKEY_LOCAL_MACHINE\Drivers\PCMCIA] key for a subkey that matches the Plug-and-Play ID. If one exists, it loads the driver listed within that key. If there is no match, the Device Manager then calls all the detection functions listed within the [HKEY_LOCAL_MACHINE\Drivers\PCMCIA\Detect] key. If one of the detection functions returns a value indicating that it can handle the PC Card, then that installable device driver is loaded.

In both the first and second methods, the Device Manager calls RegisterDevice on behalf of the installable device driver, and creates a numbered subkey within the [HKEY_LOCAL_MACHINE\Drivers\Active] key to track the driver. RegisterDevice takes a further step, which is to lock the installable device driver into working RAM. This prevents the driver from getting swapped out, and thus prevents any paging activity which would slow down the driver's operation when servicing interrupt events.

The third method is for any peripheral devices that the Device Manager cannot automatically detect when the peripheral is connected to the Windows CE platform. Such devices are typically serial devices, because there is no automatic way for Windows CE to detect that a serial device has been connected to a serial port. However, it is not unusual for Windows CE platforms to have other types of connectors which are equally unable to signal Windows CE when a peripheral is connected to them. For these peripherals, the device driver is typically loaded by the application that needs to use the peripheral. The typical sequence of actions is:

  1. The user starts the application in question.
  2. The application determines that the device driver is not loaded, either by inspecting the filesystem or by receiving a failure return code from OpenFile when trying to open the expected device filename.
  3. The application calls RegisterDevice to load the installable device driver and lock it into memory.
  4. The application continues with its normal operation.