# arch/avr32/include/arch/irq_handler.h File Reference

Interrupt handler support. More...

`#include <io.h>`
`#include <util.h>`
`#include <chip/memory-map.h>`
`#include <cpu/irq_handler.h>`

Include dependency graph for irq_handler.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | DEFINE_IRQ_HANDLER(name, handler, level)
| Define an interrupt handler for an integrated peripheral.
#define | set_irq_data(name, data)
| Associate a data pointer with an interrupt.
#define | setup_irq_handler(irq, name, level, data)
| Set up an interrupt handler.
#define | remove_irq_handler(name)
| Remove an interrupt handler.
## Functions
static unsigned long | get_irq_group_requests (unsigned int group)
| Get the pending interrupt mask for group.

## Detailed Description

Interrupt handler support.

This file includes macros and helper functions for setting up interrupt handlers.

- Compiler: GNU GCC for AVR32
- Supported devices: All AVR32 devices
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file irq_handler.h.

## Define Documentation

#define DEFINE_IRQ_HANDLER | ( | name,
|  | handler,
|  | level |  | ) |

Value:

    extern void irq_entry_symbol(name)(void);                       \
            extern void *irq_data_symbol(name);                             \
            static void __used __dummy_irq_ref_##name(void)                 \
            {                                                               \
                    handler(&handler);                                      \
            }                                                               \
            asm(".section " __irq_entry_section(name) "\n"                  \
                    "       .global " irq_entry_symbol_str(name) "\n"       \
                    "       .type   " irq_entry_symbol_str(name) ", @function\n" \
                    irq_entry_symbol_str(name) ":\n"                        \
                    CPU_SAVE_IRQ_REGS(level)                                \
                    "       lda.w   r8, " irq_data_symbol_str(name) "\n"    \
                    "       ld.w    r12, r8[0]\n"                           \
                    "       rcall   " #handler "\n"                         \
                    "       rjmp    irq_level" #level "_return\n"           \
                    "       .size   " __irq_entry_size(name) "\n"           \
                    "       .previous\n"                                    \
                    "       .section " __irq_data_section(name) "\n"        \
                    "       .global " irq_data_symbol_str(name) "\n"        \
                    "       .type   " irq_data_symbol_str(name) ", @object\n" \
                    irq_data_symbol_str(name) ":\n"                         \
                    "       .long   0\n"                                    \
                    "       .size   " __irq_data_size(name) "\n"            \
                    "       .previous")

Define an interrupt handler for an integrated peripheral.

This binds an interrupt handler function to a low-level entry point, which takes care of saving/restoring registers, finding the handler-specific data, and running any code dealing with scheduling, soft interrupt handling, etc. before returning.

Note:
  This is not a function-like macro; it should not be called from within functions. Instead, it should be called from the top-level right after the definition of the interrupt handler function.

Parameters:

  | name | An arbitrary name associated with this interrupt.
  | handler | The interrupt handler function.
  | level | The interrupt priority level for this interrupt.

Definition at line 83 of file irq_handler.h.

#define remove_irq_handler | ( | name |  | ) |

Value:

    do {                                                            \
                    extern void *irq_data_symbol(name);                     \
                    irq_data_symbol(name) = 0;                              \
            } while (0)

Remove an interrupt handler.

This will remove a registered interrupt handler, making it possible to set up a different one by calling setup_irq_handler().

Note:
  This function doesn't actually reprogram the interrupt controller; it just makes it possible to register a different handler for this interrupt later.

Parameters:

  | name | The name associated with the interrupt.

Definition at line 166 of file irq_handler.h.

#define set_irq_data | ( | name,
|  | data |  | ) |

Value:

    do {                                                            \
                    irq_data_symbol(name) = (data);                         \
            } while (0)

Associate a data pointer with an interrupt.

Parameters:

  | name | The name of the interrupt, as given to define_irq_handler().
  | data | Data to be associated with the interrupt.

Definition at line 115 of file irq_handler.h.

#define setup_irq_handler | ( | irq,
|  | name,
|  | level,
|  | data |  | ) |

Value:

    do {                                                            \
                    extern void irq_entry_symbol(name)(void);               \
                    extern void *irq_data_symbol(name);                     \
                    __setup_irq_handler(irq, &irq_entry_symbol(name),       \
                                    &irq_data_symbol(name), level, data);   \
            } while (0)

Set up an interrupt handler.

This function sets up the internal interrupt controller for handling a given interrupt through the specified handler.

Note:
  Unlike define_irq_handler(), this _is_ a function-like macro.

  Usually, this is the only reference to the handler function and associated low-level entry code. This means that it is perfectly ok to define handlers for more interrupts than needed -- if they aren't actually enabled by calling this function, they will get discarded at link-time when --gc-sections is used.

Parameters:

  | irq | The interrupt number for the handler.
  | name | The name associated with the interrupt.
  | level | The priority level for this interrupt.
  | data | Data to be associated with this interrupt.

Precondition:
  A handler for this interrupt has not already been set up.

  level must be between 0 and 3 inclusive.

  The low-level entry point must be placed less than 16k after EVBA.

Definition at line 146 of file irq_handler.h.

Referenced by gpio_setup_irq_group(), sdmmc_mcihost_init(), timer_init(), and usbb_init().

## Function Documentation

static unsigned long get_irq_group_requests | ( | unsigned int | group | ) | `[inline, static]`

Get the pending interrupt mask for group.

Definition at line 175 of file irq_handler.h.

References mmio_read32().

Here is the call graph for this function: