Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: Add interrupt controller API #66505

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ set(ZEPHYR_FINAL_EXECUTABLE zephyr_final)

# Set some phony targets to collect dependencies
set(OFFSETS_H_TARGET offsets_h)
set(SYS_IRQ_TARGET sys_irq_target)
set(SYSCALL_LIST_H_TARGET syscall_list_h_target)
set(DRIVER_VALIDATION_H_TARGET driver_validation_h_target)
set(KOBJ_TYPES_H_TARGET kobj_types_h_target)
Expand Down Expand Up @@ -910,6 +911,10 @@ add_dependencies(zephyr_interface
${KOBJ_TYPES_H_TARGET}
)

if (CONFIG_SYS_IRQ)
add_dependencies(zephyr_interface ${SYS_IRQ_TARGET})
endif()

add_custom_command(
OUTPUT ${OFFSETS_H_PATH}
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/gen_offset_header.py
Expand All @@ -921,6 +926,48 @@ add_custom_command(
)
add_custom_target(${OFFSETS_H_TARGET} DEPENDS ${OFFSETS_H_PATH})

set(SYS_IRQ_H_PATH ${PROJECT_BINARY_DIR}/include/generated/zephyr/sys_irq_generated.h)
set(SYS_IRQ_INTERNAL_H_PATH ${PROJECT_BINARY_DIR}/include/generated/zephyr/sys_irq_internal_generated.h)
set(SYS_IRQ_HANDLER_H_PATH ${PROJECT_BINARY_DIR}/include/generated/zephyr/sys_irq_handler_generated.h)
set(SYS_IRQ_HANDLER_C_PATH ${PROJECT_BINARY_DIR}/misc/generated/sys_irq_handler_generated.c)

if(CONFIG_SYS_IRQ_LOG_SPURIOUS)
set(SYS_IRQ_LOG_SPURIOUS_ARG --log-spurious-irq)
endif()

if(CONFIG_SYS_IRQ_DYNAMIC)
set(SYS_IRQ_DYNAMIC_ARG --dynamic-irq)
endif()

add_custom_command(
OUTPUT
${SYS_IRQ_H_PATH}
${SYS_IRQ_INTERNAL_H_PATH}
${SYS_IRQ_HANDLER_H_PATH}
${SYS_IRQ_HANDLER_C_PATH}
COMMAND
${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/build/gen_sys_irq.py
--edt-pickle ${EDT_PICKLE}
--irq-h ${SYS_IRQ_H_PATH}
--irq-internal-h ${SYS_IRQ_INTERNAL_H_PATH}
--irq-handler-h ${SYS_IRQ_HANDLER_H_PATH}
--irq-handler-c ${SYS_IRQ_HANDLER_C_PATH}
${SYS_IRQ_LOG_SPURIOUS_ARG}
${SYS_IRQ_DYNAMIC_ARG}
DEPENDS
${EDT_PICKLE}
)

add_custom_target(
${SYS_IRQ_TARGET}
DEPENDS
${SYS_IRQ_H_PATH}
${SYS_IRQ_INTERNAL_H_PATH}
${SYS_IRQ_HANDLER_H_PATH}
${SYS_IRQ_HANDLER_C_PATH}
)

zephyr_get_include_directories_for_lang(C ZEPHYR_INCLUDES)

add_subdirectory(kernel)
Expand Down
2 changes: 2 additions & 0 deletions drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ add_subdirectory_ifdef(CONFIG_I2S i2s)
add_subdirectory_ifdef(CONFIG_I3C i3c)
add_subdirectory_ifdef(CONFIG_IEEE802154 ieee802154)
add_subdirectory_ifdef(CONFIG_INPUT input)
add_subdirectory_ifdef(CONFIG_INTC intc)
add_subdirectory_ifdef(CONFIG_IPM ipm)
add_subdirectory_ifdef(CONFIG_KSCAN kscan)
add_subdirectory_ifdef(CONFIG_LED led)
Expand All @@ -69,6 +70,7 @@ add_subdirectory_ifdef(CONFIG_NET_DRIVERS net)
add_subdirectory_ifdef(CONFIG_PECI peci)
add_subdirectory_ifdef(CONFIG_PINCTRL pinctrl)
add_subdirectory_ifdef(CONFIG_PM_CPU_OPS pm_cpu_ops)
add_subdirectory_ifdef(CONFIG_POWER power)
add_subdirectory_ifdef(CONFIG_POWER_DOMAIN power_domain)
add_subdirectory_ifdef(CONFIG_PS2 ps2)
add_subdirectory_ifdef(CONFIG_PTP_CLOCK ptp_clock)
Expand Down
2 changes: 2 additions & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ source "drivers/i2s/Kconfig"
source "drivers/i3c/Kconfig"
source "drivers/ieee802154/Kconfig"
source "drivers/input/Kconfig"
source "drivers/intc/Kconfig"
source "drivers/interrupt_controller/Kconfig"
source "drivers/interrupt_controller/Kconfig.shared_irq"
source "drivers/ipm/Kconfig"
Expand All @@ -66,6 +67,7 @@ source "drivers/pcie/Kconfig"
source "drivers/peci/Kconfig"
source "drivers/pinctrl/Kconfig"
source "drivers/pm_cpu_ops/Kconfig"
source "drivers/power/Kconfig"
source "drivers/power_domain/Kconfig"
source "drivers/ps2/Kconfig"
source "drivers/ptp_clock/Kconfig"
Expand Down
21 changes: 15 additions & 6 deletions drivers/clock_control/clock_control_nrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <nrfx_clock.h>
#include <zephyr/logging/log.h>
#include <zephyr/shell/shell.h>
#include <zephyr/irq.h>
#include <zephyr/sys/irq.h>

LOG_MODULE_REGISTER(clock_control, CONFIG_CLOCK_CONTROL_LOG_LEVEL);

Expand Down Expand Up @@ -531,7 +531,7 @@
/* Clear pending interrupt, otherwise new clock event
* would not wake up from idle.
*/
NVIC_ClearPendingIRQ(DT_INST_IRQN(0));
sys_irq_clear(SYS_DT_IRQN(DT_NODELABEL(clock)));
nrf_clock_task_trigger(NRF_CLOCK,
NRF_CLOCK_TASK_LFCLKSTART);
}
Expand Down Expand Up @@ -648,6 +648,16 @@
#endif
}

