Registering Interrupt Handler

Hardwares inform processor through signals called interrupts whenever they require processor's attention. Registering interrupt handler: Interrupt handlers are registered using request_irq and unregistered using free_irq calls.
int request_irq(
 unsignd int irq, /* Requested interrupt number */
 irqreturn_t (*handler)(int, void *, struct  pt_regs *), 
  /* Interrupt handler */
 unsigned long flags, /* Flags */
 const  char *dev_name,
  /* Device name -- used in /proc/interrupts */
 void *dev_id); /* Device id */

void  free_irq(
  unsigned int irq, /* Interrupt number */
  void *dev_id); /*  Device id */

Flags:
SA_INTERRUPT - Indicates a fast interrupt handler. Fast interrupt handlers are executed with interrupts disabled on the current processor.
SA_SHIRQ - Interrupt can be shared between devices.
SA_SAMPLE_RANDOM - device may be considered as a source of random events (and can be used by the kernel random number generator).

Since an interrupt can be shared and device id is unique for each device, free_irq takes both interrupt number and device id.

Registration of interrupt handlers can be done either during driver load or during initialization. Correspondingly, free_irq is called either during termination or during driver unload.

Reference: Linux Device Drivers

Stumble
Delicious
Technorati
Twitter
Facebook

Bookmark and Share
Your Ad Here

0 comments

Post a Comment