Windows 2000 Device Driver Installation

Updated: December 4, 2001
*

Introduction

On a system running the Microsoft Windows 2000 (or later) operating system, Setup works with other system-supplied components and with vendor-supplied components to install devices. Setup installs devices when the machine boots and at any time after boot when a user adds a Plug and Play device (or manually installs a non-Plug and Play device).

In support of Plug and Play, Setup proceeds with installation based on the devices in the machine, rather than structuring installation around the drivers. For example, rather than loading a set of drivers and having those drivers detect the devices that they support, Setup determines the devices that are present in the machine and loads and calls the drivers for each device. Drivers such as the ACPI driver and other Plug and Play bus drivers assist Setup in determining the devices present on the machine.

This article contains the following information from the Windows Driver Development Kit (DDK):

Device Installation Components

System Setup Phases

For complete information about device installation, see the Windows DDK documentation.

Top of pageTop of page

Device Installation Components

Figure 1 shows the software components involved in installing a device on a Windows machine.

Figure 1 Device Installation Setup Components

DeviceInstall.gif
Click to view full-size image.

The shaded boxes in Figure 1 represent components that can be provided by IHVs and OEMs. The other device installation components are supplied by Microsoft.

The following list describes the roles that the various components play in device installation.

Kernel-Mode Plug and Play Manager
The kernel-mode Plug and Play (PnP) Manager notifies the user-mode Plug and Play Manager that a new device is present on the machine and needs to be installed. The kernel-mode Plug and Play Manager also calls the DriverEntry and AddDevice routines of a device's drivers and sends the IRP_MN_START_DEVICE request to start the device.

The Plug and Play Manager has two parts: one part runs in user-mode and one part runs in kernel mode. The kernel-mode Plug and Play Manager reports Plug and Play events to the user-mode Plug and Play Manager and the user-mode Plug and Play Manager sends control requests to the kernel-mode Plug and Play Manager.

Drivers
Plug and Play drivers perform device-installation operations as directed by the Plug and Play Manager. For example, a Plug and Play bus driver returns a list of its child devices when the Plug and Play Manager sends the driver an IRP_MN_QUERY_DEVICE_RELATIONS request for BusRelations. Plug and Play drivers execute their DriverEntry and AddDevice routines when called by the Plug and Play Manager. Plug and Play drivers also handle other requests that are sent by the Plug and Play Manager, such as IRP_MN_QUERY_CAPABILITIES, IRP_MN_START_DEVICE, and IRP_MN_REMOVE_DEVICE.

Plug and Play drivers can also detect non-Plug and Play devices and report them to the Plug and Play Manager using IoReportDetectedDevice.

User-Mode Plug and Play Manager
The user-mode Plug and Play Manager receives device installation requests from the kernel-mode Plug and Play Manager, calls other user-mode Setup components to initiate device-installation tasks, and sends control requests to the kernel-mode Plug and Play Manager (such as "start the device").

The user-mode Plug and Play Manager and the kernel-mode Plug and Play Manager together maintain the device tree.

The user-mode Plug and Play Manager tries to install a device in a trusted process context without requiring user responses to dialog boxes (a "server-side" installation). Such an automatic installation provides a better user experience. If the Plug and Play Manager is unable to complete a trusted installation, because, for example, an installer supplies custom Finish page(s), the Plug and Play Manager aborts the trusted installation. In this case, the Plug and Play Manager restarts the device installation when a user with administrative privileges logs in (a "client-side" installation) by launching the Found New Hardware wizard in the New Device DLL.

Setup API
The Setup API includes the SetupXxx functions and the SetupDiXxx functions. These functions perform many device installation tasks such as searching for INF files, building a potential list of drivers for a device, copying driver files, writing information to the registry, registering device coinstallers, and so forth. Most of the Setup components call these functions to get work done.

The SetupDiXxx functions are also sometimes referred to as the Device Installer. That term can be confusing, however, because more than one component is involved in installing a device.

For more information, see the Windows DDK.

CfgMgr API The Configuration Manager API provides basic installation and configuration operations that are not provided by Setup API. The Configuration Manager Functions perform low-level tasks such as getting the status of a devnode and managing resource descriptors. These functions are primarily called by Setup API, but can also be called by other Setup components.