static int clk_irq_handler_wrapper(const void *data)
{
ARG_UNUSED(data);

nrfx_clock_irq_handler();
return SYS_IRQ_HANDLED;
}

SYS_DT_DEFINE_IRQ_HANDLER(DT_NODELABEL(clock), clk_irq_handler_wrapper, NULL);

static int clk_init(const struct device *dev)
{
nrfx_err_t nrfx_err;
Expand All @@ -657,9 +667,6 @@
.stop = onoff_stop
};

IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
nrfx_isr, nrfx_power_clock_irq_handler, 0);

nrfx_err = nrfx_clock_init(clock_event_handler);
if (nrfx_err != NRFX_SUCCESS) {
return -EIO;
Expand All @@ -673,7 +680,9 @@
z_nrf_clock_calibration_init(data->mgr);
}

nrfx_clock_enable();
sys_irq_configure(SYS_DT_IRQN(DT_NODELABEL(clock)),
SYS_DT_IRQ_FLAGS(DT_NODELABEL(clock)));
sys_irq_enable(SYS_DT_IRQN(DT_NODELABEL(clock)));

Check notice on line 685 in drivers/clock_control/clock_control_nrf.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/clock_control/clock_control_nrf.c:685 - sys_irq_configure(SYS_DT_IRQN(DT_NODELABEL(clock)), - SYS_DT_IRQ_FLAGS(DT_NODELABEL(clock))); + sys_irq_configure(SYS_DT_IRQN(DT_NODELABEL(clock)), SYS_DT_IRQ_FLAGS(DT_NODELABEL(clock)));

Check notice on line 685 in drivers/clock_control/clock_control_nrf.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/clock_control/clock_control_nrf.c:685 - sys_irq_configure(SYS_DT_IRQN(DT_NODELABEL(clock)), - SYS_DT_IRQ_FLAGS(DT_NODELABEL(clock))); + sys_irq_configure(SYS_DT_IRQN(DT_NODELABEL(clock)), SYS_DT_IRQ_FLAGS(DT_NODELABEL(clock)));

