INTRENABLE(9)                                       INTRENABLE(9)

     NAME
          intrenable, intrdisable - enable (disable) an interrupt
          handler

     SYNOPSIS
          void intrenable(int v, void (*f)(Ureg*, void*), void* a, int
          tbdf, char *name)

          void intrdisable(int v, void (*f)(Ureg*, void*), void* a,
          int tbdf, char *name)

     DESCRIPTION
          Intrenable registers f to be called by the kernel's inter-
          rupt controller driver each time an interrupt denoted by v
          occurs, and unmasks the corresponding interrupt in the
          interrupt controller.  The encoding of v is platform-
          dependent; it is often an interrupt vector number, but can
          be more complex.  Tbdf is a platform-dependent value that
          might further qualify v. It might for instance denote the
          type of bus, bus instance, device number and function (fol-
          lowing the PCI device indexing scheme), hence its name, but
          can have platform-dependent meaning.  Name is a string that
          should uniquely identify the corresponding device (eg,
          "uart0"); again it is usually platform-dependent.
          Intrenable supports sharing of interrupt levels when the
          hardware does.

          Almost invariably f is a function defined in a device driver
          to carry out the device-specific work associated with a
          given interrupt.  The pointer a is passed to f; typically it
          points to the driver's data for a given device or con-
          troller.  It also passes f a Ureg* value that contains the
          registers saved by the interrupt handler (the contents are
          platform specific; see the platform's include file ureg.h).

          F is invoked by underlying code in the kernel that is
          invoked directly from the hardware vectors.  It is therefore
          not running in any process (see kproc(9); indeed, on many
          platforms the current process pointer (up) will be nil.
          There are many restrictions on kernel functions running out-
          side a process, but a fundamental one is that they must not
          sleep(9), although they often call wakeup to signal the
          occurrence of an event associated with the interrupt.
          Qio(9) and other manual pages note which functions are safe
          for f to call.

          The interrupt controller driver does whatever is required to
          acknowledge or dismiss the interrupt signal in the interrupt
          controller, before calling f, for edge-triggered interrupts,
          and after calling f for level-triggered ones.  F is

     Page 1                       Plan 9            (printed 12/21/24)

     INTRENABLE(9)                                       INTRENABLE(9)

          responsible for deal with the cause of the interrupt in the
          device, including any acknowledgement required in the
          device, before it returns.

          Intrdisable removes any registration previously made by
          intrenable with matching parameters, and if no other inter-
          rupt is active on v, it masks the interrupt in the con-
          troller.  Device drivers that are not dynamically configured
          tend to call intrenable during reset or initialisation (see
          dev(9)), but can call it at any appropriate time, and
          instead of calling intrdisable they can simply enable or
          disable interrupts in the device as required.

     SOURCE
          /sys/src/9/*/trap.c

     SEE ALSO
          malloc(9), qio(9), sleep(9), splhi(9)

     Page 2                       Plan 9            (printed 12/21/24)