diff --git a/arch/Kconfig b/arch/Kconfig index cf3609193f0..2d48d74767d 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -206,6 +206,14 @@ menu "Interrupt Configuration" # # Interrupt related configs # +config DYNAMIC_INTERRUPTS + bool "Enable installation of IRQs at runtime" + default n + help + Enable installation of interrupts at runtime, which will move some + interrupt-related data structures to RAM instead of ROM, and + on some architectures increase code size. + config GEN_ISR_TABLES bool "Use generated IRQ tables" help diff --git a/include/irq.h b/include/irq.h index a919cb25d87..dd3cd163137 100644 --- a/include/irq.h +++ b/include/irq.h @@ -16,6 +16,7 @@ #ifndef _ASMLANGUAGE #include +#include #ifdef __cplusplus extern "C" { @@ -49,6 +50,31 @@ extern "C" { #define IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \ _ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) +/** + * Configure a dynamic interrupt. + * + * Use this instead of IRQ_CONNECT() if arguments cannot be known at build time. + * + * @param irq IRQ line number + * @param priority Interrupt priority + * @param routine Interrupt service routine + * @param parameter ISR parameter + * @param flags Arch-specific IRQ configuration flags + * + * @return The vector assigned to this interrupt + */ +extern int _arch_irq_connect_dynamic(unsigned int irq, unsigned int priority, + void (*routine)(void *parameter), void *parameter, + u32_t flags); + +static inline int +irq_connect_dynamic(unsigned int irq, unsigned int priority, + void (*routine)(void *parameter), void *parameter, + u32_t flags) +{ + return _arch_irq_connect_dynamic(irq, priority, routine, parameter, flags); +} + /** * @brief Initialize a 'direct' interrupt handler. *