for (enum clock_control_nrf_type i = 0;
i < CLOCK_CONTROL_NRF_TYPE_COUNT; i++) {
Expand Down
38 changes: 32 additions & 6 deletions drivers/gpio/gpio_nrfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <string.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/dt-bindings/gpio/nordic-nrf-gpio.h>
#include <zephyr/irq.h>
#include <zephyr/sys/irq.h>

#include <zephyr/drivers/gpio/gpio_utils.h>

Expand Down Expand Up @@ -385,10 +385,6 @@
}
#endif /* CONFIG_GPIO_NRFX_INTERRUPT */

#define GPIOTE_IRQ_HANDLER_CONNECT(node_id) \
IRQ_CONNECT(DT_IRQN(node_id), DT_IRQ(node_id, priority), nrfx_isr, \
NRFX_CONCAT(nrfx_gpiote_, DT_PROP(node_id, instance), _irq_handler), 0);

static int gpio_nrfx_init(const struct device *port)
{
const struct gpio_nrfx_cfg *cfg = get_port_cfg(port);
Expand All @@ -409,7 +405,6 @@

#ifdef CONFIG_GPIO_NRFX_INTERRUPT
nrfx_gpiote_global_callback_set(&cfg->gpiote, nrfx_gpio_handler, NULL);
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpiote, GPIOTE_IRQ_HANDLER_CONNECT);
#endif /* CONFIG_GPIO_NRFX_INTERRUPT */

return 0;
Expand Down Expand Up @@ -474,3 +469,34 @@
&gpio_nrfx_drv_api_funcs);

DT_INST_FOREACH_STATUS_OKAY(GPIO_NRF_DEVICE)

#define GPIOTE_NRF_ISR_SYM(node_id) \
NRFX_CONCAT( \
nrfx_gpiote_, \
DT_PROP(node_id, instance), \
_irq_handler \
)

#define GPIOTE_NRF_ISR_WRAP_SYM(node_id) \
_CONCAT_3( \
gpiote_nrf_, \
DT_PROP(node_id, instance), \
_isr_wrapper \
)

#define GPIOTE_NRF_DEFINE_IRQ_HANDLER(node_id) \

Check warning on line 487 in drivers/gpio/gpio_nrfx.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

MACRO_WITH_FLOW_CONTROL

drivers/gpio/gpio_nrfx.c:487 Macros with flow control statements should be avoided

Check warning on line 487 in drivers/gpio/gpio_nrfx.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

MACRO_WITH_FLOW_CONTROL

drivers/gpio/gpio_nrfx.c:487 Macros with flow control statements should be avoided
static int GPIOTE_NRF_ISR_WRAP_SYM(node_id)(const void *data) \
{ \
GPIOTE_NRF_ISR_SYM(node_id)(); \
return SYS_IRQ_HANDLED; \
} \
\
SYS_DT_DEFINE_IRQ_HANDLER( \
node_id, \
GPIOTE_NRF_ISR_WRAP_SYM(node_id), \
NULL \
)

Check notice on line 499 in drivers/gpio/gpio_nrfx.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/gpio/gpio_nrfx.c:499 -#define GPIOTE_NRF_ISR_SYM(node_id) \ - NRFX_CONCAT( \ - nrfx_gpiote_, \ - DT_PROP(node_id, instance), \ - _irq_handler \ - ) - -#define GPIOTE_NRF_ISR_WRAP_SYM(node_id) \ - _CONCAT_3( \ - gpiote_nrf_, \ - DT_PROP(node_id, instance), \ - _isr_wrapper \ - ) - -#define GPIOTE_NRF_DEFINE_IRQ_HANDLER(node_id) \ - static int GPIOTE_NRF_ISR_WRAP_SYM(node_id)(const void *data) \ - { \ - GPIOTE_NRF_ISR_SYM(node_id)(); \ - return SYS_IRQ_HANDLED; \ - } \ - \ - SYS_DT_DEFINE_IRQ_HANDLER( \ - node_id, \ - GPIOTE_NRF_ISR_WRAP_SYM(node_id), \ - NULL \ - ) +#define GPIOTE_NRF_ISR_SYM(node_id) \ + NRFX_CONCAT(nrfx_gpiote_, DT_PROP(node_id, instance), _irq_handler) + +#define GPIOTE_NRF_ISR_WRAP_SYM(node_id) \ + _CONCAT_3(gpiote_nrf_, DT_PROP(node_id, instance), _isr_wrapper) + +#define GPIOTE_NRF_DEFINE_IRQ_HANDLER(node_id) \ + static int GPIOTE_NRF_ISR_WRAP_SYM(node_id)(const void *data) \ + { \ + GPIOTE_NRF_ISR_SYM(node_id)(); \ + return SYS_IRQ_HANDLED; \ + } \ + \ + SYS_DT_DEFINE_IRQ_HANDLER(node_id, GPIOTE_NRF_ISR_WRAP_SYM(node_id), NULL)

