gpio interrupt on x86

Andriy Gapon avg at FreeBSD.org
Mon May 27 15:24:00 UTC 2019


I would like to run some code when an input pin changes its state.
A GPIO controller that handles that pin is capable of generating an interrupt.
I can configure the type of a signal change that would trigger the interrupt.
The GPIO controller would generate the interrupt on that change.
I would be able to query the controller for a specific pin (if interrupts for
multiple pins are enabled).
All is good.

Now, the question is how to _properly_ hook my code to the gpiobus hanging off
the controller.
I see that embedded (or not so embedded) platforms typically define a "slave"
interrupt controller.  I guess that it defines a new interrupt number (and
interrupt source, etc) for each interrupt capable pin.  And then hooking to that
pin is a matter of just installing an interrupt handler for a specific interrupt
and enabling it.

But I am not sure if the same approach would work on x86.
Is there any other alternative approach?
Perhaps even a more light-weight one?
Any code examples?

Thank you.
-- 
Andriy Gapon


More information about the freebsd-hackers mailing list