Coinstallers and Class Installers
A class installer performs installation operations that apply to devices in a particular device setup class. For example, the ports class installer is responsible for assigning a COM port name to a device in the ports setup class. If the devices in a particular setup class do not require any special installation operations, a class installer is not required for that setup class.

Microsoft provides class installers for most of the system-defined device setup classes. For more information, see Writing a Class Installer in the Windows 2000 DDK. IHVs and OEMs can provide class installers, but typically they provide coinstallers.

A coinstaller performs installation operations that are specific to a particular device or to a setup class of devices. For more information, see Writing a Coinstaller in the Windows 2000 DDK.

INF files and catalog files
INF files and catalog files provide information about devices and drivers to be installed. For more information, see Creating an INF File in the Windows 2000 DDK.

Device Manager
The Device Manager allows a user to view and manage the devices on a machine. For example, a user can view device status and set device properties. If a user requests to update a driver, the Device Manager calls the Update Driver wizard in the New Device DLL.

For more information, see the online help in the Device Manager.

Add/Remove Hardware Wizard
The Add/Remove Hardware Wizard allows a user to add, remove, unplug, and troubleshoot devices. The Unplug or Eject Hardware applet in the systray is a shortcut to the unplug task in this wizard.

New Device DLL
The New Device DLL contains the Found New Hardware wizard, the Update Driver wizard, and the UpdateDriverForPlugAndPlayDevices function.

The user-mode Plug and Play Manager calls the Found New Hardware wizard to initiate a client-side installation of a new device in the context of a user with the appropriate privileges. The Device Manager calls the Update Driver wizard when a user selects the "Update Driver..." button on a device's Driver property page. The Found New Hardware and Update Driver wizards call Setup APIs and Configuration Manager APIs to accomplish their tasks.

Custom Setup Application
An IHV or OEM can provide a custom setup application. For more information, see Writing a Custom Device Installation Application in the Windows 2000 DDK.

Top of pageTop of page

System Setup Phases

For most devices, you should design your device and supporting files so that Setup can install the device at an appropriate time during system startup or dynamically at any time after startup while the machine is running. Certain devices, however, must be installed during a particular phase of system boot. To assist vendors of such devices, this section provides some background information on the system setup phases as they relate to device installation.

When Windows 2000 boots on a machine, the initial phase of the Windows 2000 Setup program installs only the minimum number of devices needed for Windows 2000 to run, such as the keyboard, mouse, video adapter, SCSI/Disk, and Machine/HAL. This phase of the Setup program is known as text-mode setup. For a user to install your device during text-mode setup, your distribution disk must include a text file named Txtsetup.oem. For information, see Installing a Device Required to Boot the Machine in the Windows 2000 DDK.

After text-mode setup has completed, the Setup program boots Windows 2000 and proceeds with the GUI-mode phase of the Windows 2000 installation. Setup installs most devices during GUI-mode setup.

Devices that are not installed during GUI-mode setup include devices that require user interaction to be installed. For example, if this is the first time a device is being configured on the machine and a coinstaller for the device supplies custom Finish page(s), Setup must display those pages to the user. Setup performs such a device installation when a user with administrative privileges logs in.

Once a machine is up and running, a user can install new devices:

To install a new Plug and Play device, plug the device into the machine.

If the device and the bus support hot-plug notification, device installation is initiated automatically.

If the user needs to power down the machine and open the system box to plug in the device, the device will be recognized and configured when the system boots.

If the device can be plugged in while the system is running and the device and the bus do not support hot-plug notification, use the Add/Remove Hardware wizard to initiate device configuration (select "Install").

To install a non-Plug and Play device, use the Add/Remove Hardware wizard.

If Setup can install the device in the trusted context of a system process, the user does not need administrative privileges to install the device. If Setup needs to prompt the user for information, Setup requires the process context of an administrative user to install the device.

To update a driver for an installed device, use the Device Manager or the Hardware tab of the appropriate control panel applet. (Clicking the Properties button in the Hardware tab of a control panel applet brings up the Device Manager properties for the device.)


Top of pageTop of page