Check notice on line 499 in drivers/gpio/gpio_nrfx.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/gpio/gpio_nrfx.c:499 -#define GPIOTE_NRF_ISR_SYM(node_id) \ - NRFX_CONCAT( \ - nrfx_gpiote_, \ - DT_PROP(node_id, instance), \ - _irq_handler \ - ) - -#define GPIOTE_NRF_ISR_WRAP_SYM(node_id) \ - _CONCAT_3( \ - gpiote_nrf_, \ - DT_PROP(node_id, instance), \ - _isr_wrapper \ - ) - -#define GPIOTE_NRF_DEFINE_IRQ_HANDLER(node_id) \ - static int GPIOTE_NRF_ISR_WRAP_SYM(node_id)(const void *data) \ - { \ - GPIOTE_NRF_ISR_SYM(node_id)(); \ - return SYS_IRQ_HANDLED; \ - } \ - \ - SYS_DT_DEFINE_IRQ_HANDLER( \ - node_id, \ - GPIOTE_NRF_ISR_WRAP_SYM(node_id), \ - NULL \ - ) +#define GPIOTE_NRF_ISR_SYM(node_id) \ + NRFX_CONCAT(nrfx_gpiote_, DT_PROP(node_id, instance), _irq_handler) + +#define GPIOTE_NRF_ISR_WRAP_SYM(node_id) \ + _CONCAT_3(gpiote_nrf_, DT_PROP(node_id, instance), _isr_wrapper) + +#define GPIOTE_NRF_DEFINE_IRQ_HANDLER(node_id) \ + static int GPIOTE_NRF_ISR_WRAP_SYM(node_id)(const void *data) \ + { \ + GPIOTE_NRF_ISR_SYM(node_id)(); \ + return SYS_IRQ_HANDLED; \ + } \ + \ + SYS_DT_DEFINE_IRQ_HANDLER(node_id, GPIOTE_NRF_ISR_WRAP_SYM(node_id), NULL)
#ifdef CONFIG_GPIO_NRFX_INTERRUPT
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpiote, GPIOTE_NRF_DEFINE_IRQ_HANDLER);
#endif /* CONFIG_GPIO_NRFX_INTERRUPT */
5 changes: 5 additions & 0 deletions drivers/intc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0

add_subdirectory_ifdef(CONFIG_INTC_ARM_V7M_NVIC intc_arm_v7m_nvic)
add_subdirectory_ifdef(CONFIG_INTC_ARM_V8M_NVIC intc_arm_v8m_nvic)
12 changes: 12 additions & 0 deletions drivers/intc/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2023 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0

menuconfig INTC
bool "INTC (INTerrupt Controller) drivers"

if INTC

rsource "intc_arm_v7m_nvic/Kconfig"
rsource "intc_arm_v8m_nvic/Kconfig"

endif # INTC
7 changes: 7 additions & 0 deletions drivers/intc/intc_arm_v7m_nvic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0

zephyr_library()

zephyr_library_sources(arm_v7m_nvic.c)
zephyr_linker_sources(ROM_START SORT_KEY 0x0vectors irq-vector-table.ld)
7 changes: 7 additions & 0 deletions drivers/intc/intc_arm_v7m_nvic/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0

config INTC_ARM_V7M_NVIC
bool "Arm V7M Nested Vector Interrupt Controller"
default y
depends on DT_HAS_ARM_V7M_NVIC_ENABLED
143 changes: 143 additions & 0 deletions drivers/intc/intc_arm_v7m_nvic/arm_v7m_nvic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
* Copyright (c) 2024 Bjarki Arge Andreasen
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/drivers/intc.h>
#include <zephyr/drivers/intc/intl.h>
#include <cmsis_core.h>
#include <zephyr/sys/barrier.h>
#include <zephyr/arch/cpu.h>
#include <zephyr/linker/sections.h>

