diff --git a/arch/common/CMakeLists.txt b/arch/common/CMakeLists.txt index 7ef9d48c50e..1a5f3b5192a 100644 --- a/arch/common/CMakeLists.txt +++ b/arch/common/CMakeLists.txt @@ -5,6 +5,7 @@ zephyr_cc_option(-ffunction-sections -fdata-sections) zephyr_sources_ifdef( CONFIG_GEN_ISR_TABLES isr_tables.c + sw_isr_common.c ) zephyr_sources_ifdef( diff --git a/arch/common/sw_isr_common.c b/arch/common/sw_isr_common.c new file mode 100644 index 00000000000..f7fc9d20c5a --- /dev/null +++ b/arch/common/sw_isr_common.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018 Intel Corporation. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +/* + * Common code for arches that use software ISR tables (CONFIG_GEN_ISR_TABLES) + */ + +#ifdef CONFIG_DYNAMIC_INTERRUPTS +void z_isr_install(unsigned int irq, void (*routine)(void *), void *param) +{ + unsigned int table_idx = irq - CONFIG_GEN_IRQ_START_VECTOR; + + __ASSERT(!irq_is_enabled(irq), "IRQ %d is enabled", irq); + + /* If dynamic IRQs are enabled, then the _sw_isr_table is in RAM and + * can be modified + */ + _sw_isr_table[table_idx].arg = param; + _sw_isr_table[table_idx].isr = routine; +} +#endif /* CONFIG_DYNAMIC_INTERRUPTS */ diff --git a/include/sw_isr_table.h b/include/sw_isr_table.h index d121abfb737..5d810dc51c9 100644 --- a/include/sw_isr_table.h +++ b/include/sw_isr_table.h @@ -71,6 +71,10 @@ struct _isr_list { #define IRQ_TABLE_SIZE (CONFIG_NUM_IRQS - CONFIG_GEN_IRQ_START_VECTOR) +#ifdef CONFIG_DYNAMIC_INTERRUPTS +void z_isr_install(unsigned int irq, void (*routine)(void *), void *param); +#endif + #endif /* _ASMLANGUAGE */ #ifdef __cplusplus