[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Understanding the Diagnostic Subsystem for AIX

Using the Interrupt Flag Bit Mask

The interrupt_flag parameter to the interrupt handling routine and the flag_mask parameter on the pdiag_dd_watch_for_interrupt system service are used by the Test Unit and interrupt handler to communicate the type of interrupt that occurred, and which types of interrupts the Test Unit wants to know about. The bit fields within these words can be defined in whatever way the TU developer wants to assign them, based on the device involved and how many different interrupt types it can surface. However, it is important to understand how these parameters should be used.

When an interrupt handler is called as the result of an interrupt condition, it should examine its device to see which type of interrupt, if any, occurred on that device. If it detects no interrupt condition, the interrupt_flag should be set to 0 before it returns. If it does detect an interrupt condition, then it should set an appropriate bit equal to 1 in the interrupt_flag before it returns.

A TU waits for an interrupt condition to occur by calling the pdiag_dd_watch_for_interrupt service, and one of the parameters to that function is a flag_mask word. This is defined as a bit mask, using the same bit definitions as in the interrupt handler, to indicate the interrupt types for which the TU wants to watch. It does this by setting one or more bit values equal to 1, where each bit represents an interrupt type. The pdiag_dd_watch_for_interrupt will not return until either an appropriate interrupt is detected (essentially determined by a non-zero result when "and"ing the flag_mask and the interrupt_flag 0 values), or until the time limit is reached.

Note: If the Test Unit writer wants to watch for more than one interrupt type, but also needs to know which specific interrupt occurred, the writer should define a structure element in the data_area buffer where the interrupt handler can pass back that information.


#define Int_A 80000000       /* Common defines used by both the TU and */
#define Int_B 40000000       /* interrupt handler                     */
#define Int_C 20000000

Assume TU calls pdiag_dd_watch_for_interrupt with:

flag_mask = Int_A | Int_B
Case 1:
  1. Interrupt received
  2. Interrupt handler reads device, sees Interrupt C, sets:
    interrupt_flag = Int_C
  3. pdiag_dd_watch_for_interrupt does not return until timeout occurs.
Case 2:
  1. Interrupt received
  2. Interrupt handler reads device, sees interrupt A, sets:
    interrupt_flag = Int_A
  3. pdiag_dd_watch_for_interrupt returns
Case 3:
  1. Interrupt received
  2. Interrupt handler reads device, sees both interrupt B and C, sets:
    interrupt_flag = Int_B | Int_C
  3. pdiag_dd_watch_for_interrupt returns

[ Previous | Next | Contents | Home | Search ]