#define DT_DRV_COMPAT arm_v7m_nvic

struct intc_arm_v7m_nvic_config {
uint8_t max_irq_priority;
};

#ifdef CONFIG_TRACING_ISR
extern void sys_trace_isr_enter(void);
extern void sys_trace_isr_exit(void);
#endif

#ifdef CONFIG_PM
extern void _arch_isr_direct_pm(void);
#endif

extern void z_arm_int_exit(void);

static inline void arm_v7m_nvic_vector_enter(void)
{
#ifdef CONFIG_TRACING_ISR
sys_trace_isr_enter();
#endif
}

static inline void arm_v7m_nvic_vector_exit(void)
{
#ifdef CONFIG_PM
_arch_isr_direct_pm(void);
#endif

#ifdef CONFIG_TRACING_ISR
sys_trace_isr_exit();
#endif

z_arm_int_exit();
}

static int arm_v7m_nvic_configure_irq(const struct device *dev, uint16_t irq, uint32_t flags)
{
const struct intc_arm_v7m_nvic_config *config = dev->config;

if (flags > config->max_irq_priority) {
return -EINVAL;
}

NVIC_DisableIRQ(irq);
NVIC_ClearPendingIRQ(irq);
NVIC_SetPriority(irq, flags);
return 0;
}

static int arm_v7m_nvic_enable_irq(const struct device *dev, uint16_t irq)
{
ARG_UNUSED(dev);

NVIC_EnableIRQ(irq);
return 0;
}

static int arm_v7m_nvic_disable_irq(const struct device *dev, uint16_t irq)
{
int ret;

ARG_UNUSED(dev);

ret = NVIC_GetEnableIRQ(irq);
NVIC_DisableIRQ(irq);
return ret;
}

static int arm_v7m_nvic_trigger_irq(const struct device *dev, uint16_t irq)
{
ARG_UNUSED(dev);

NVIC_SetPendingIRQ(irq);
return 0;
}

static int arm_v7m_nvic_clear_irq(const struct device *dev, uint16_t irq)
{
int ret;

ARG_UNUSED(dev);

ret = NVIC_GetPendingIRQ(irq);
NVIC_ClearPendingIRQ(irq);
return ret;
}

static const struct intc_driver_api api = {
.configure_irq = arm_v7m_nvic_configure_irq,
.enable_irq = arm_v7m_nvic_enable_irq,
.disable_irq = arm_v7m_nvic_disable_irq,
.trigger_irq = arm_v7m_nvic_trigger_irq,
.clear_irq = arm_v7m_nvic_clear_irq,
};

#define ARM_V7M_NVIC_VECTOR_DEFINE(inst, intln) \
__attribute__((interrupt("IRQ"))) \
__weak void INTC_DT_INST_VECTOR_SYMBOL(inst, intln)(void) \
{ \
arm_v7m_nvic_vector_enter(); \
INTC_DT_INST_INTL_HANDLER_SYMBOL(inst, intln)(); \
arm_v7m_nvic_vector_exit(); \
}

#define ARM_V7M_NVIC_VECTORS_DEFINE(inst) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
INTC_DT_INST_FOREACH_INTL(inst, ARM_V7M_NVIC_VECTOR_DEFINE) \
_Pragma("GCC diagnostic pop")

#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE(inst, intln) \
INTC_DT_INST_VECTOR_SYMBOL(inst, intln)

#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(inst) \
INTC_DT_INST_FOREACH_INTL_SEP(inst, ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE, (,))

ARM_V7M_NVIC_VECTORS_DEFINE(0)

intc_vector_t __irq_vector_table __used _irq_vector_table[] = {
ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(0)
};

