3.5.1 Getting a System-assigned Interrupt Vector, DIRQL, and Processor Mask

When an NT device driver is loaded for initialization, the registry contains whatever hardware information the system can detect about the processors, I/O buses, and peripheral devices in the machine. An NT device driver can use the registry to determine the system-assigned number and, for some devices, the system-defined interface type of the bus to which its device is attached, along with the bus-relative vector and/or IRQL for the device itself. Otherwise, an NT device driver can call one of the HalGetBusXxx routines to get bus-relative configuration information about its interrupt and use other support routines to claim hardware resources in the registry. For more information about how device drivers can get this hardware configuration information, see Chapter 16.

The HAL is responsible for remapping bus-relative device interrupt vectors to system interrupt vectors with system-assigned DIRQL values, so NT device drivers call a HAL-supplied support routine to get required parameters for setting up interrupt objects and registering their ISRs. Figure 3.15 illustrates a call to HalGetInterruptVector.

Figure 3.15 Getting a System Vector and IRQL

As shown in Figure 3.15, HalGetInterruptVector maps driver-supplied values for a device’s bus-relative interrupt vector and IRQL to DeviceSystemVector and SystemDirql values. See the section on the registry in Chapter 16 for more information about how device drivers can obtain the BusInterfaceType, BusNumber, BusRelativeVector, and BusRelativeIrql parameters to HalGetInterruptVector.

HalGetInterruptVector also returns a ProcessorMask (Affinity) that indicates the platform-specific set of processors on which any particular device can interrupt. NT device drivers must pass this value to the I/O Manager so it can set up a Kernel-defined interrupt object for each enabled processor when the driver registers its ISR, as explained in the next section.