A typical sequence of events in the functional flow of a Test Unit is to set up a device operation through reads and writes to the device address space, and then wait to receive an interrupt from the device to indicate that an operation has completed or needs attention. Since interrupt handling is device-specific and part of the test process, an interrupt handler function must be provided in addition to the Test Unit library. When a device is opened for testing by Test Unit 1 (TU_OPEN), an interrupt handler may be loaded (if one is needed) by passing an interrupt handler module name as one of the parameters on the pdiag_open system service. A data buffer address is also passed as part of the input to the pdiag_open function, so the device methods know which interrupt handler to use, as well as where to pass back data from the interrupt handler.
The purpose of the interrupt handler function is to receive the interrupt indication, possibly gather some information from the device, clear the interrupt condition on the device, and notify a waiting Test Unit that the interrupt has occurred. Clearing of the interrupt condition is critical, because the interrupt handler will be called continuously as long as the interrupt condition exists. Since this function is called to handle a specific device I/O interrupt, the information it gathers from the device is useful in diagnosing the device behavior. The interrupt handler puts this information into the data buffer area (defined at device-open time), where the waiting Test Unit can access it for analysis.
The basic flow of interrupt processing is shown in the "Interrupt Processing in Test Units" illustration. The flow of events is as follows:
The cycle of device setup and wait for interrupt can be repeated as often as necessary during the execution of the Test Units. Registration of the interrupt handler only needs to be done once, at the time when the device is opened for testing. However, different interrupt handlers could be used (if necessary) by closing the device, then reopening the device with a different interrupt handler module-name parameter.