From ff6cce6fc092aa3c7ec18b277c5c2d68619e846f Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Tue, 30 Oct 2018 16:53:56 -0700 Subject: [PATCH] kernel: add dynamic interrupt API In the past the capability to install interrupts at runtime was removed due to lack of use-cases for Zephyr's intended targets. Now we want to support hypervisor applications like ACRN where virtual devices are presented to the kernel using PCI enumeration, and the interrupt configuration is not known at build time. Signed-off-by: Andrew Boie --- arch/Kconfig | 8 ++++++++ include/irq.h | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) 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. *