diff --git a/arch/common/CMakeLists.txt b/arch/common/CMakeLists.txt index 8056ad5d95..7421e44631 100644 --- a/arch/common/CMakeLists.txt +++ b/arch/common/CMakeLists.txt @@ -2,6 +2,8 @@ zephyr_library() +zephyr_library_include_directories(include) + # Library may be empty due to kconfigs zephyr_library_property(ALLOW_EMPTY TRUE) diff --git a/arch/common/include/sw_isr_common.h b/arch/common/include/sw_isr_common.h new file mode 100644 index 0000000000..223c9ba244 --- /dev/null +++ b/arch/common/include/sw_isr_common.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023, Meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief Private header for the software-managed ISR table's functions + */ + +#ifndef ZEPHYR_ARCH_COMMON_INCLUDE_SW_ISR_COMMON_H_ +#define ZEPHYR_ARCH_COMMON_INCLUDE_SW_ISR_COMMON_H_ + +#if !defined(_ASMLANGUAGE) +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Helper function used to compute the index in _sw_isr_table + * based on passed IRQ. + * + * @param irq IRQ number in its zephyr format + * + * @return corresponding index in _sw_isr_table + */ +unsigned int z_get_sw_isr_table_idx(unsigned int irq); + +/** + * @brief Helper function used to get the parent interrupt controller device based on passed IRQ. + * + * @param irq IRQ number in its zephyr format + * + * @return corresponding interrupt controller device in _sw_isr_table + */ +const struct device *z_get_sw_isr_device_from_irq(unsigned int irq); + +/** + * @brief Helper function used to get the IRQN of the passed in parent interrupt + * controller device. + * + * @param dev parent interrupt controller device + * + * @return IRQN of the interrupt controller + */ +unsigned int z_get_sw_isr_irq_from_device(const struct device *dev); + +#ifdef __cplusplus +} +#endif + +#endif /* _ASMLANGUAGE */ + +#endif /* ZEPHYR_ARCH_COMMON_INCLUDE_SW_ISR_COMMON_H_ */ diff --git a/arch/common/shared_irq.c b/arch/common/shared_irq.c index 744aece2fd..68641cb2bb 100644 --- a/arch/common/shared_irq.c +++ b/arch/common/shared_irq.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "sw_isr_common.h" + #include #include diff --git a/include/zephyr/sw_isr_table.h b/include/zephyr/sw_isr_table.h index fb68272c34..f43efafad4 100644 --- a/include/zephyr/sw_isr_table.h +++ b/include/zephyr/sw_isr_table.h @@ -84,35 +84,6 @@ void z_shared_isr(const void *data); extern struct z_shared_isr_table_entry z_shared_sw_isr_table[]; #endif /* CONFIG_SHARED_INTERRUPTS */ -/** - * @brief Helper function used to compute the index in _sw_isr_table - * based on passed IRQ. - * - * @param irq IRQ number in its zephyr format - * - * @return corresponding index in _sw_isr_table - */ -unsigned int z_get_sw_isr_table_idx(unsigned int irq); - -/** - * @brief Helper function used to get the parent interrupt controller device based on passed IRQ. - * - * @param irq IRQ number in its zephyr format - * - * @return corresponding interrupt controller device in _sw_isr_table - */ -const struct device *z_get_sw_isr_device_from_irq(unsigned int irq); - -/** - * @brief Helper function used to get the IRQN of the passed in parent interrupt - * controller device. - * - * @param dev parent interrupt controller device - * - * @return IRQN of the interrupt controller - */ -unsigned int z_get_sw_isr_irq_from_device(const struct device *dev); - /** This interrupt gets put directly in the vector table */ #define ISR_FLAG_DIRECT BIT(0) diff --git a/tests/kernel/interrupt/CMakeLists.txt b/tests/kernel/interrupt/CMakeLists.txt index 645f1f7965..b464719f89 100644 --- a/tests/kernel/interrupt/CMakeLists.txt +++ b/tests/kernel/interrupt/CMakeLists.txt @@ -7,6 +7,7 @@ project(interrupt) target_include_directories(app PRIVATE ${ZEPHYR_BASE}/kernel/include ${ZEPHYR_BASE}/arch/${ARCH}/include + ${ZEPHYR_BASE}/arch/common/include ) target_sources(app PRIVATE diff --git a/tests/kernel/interrupt/src/sw_isr_table.c b/tests/kernel/interrupt/src/sw_isr_table.c index 621480905a..385f2c244b 100644 --- a/tests/kernel/interrupt/src/sw_isr_table.c +++ b/tests/kernel/interrupt/src/sw_isr_table.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "sw_isr_common.h" + #include extern const struct _irq_parent_entry _lvl2_irq_list[];