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.
Example
#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:
Case 2:
- Interrupt received
- Interrupt handler reads device, sees interrupt A, sets:
interrupt_flag = Int_A
- pdiag_dd_watch_for_interrupt returns
Case 3:
- Interrupt received
- Interrupt handler reads device, sees both interrupt B and C, sets:
interrupt_flag = Int_B | Int_C
- pdiag_dd_watch_for_interrupt returns