Check notice on line 138 in drivers/intc/intc_arm_v7m_nvic/arm_v7m_nvic.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/intc/intc_arm_v7m_nvic/arm_v7m_nvic.c:138 -#define ARM_V7M_NVIC_VECTOR_DEFINE(inst, intln) \ - __attribute__((interrupt("IRQ"))) \ - __weak void INTC_DT_INST_VECTOR_SYMBOL(inst, intln)(void) \ - { \ - arm_v7m_nvic_vector_enter(); \ - INTC_DT_INST_INTL_HANDLER_SYMBOL(inst, intln)(); \ - arm_v7m_nvic_vector_exit(); \ +#define ARM_V7M_NVIC_VECTOR_DEFINE(inst, intln) \ + __attribute__((interrupt("IRQ"))) __weak void INTC_DT_INST_VECTOR_SYMBOL(inst, \ + intln)(void) \ + { \ + arm_v7m_nvic_vector_enter(); \ + INTC_DT_INST_INTL_HANDLER_SYMBOL(inst, intln)(); \ + arm_v7m_nvic_vector_exit(); \ } -#define ARM_V7M_NVIC_VECTORS_DEFINE(inst) \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ - INTC_DT_INST_FOREACH_INTL(inst, ARM_V7M_NVIC_VECTOR_DEFINE) \ - _Pragma("GCC diagnostic pop") +#define ARM_V7M_NVIC_VECTORS_DEFINE(inst) \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ + INTC_DT_INST_FOREACH_INTL(inst, ARM_V7M_NVIC_VECTOR_DEFINE) \ + _Pragma("GCC diagnostic pop") -#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE(inst, intln) \ - INTC_DT_INST_VECTOR_SYMBOL(inst, intln) +#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE(inst, intln) INTC_DT_INST_VECTOR_SYMBOL(inst, intln) -#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(inst) \ - INTC_DT_INST_FOREACH_INTL_SEP(inst, ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE, (,)) +#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(inst) \ + INTC_DT_INST_FOREACH_INTL_SEP(inst, ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE, (, )) ARM_V7M_NVIC_VECTORS_DEFINE(0) intc_vector_t __irq_vector_table __used _irq_vector_table[] = { - ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(0) -}; + ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(0)};

Check notice on line 138 in drivers/intc/intc_arm_v7m_nvic/arm_v7m_nvic.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/intc/intc_arm_v7m_nvic/arm_v7m_nvic.c:138 -#define ARM_V7M_NVIC_VECTOR_DEFINE(inst, intln) \ - __attribute__((interrupt("IRQ"))) \ - __weak void INTC_DT_INST_VECTOR_SYMBOL(inst, intln)(void) \ - { \ - arm_v7m_nvic_vector_enter(); \ - INTC_DT_INST_INTL_HANDLER_SYMBOL(inst, intln)(); \ - arm_v7m_nvic_vector_exit(); \ +#define ARM_V7M_NVIC_VECTOR_DEFINE(inst, intln) \ + __attribute__((interrupt("IRQ"))) __weak void INTC_DT_INST_VECTOR_SYMBOL(inst, \ + intln)(void) \ + { \ + arm_v7m_nvic_vector_enter(); \ + INTC_DT_INST_INTL_HANDLER_SYMBOL(inst, intln)(); \ + arm_v7m_nvic_vector_exit(); \ } -#define ARM_V7M_NVIC_VECTORS_DEFINE(inst) \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ - INTC_DT_INST_FOREACH_INTL(inst, ARM_V7M_NVIC_VECTOR_DEFINE) \ - _Pragma("GCC diagnostic pop") +#define ARM_V7M_NVIC_VECTORS_DEFINE(inst) \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ + INTC_DT_INST_FOREACH_INTL(inst, ARM_V7M_NVIC_VECTOR_DEFINE) \ + _Pragma("GCC diagnostic pop") -#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE(inst, intln) \ - INTC_DT_INST_VECTOR_SYMBOL(inst, intln) +#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE(inst, intln) INTC_DT_INST_VECTOR_SYMBOL(inst, intln) -#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(inst) \ - INTC_DT_INST_FOREACH_INTL_SEP(inst, ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE, (,)) +#define ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(inst) \ + INTC_DT_INST_FOREACH_INTL_SEP(inst, ARM_V7M_NVIC_VECTOR_TABLE_ENTRY_DEFINE, (, )) ARM_V7M_NVIC_VECTORS_DEFINE(0) intc_vector_t __irq_vector_table __used _irq_vector_table[] = { - ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(0) -}; + ARM_V7M_NVIC_VECTOR_TABLE_ENTRIES_DEFINE(0)};
static struct intc_arm_v7m_nvic_config config = {
.max_irq_priority = BIT_MASK(DT_INST_PROP(0, arm_num_irq_priority_bits)),
};

DEVICE_DT_INST_DEFINE(0, NULL, NULL, NULL, &config, PRE_KERNEL_1, 0, &api);
Loading
Loading