Using a Driver INF File

< BACK  NEXT >
[oR]

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 Installation

To 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 Installation

When 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.

  1. When the device is inserted, the hardware, using auto-detection and notification, alerts the bus driver that the device is present. Depending on the bus hardware, this might involve notifying the bus driver that a change has occurred that warrants a new enumeration of bus devices. Regardless, at the end of this step, the bus driver is aware that the new device is present and that it has a specific device ID.

  2. The kernel-mode PnP Manager notifies the user-mode PnP Manager that a new device with a specific ID is present in the system.

  3. The user-mode PnP Manager, using the Setup API library of Windows 2000, constructs a likely list of drivers for the new device. The INF directory of the system (e.g., WINNT\INF) is searched using the class and model information from the new device for a suitable match.

  4. If a suitable INF file cannot be located, the system delays further action until a privileged user logs on. Then the user is presented with a dialog-driven New Hardware wizard. The user supplies the location of the drivers (CD, diskette, Web location, etc.) and the appropriate INF file is located.

  5. Once the INF file is found, it is processed using the CfgMgr API library. The driver files and Registry entries are installed and modified. This step is primarily carried out by the kernel-mode PnP Manager.

  6. Based on the directives of the INF file, the kernel-mode PnP Manager loads any lower filter drivers, then the functional driver, and finally any upper filter drivers for the device. The top driver in the stack is then sent appropriate PnP messages, including IRP_MN_START_DEVICE.

The Add/Remove Hardware Wizard

As 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.
graphics/16fig03.gif

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 IDs

The 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.

Table 16.9. Setup Classes: Names and GUIDs
Setup Classes
Class Name Description GUID
1394 1394 Host Bus Controller {6bdd1fc1-810f-11d0-bec7-08002be2092f}
Battery Battery Devices {72631e54-78a4-11d0-bcf7-00aa00b7b32a}
CDROM CD-ROM Drives {4d36e965-e325-11ce-bfc1-08002be10318}
DiskDrive Disk Drives 4d36e967-e325-11ce-bfc1-08002be10318}
Display Display Adapters {4d36e968-e325-11ce-bfc1-08002be10318}
FloppyDisk Floppy Disk Controllers {4d36e980-e325-11ce-bfc1-08002be10318}
HDC Hard Disk Controllers {4d36e96a-e325-11ce-bfc1-08002be10318}
HIDClass Human Input Devices {745a17a0-74d3-11d0-b6fe-00a0c90f57da}
Image Imaging Devices {6bdd1fc6-810f-11d0-bec7-08002be2092f}
Infrared IrDA Devices {6bdd1fc5-810f-11d0-bec7-08002be2092f}
Keyboard Keyboard {4d36e96b-e325-11ce-bfc1-08002be10318}
MediumChangers Medium Changers {ce5939ae-ebde-11d0-b181-0000f8753ec4}
MTD Memory Technology Driver {4d36e970-e325-11ce-bfc1-08002be10318}
Media Multimedia {4d36e96c-e325-11ce-bfc1-08002be10318}
Modem Modem {4d36e96d-e325-11ce-bfc1-08002be10318}
Monitor Monitor {4d36e96e-e325-11ce-bfc1-08002be10318}
Mouse Mouse {4d36e96f-e325-11ce-bfc1-08002be10318}
Multifunction Multifunction Devices {4d36e971-e325-11ce-bfc1-08002be10318}
MultiportSerial Multi-port Serial Adapters {50906cb8-ba12-11d1-bf5d-0000f805f530}
Network Network Adapter {4d36e972-e325-11ce-bfc1-08002be10318}
NetClient Network Client {4d36e973-e325-11ce-bfc1-08002be10318}
NetService Network Service {4d36e974-e325-11ce-bfc1-08002be10318}
NetTrans Network Transport {4d36e975-e325-11ce-bfc1-08002be10318}
PCMCIA PCMCIA Adapters {4d36e977-e325-11ce-bfc1-08002be10318}
Ports Ports (COM & LPT) {4d36e978-e325-11ce-bfc1-08002be10318}
Printer Printer {4d36e979-e325-11ce-bfc1-08002be10318}
SCSIAdapter SCSI and RAID Controllers {4d36e97b-e325-11ce-bfc1-08002be10318}
SmartCardReader Smart Card Readers {50dd5230-ba8a-11d1-bf5d-0000f805f530}
Volume Storage Volumes {71a27cdd-812a-11d0-bec7-08002be2092f}
System System Devices {4d36e97d-e325-11ce-bfc1-08002be10318}
TapeDrive Tape Drives {6d807884-7d21-11cf-801c-08002be10318}
USB USB {36fc9e60-c465-11cf-8056-444553540000}

Customizing an Installation

There 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.

< BACK  NEXT >


The Windows 2000 Device Driver Book(c) A Guide for Programmers
The Windows 2000 Device Driver Book: A Guide for Programmers (2nd Edition)
ISBN: 0130204315
EAN: 2147483647
Year: 2000
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net