Share via


Interrupt Service Routines (Compact 2013)

3/26/2014

An interrupt service routine (ISR) is a software routine that hardware invokes in response to an interrupt. ISRs examine an interrupt and determine how to handle it. ISRs handle the interrupt and then return a logical interrupt value. If no further handling is required because the device is disabled or data is buffered, the ISR notifies the kernel with a SYSINTR_NOP value. An ISR must perform very quickly to avoid slowing down the operation of the device and the operation of all lower-priority ISRs. The ISR runs in kernel mode, so it should do the minimum work that is required to service the interrupt. Because the kernel handles the saving and restoring of CPU registers, you can implement your ISR in small and fast C code instead of in assembly code.

The ISR performs the following tasks:

  • Determines the source of the interrupt
  • Masks the interrupt
  • Reads data from the device into a software buffer if the data might be lost or another interrupt might overwrite it
  • Clears the interrupt condition on the device
  • Translates the interrupt into a system interrupt (SYSINTR) identifier that the ISR returns to the OS

Although an ISR might move data from a CPU register or a hardware port into a memory buffer, it typically relies on a dedicated interrupt service thread (the IST) to do most of the required processing. If additional processing is required, the ISR returns a logical interrupt value other than SYSINTR_NOP to the kernel. It then maps a physical interrupt number to a logical interrupt value. For example, the keyboard could be associated with IRQ 4 on one device and IRQ 15 on another device. The ISR, which is in the OAL, translates the hardware-specific value to the Windows Embedded Compact standard value of SYSINTR_KEYBOARD. In this example, SYSINTR_KEYBOARD is the return value from the ISR.

See Also

Concepts

Add Interrupt Handling Functionality