The diagnostic interrupt handler function for a device must be packaged in an executable module separate from the Test Unit library. This module is loaded into the operating system and registered with the diagnostic system services when the TU_OPEN calls the pdiag_open function.
When the services receive an interrupt, control is passed to these "second-level" interrupt handlers in sequential order. Each interrupt handler reads the status of its respective adapter to see if it was the source of the interrupt. If the Test Unit is waiting for the interrupt by calling the pdiag_dd_watch_for_interrupt service, the sleep_flag will be set to 1, indicating that the interrupt handler should do a pdiag_dd_interrupt_notify when it has completed.
Interrupt handlers can use the device methods to read and write operations on the device. Typically, they will read registers on the device to obtain more information about the interrupt, and write registers (if necessary) to clear the interrupt condition. The content of any data passed back to the TU through the data_area buffer, and whether the TUs even wait for interrupts, is a decision left to the designer of the TUs and interrupt handler. That decision depends upon the operation of the specific device and how it is being tested.
The function entry prototype for an interrupt handler is as follows:
int device_interrupt ( PDIAG_INFO_HANDLE *handle, pdiag_addr_t data_area,int32 *interrupt_flag, uint32 sleep_flag, uint32 *sleep_word )