Skip to content

Commit ff6cce6

Browse files
Andrew Boienashif
authored andcommitted
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 <[email protected]>
1 parent 9c8a609 commit ff6cce6

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

arch/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ menu "Interrupt Configuration"
206206
#
207207
# Interrupt related configs
208208
#
209+
config DYNAMIC_INTERRUPTS
210+
bool "Enable installation of IRQs at runtime"
211+
default n
212+
help
213+
Enable installation of interrupts at runtime, which will move some
214+
interrupt-related data structures to RAM instead of ROM, and
215+
on some architectures increase code size.
216+
209217
config GEN_ISR_TABLES
210218
bool "Use generated IRQ tables"
211219
help

include/irq.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#ifndef _ASMLANGUAGE
1818
#include <toolchain.h>
19+
#include <zephyr/types.h>
1920

2021
#ifdef __cplusplus
2122
extern "C" {
@@ -49,6 +50,31 @@ extern "C" {
4950
#define IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
5051
_ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p)
5152

53+
/**
54+
* Configure a dynamic interrupt.
55+
*
56+
* Use this instead of IRQ_CONNECT() if arguments cannot be known at build time.
57+
*
58+
* @param irq IRQ line number
59+
* @param priority Interrupt priority
60+
* @param routine Interrupt service routine
61+
* @param parameter ISR parameter
62+
* @param flags Arch-specific IRQ configuration flags
63+
*
64+
* @return The vector assigned to this interrupt
65+
*/
66+
extern int _arch_irq_connect_dynamic(unsigned int irq, unsigned int priority,
67+
void (*routine)(void *parameter), void *parameter,
68+
u32_t flags);
69+
70+
static inline int
71+
irq_connect_dynamic(unsigned int irq, unsigned int priority,
72+
void (*routine)(void *parameter), void *parameter,
73+
u32_t flags)
74+
{
75+
return _arch_irq_connect_dynamic(irq, priority, routine, parameter, flags);
76+
}
77+
5278
/**
5379
* @brief Initialize a 'direct' interrupt handler.
5480
*

0 commit comments

Comments
 (0)