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