Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
irq.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2014 Wind River Systems, Inc.
3 * Copyright (c) 2019 Nordic Semiconductor ASA.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
16#ifndef ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_IRQ_H_
17#define ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_IRQ_H_
18
19#include <zephyr/sw_isr_table.h>
20#include <stdbool.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#ifdef _ASMLANGUAGE
27GTEXT(z_arm_int_exit);
28GTEXT(arch_irq_enable)
31#if defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER)
32GTEXT(z_soc_irq_get_active)
33GTEXT(z_soc_irq_eoi)
34#endif /* CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER */
35#else
36
37#if !defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER)
38
39extern void arch_irq_enable(unsigned int irq);
40extern void arch_irq_disable(unsigned int irq);
41extern int arch_irq_is_enabled(unsigned int irq);
42
43/* internal routine documented in C file, needed by IRQ_CONNECT() macro */
44extern void z_arm_irq_priority_set(unsigned int irq, unsigned int prio,
46
47#else
48
49/*
50 * When a custom interrupt controller is specified, map the architecture
51 * interrupt control functions to the SoC layer interrupt control functions.
52 */
53
54void z_soc_irq_init(void);
55void z_soc_irq_enable(unsigned int irq);
56void z_soc_irq_disable(unsigned int irq);
57int z_soc_irq_is_enabled(unsigned int irq);
58
59void z_soc_irq_priority_set(
60 unsigned int irq, unsigned int prio, unsigned int flags);
61
62unsigned int z_soc_irq_get_active(void);
63void z_soc_irq_eoi(unsigned int irq);
64
65#define arch_irq_enable(irq) z_soc_irq_enable(irq)
66#define arch_irq_disable(irq) z_soc_irq_disable(irq)
67#define arch_irq_is_enabled(irq) z_soc_irq_is_enabled(irq)
68
69#define z_arm_irq_priority_set(irq, prio, flags) \
70 z_soc_irq_priority_set(irq, prio, flags)
71
72#endif /* !CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER */
73
74extern void z_arm_int_exit(void);
75
76extern void z_arm_interrupt_init(void);
77
78/* macros convert value of its argument to a string */
79#define DO_TOSTR(s) #s
80#define TOSTR(s) DO_TOSTR(s)
81
82/* concatenate the values of the arguments into one */
83#define DO_CONCAT(x, y) x ## y
84#define CONCAT(x, y) DO_CONCAT(x, y)
85
86/* Flags for use with IRQ_CONNECT() */
94#define IRQ_ZERO_LATENCY BIT(0)
95
96#ifdef CONFIG_CPU_CORTEX_M
97
98#if defined(CONFIG_ZERO_LATENCY_LEVELS)
99#define ZERO_LATENCY_LEVELS CONFIG_ZERO_LATENCY_LEVELS
100#else
101#define ZERO_LATENCY_LEVELS 1
102#endif
103
104#define _CHECK_PRIO(priority_p, flags_p) \
105 BUILD_ASSERT(((flags_p & IRQ_ZERO_LATENCY) && \
106 ((ZERO_LATENCY_LEVELS == 1) || \
107 (priority_p < ZERO_LATENCY_LEVELS))) || \
108 (priority_p <= IRQ_PRIO_LOWEST), \
109 "Invalid interrupt priority. Values must not exceed IRQ_PRIO_LOWEST");
110#else
111#define _CHECK_PRIO(priority_p, flags_p)
112#endif
113
114/* All arguments must be computable by the compiler at build time.
115 *
116 * Z_ISR_DECLARE will populate the .intList section with the interrupt's
117 * parameters, which will then be used by gen_irq_tables.py to create
118 * the vector table and the software ISR table. This is all done at
119 * build-time.
120 *
121 * We additionally set the priority in the interrupt controller at
122 * runtime.
123 */
124#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
125{ \
126 BUILD_ASSERT(IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS) || !(flags_p & IRQ_ZERO_LATENCY), \
127 "ZLI interrupt registered but feature is disabled"); \
128 _CHECK_PRIO(priority_p, flags_p) \
129 Z_ISR_DECLARE(irq_p, 0, isr_p, isr_param_p); \
130 z_arm_irq_priority_set(irq_p, priority_p, flags_p); \
131}
132
133#define ARCH_IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p) \
134{ \
135 BUILD_ASSERT(IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS) || !(flags_p & IRQ_ZERO_LATENCY), \
136 "ZLI interrupt registered but feature is disabled"); \
137 _CHECK_PRIO(priority_p, flags_p) \
138 Z_ISR_DECLARE(irq_p, ISR_FLAG_DIRECT, isr_p, NULL); \
139 z_arm_irq_priority_set(irq_p, priority_p, flags_p); \
140}
141
142#ifdef CONFIG_PM
143extern void _arch_isr_direct_pm(void);
144#define ARCH_ISR_DIRECT_PM() _arch_isr_direct_pm()
145#else
146#define ARCH_ISR_DIRECT_PM() do { } while (false)
147#endif
148
149#define ARCH_ISR_DIRECT_HEADER() arch_isr_direct_header()
150#define ARCH_ISR_DIRECT_FOOTER(swap) arch_isr_direct_footer(swap)
151
152/* arch/arm/core/exc_exit.S */
153extern void z_arm_int_exit(void);
154
155#ifdef CONFIG_TRACING_ISR
156extern void sys_trace_isr_enter(void);
157extern void sys_trace_isr_exit(void);
158#endif
159
160static inline void arch_isr_direct_header(void)
161{
162#ifdef CONFIG_TRACING_ISR
164#endif
165}
166
167static inline void arch_isr_direct_footer(int maybe_swap)
168{
169#ifdef CONFIG_TRACING_ISR
171#endif
172 if (maybe_swap != 0) {
173 z_arm_int_exit();
174 }
175}
176
177#define ARCH_ISR_DIRECT_DECLARE(name) \
178 static inline int name##_body(void); \
179 _Pragma("GCC diagnostic push") \
180 _Pragma("GCC diagnostic ignored \"-Wattributes\"") \
181 __attribute__ ((interrupt ("IRQ"))) void name(void) \
182 { \
183 int check_reschedule; \
184 ISR_DIRECT_HEADER(); \
185 check_reschedule = name##_body(); \
186 ISR_DIRECT_FOOTER(check_reschedule); \
187 } \
188 _Pragma("GCC diagnostic pop") \
189 static inline int name##_body(void)
190
191#if defined(CONFIG_DYNAMIC_DIRECT_INTERRUPTS)
192
193extern void z_arm_irq_direct_dynamic_dispatch_reschedule(void);
194extern void z_arm_irq_direct_dynamic_dispatch_no_reschedule(void);
195
242#define ARM_IRQ_DIRECT_DYNAMIC_CONNECT(irq_p, priority_p, flags_p, resch) \
243 IRQ_DIRECT_CONNECT(irq_p, priority_p, \
244 CONCAT(z_arm_irq_direct_dynamic_dispatch_, resch), flags_p)
245
246#endif /* CONFIG_DYNAMIC_DIRECT_INTERRUPTS */
247
248#if defined(CONFIG_ARM_SECURE_FIRMWARE)
249/* Architecture-specific definition for the target security
250 * state of an NVIC IRQ line.
251 */
252typedef enum {
253 IRQ_TARGET_STATE_SECURE = 0,
254 IRQ_TARGET_STATE_NON_SECURE
255} irq_target_state_t;
256
257#endif /* CONFIG_ARM_SECURE_FIRMWARE */
258
259#endif /* _ASMLANGUAGE */
260
261#ifdef __cplusplus
262}
263#endif
264
265#endif /* ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_IRQ_H_ */
static void arch_isr_direct_header(void)
Definition: irq.h:91
static void arch_isr_direct_footer(int maybe_swap)
Definition: irq.h:98
#define arch_irq_disable(irq)
Definition: irq.h:98
#define arch_irq_enable(irq)
Definition: irq.h:97
#define arch_irq_is_enabled(irq)
Definition: irq.h:100
void sys_trace_isr_enter(void)
Called when entering an ISR.
void sys_trace_isr_exit(void)
Called when exiting an ISR.
flags
Definition: parser.h:96
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
Software-managed ISR table.