16.8.2  Getting Device Hardware Configuration Information

When an NT device driver is loaded, the OS loader has already set up the registry with any machine-specific information the ARC or NtDetect component could find. Depending on the I/O buses in the machine, this information can include the bus-relative interrupt vector for a particular peripheral connected on a particular bus, the bus-relative physical memory range or the bus-relative range of I/O ports that a particular device can use, or the bus-relative DMA controller channel/port to which a particular device is connected.

Each NT device driver must have this kind of hardware configuration information to initialize successfully. For example, a device driver must pass the bus-relative interrupt vector for its device to HalGetInterruptVector, as described in the section on interrupt objects in Chapter 3, to get a mapped system vector, system-assigned DIRQL, and processor affinity mask, required as parameters to IoConnectInterrupt. Otherwise, the driver cannot be loaded because it cannot register its ISR(s) to handle interrupts from its device(s).

If a driver needs hardware configuration information that the ARC or NtDetect component cannot supply, it can get some of the required information from its device or by calling HalGetBusData, particularly for an EISA or MCA device, or HalGetBusDataByOffset, particularly for a PCI device. Calls to these support routines can return more hardware configuration data than is available in the registry ..\Hardware\Description tree since they are called later in the system boot process. For more information about getting hardware configuration information with these routines, see Section 16.8.2.2. For specifics, see the Kernel-Mode Driver Reference.

Otherwise, the driver must must use the RegistryPath pointer to get its DriverName\Parameters, as mentioned in Section 16.8.1.1. An NT driver can always supplement the system-, bus-, or device-supplied hardware information with “user-supplied” Parameters under its registry key \Registry\Machine\System\CurrentControlSet\Services\DriverName . Frequently, these Parameters are set up in the registry when the user installs a new driver. For more information about using Parameters, see also Section 16.8.5. For more information about installing Windows NT drivers, see the Programmer’s Guide.

Every NT device driver must claim any hardware resources it needs for its device(s) in the \Registry\Machine\Hardware\ResourceMap tree, as described in Section 16.8.3. Any NT driver that cannot claim sufficient hardware resources for at least one device should release any system resources it is using, such a driver-created device object(s). Such a driver must not be loaded.