Handling Interrupts in a Device Driver

I wrote a simple character driver and requested an IRQ on the gpio pin and asked for a handler for it.

err = request_irq (irq, irq_handler, IRQF_SHARED | IRQF_TRIGGER_RISING, INTERRUPT_DEVICE_NAME, raspi_gpio_devp);

static irqreturn_t irq_handler (int irq, void * arg);

Now, from theory, I know that after an interrupt, the Interrupt Controller inform the processor about the call to do_IRQ (), which will check the IDT and call my interrupt handler for this line.

how does the kernel know that the interrupt handler was for this particular device file

I also know that interrupt handlers do not start in any process context. But let me say that I refer to any variable declared outside the processing area of ​​the handler, static global flag = 0. In the handler, I make flag = 1, indicating that an interrupt has occurred. This variable is in the context of the process. Therefore, I am confused by the way this handler does not in any context of the process change the variable in the context of the process.

thank

+4
source share
3 answers

The kernel does not know that this particular interrupt is for a specific device.

, , , irq_handler raspi_gpio_devp . (: irq_handler(irq, raspi_gpio_devp)).

irq , , IRQ . :

int irq_handler(int irq, void* dev_id) {
    struct raspi_gpio_dev *raspi_gpio_devp = (struct raspi_gpio_dev *) dev_id;
    if (!my_gpio_irq_occured(raspi_gpio_devp))
        return IRQ_NONE;
    /* do stuff here */
    return IRQ_HANDLED;
}

. , .

, :

  • - (, /fifo )
  • wake_up() ,

, , , .

, , Linux Kernel Developpement Robert Love.

+4

, . . . . , (.. "" ).

"void * arg". , , - , ( , /, , ).

" ". - , . " ", : (1) / (- ?), (2) - ( ?), (3) " " ( ).

, " ", / .

+5

: -

​​, > ?

  • System-On-Chip , .

  • .

  • IRQ register_irq.

  • / IRQ , IRQ- IRQ ( , VM).

blog

0

All Articles