Once the driver's INF file is created, it must be processed for it to take effect. Obviously, the strict adherence to INF syntax suggests that an engine exists for just such a purpose. This section describes the mechanics of running the engine, either automatically or manually. Manual InstallationTo process an INF file manually, simply use the Windows Explorer file manager to select the INF file. Right-clicking the file offers the option to Install (process) the file. In a true Plug and Play environment, the insertion or removal of a device triggers the installation, load, and unload of an appropriate driver. Therefore, the use of manual installation is reserved for initial testing and debugging of a driver. Automatic InstallationWhen a PnP device is inserted into a system, several subsystems interact to force the loading of a new driver, if necessary. The steps are outlined below.
The Add/Remove Hardware WizardAs just explained, the user must sometimes interact with even an automated installation. The prime interface for this interaction is the New Hardware wizard. A typical screen shot from this (all too) familiar tool is shown in Figure 16.3. Notice that there is a column for Manufacturers (listed from INF files [Manufacturers] section), and for Models (listed from INF files [Models] sections). Figure 16.3. New Hardware wizard.In general, the user manually selects the appropriate driver to install and load. If the driver survives installation, its DriverEntry and AddDevice routines must still validate that the hardware they are being asked to drive satisfies their set of code assumptions. In other words, a manual selection process can succeed the installation, but still fail initialization. Class Names and Device IDsThe automated process of installation of a Plug and Play device depends largely on the ability of the Setup program to locate an appropriate INF file and section for the driver. The purpose of this section is to explain the source for Device IDs and Class Names, as well as explain the matching process that is used to locate an INF file section. Every Plug and Play device should have an identifier that uniquely specifies the model of hardware. This Device ID must be provided to the Plug and Play bus hardware and, therefore, to a bus driver upon request. Of course, the bus driver requests the Device ID shortly after a new device is inserted. The form of a Device ID varies somewhat with the hardware bus type, but generally appears as <enumerator>\<enumerator-specific-device-ID>, (for example, PCI\VEN_1000&DEV_0001&SUBSYS_00000000&REV_02) to driver code. A given hardware device can report more than one Device ID, which is a statement that the device is functionally compatible with numerous models. Since the [Models] section of an INF file includes an hw-id value, it is a simple matter to look for a direct match between an entry in the INF file with the Device ID returned by a newly installed device. The same INF entry allows for the specification of a list of (hopefully) compatible hardware, in the form of additional Device IDs. If an exact match cannot be located with the INF file for the Device ID, a compatible match is used as recourse. Another key element used in locating appropriate drivers for a device is the notion of a Setup Class. A group of related devices can share layers of drivers (e.g., upper or lower filters) even though individual drivers within the stack vary. Setup Classes are uniquely identified by GUID and name. Microsoft defines a series of driver classes, listed in Table 16.9. New classes can be defined for new hardware groupings, with the same benefits bestowed to drivers that participate in the group membership. To create a new group, a new GUID and class name must be chosen.
Customizing an InstallationThere are generally two things that a driver author can provide to customize the installation of a driver. First, a custom installation program can be provided that essentially replaces the work of the New Hardware wizard. To provide this functionality, the custom program must utilize the library routines provided by SETUPAPI.DLL. Each of the functions within this library begins with the name SetupDiXxx. The DDK provides the laborious details of the use of this DLL. Second, a driver can provide a custom wizard page to allow the specification of custom device settings. Just prior to the completion of its work, the setup process sends a DIF_NEWDEVICEWIZARD_FINISHINSTALL request that offers the opportunity for a driver to display the custom page. Again, the DDK provides the details for this process.
|