Assigns an interrupt handler to the specified interrupt level, and optionally makes the calling thread the interrupt thread for that level. This call can also designate a handler as a shared handler, or an MSI handler. It is not necessary for the handler to have an associated thread.
Typically the programmer is required to call SetRtInterruptHandlerEx in place of SetRtInterruptHandler in the case of PCI interrupt handlers (because they can be shared) and in the case of MSI handlers.
WORD SetRtInterruptHandlerEx( WORD wLevel, BYTE byMaxInt, LPPROC lpfnHandler, LPVOID lpParamPtr );
wLevel
byMaxInt
lpfnHandler
lpParamPtr
The number of outstanding SignalRtInterruptThread requests that the handler can make before the associated interrupt level is disabled generally corresponds to the number of buffers used by the handler and interrupt thread.
If the byMaxInt parameter is non-zero, then the calling thread becomes the interrupt thread. If the interrupt source is a PCI legacy interrupt or an MSI, it is recommended that this value is set to the maximum, 255. If a small value is provided there is the risk that interrupts will be lost.
If the interrupt source is a legacy IRQ from a PCI device, assume that the interrupt line may be shared and logical-or the level parameter with SHARED_LEVEL before making the call.
If the interrupt level parameter is not OR-ed with SHARED_LEVEL and is not MSI_LEVEL then the interrupt handler will have the same form as for SetRtInterruptHandler.
If the interrupt source is an MSI then specify MSI_LEVEL for the wLevel parameter. In this case the lpParamPtr must point to an initialized MSI_PARAM or MSI_PARAM_EX structure. See the section about MSI handling for more detail.
The interrupt handler has this general form:
__INTERRUPT void InterruptHandler( WORD wCSRA, // (unused) WORD wLevel, // interrupt level returned from SetRtInterruptHandlerEx PVOID pv) // parameter pointer from SetRtInterruptHandlerEx { // TODO: any local variables are declared here. __SHARED_INTERRUPT_PROLOG(); // TODO: interrupt handling statements __SHARED_INTERRUPT_RETURN(); }
Note that any pointer to a variable on the stack in the interrupt handler cannot be dereferenced. This is because the interrupt handler runs in a privileged context which makes it impossible for the compiler to generate a correct stack-based address. Any attempt to do so will result in a page fault.
To uninstall an interrupt handler call ResetRtInterruptHandler. If a handler has an associated interrupt thread then an implicit call to ResetRtInterruptHandler is made on exit from the current process. If there is no interrupt thread then an explicit call to ResetRtInterruptHandler must be made before process termination. Failure to do so can cause system instability.
BAD_LEVEL
. To determine the status, call GetLastRtError. E_OK 0000
E_LIMIT 0x0004
byMaxInt
contains a value other than 0 (zero).
E_CONTEXT 0x0005
E_PARAM 0x8004
wLevel
is invalid.
E_BAD_ADDR 0x800F
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/rtbase.h | rt.h | rt.lib |