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 <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2018-10-30 16:53:56 -07:00 committed by Anas Nashif
commit ff6cce6fc0
2 changed files with 34 additions and 0 deletions

View file

@ -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

View file

@ -16,6 +16,7 @@
#ifndef _ASMLANGUAGE
#include <toolchain.h>
#include <zephyr/types.h>
#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.
*