Zephyr API Documentation  2.7.0-rc2
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 <irq.h>
20#include <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 it's 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() */
93#define IRQ_ZERO_LATENCY BIT(0)
94
95#ifdef CONFIG_CPU_CORTEX_M
96#define _CHECK_PRIO(priority_p, flags_p) \
97 BUILD_ASSERT((flags_p & IRQ_ZERO_LATENCY) || \
98 priority_p <= IRQ_PRIO_LOWEST, \
99 "Invalid interrupt priority. Values must not exceed IRQ_PRIO_LOWEST");
100#else
101#define _CHECK_PRIO(priority_p, flags_p)
102#endif
103
104/* All arguments must be computable by the compiler at build time.
105 *
106 * Z_ISR_DECLARE will populate the .intList section with the interrupt's
107 * parameters, which will then be used by gen_irq_tables.py to create
108 * the vector table and the software ISR table. This is all done at
109 * build-time.
110 *
111 * We additionally set the priority in the interrupt controller at
112 * runtime.
113 */
114#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
115{ \
116 BUILD_ASSERT(IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS) || !(flags_p & IRQ_ZERO_LATENCY), \
117 "ZLI interrupt registered but feature is disabled"); \
118 _CHECK_PRIO(priority_p, flags_p) \
119 Z_ISR_DECLARE(irq_p, 0, isr_p, isr_param_p); \
120 z_arm_irq_priority_set(irq_p, priority_p, flags_p); \
121}
122
123#define ARCH_IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p) \
124{ \
125 BUILD_ASSERT(IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS) || !(flags_p & IRQ_ZERO_LATENCY), \
126 "ZLI interrupt registered but feature is disabled"); \
127 _CHECK_PRIO(priority_p, flags_p) \
128 Z_ISR_DECLARE(irq_p, ISR_FLAG_DIRECT, isr_p, NULL); \
129 z_arm_irq_priority_set(irq_p, priority_p, flags_p); \
130}
131
132#ifdef CONFIG_PM
133extern void _arch_isr_direct_pm(void);
134#define ARCH_ISR_DIRECT_PM() _arch_isr_direct_pm()
135#else
136#define ARCH_ISR_DIRECT_PM() do { } while (false)
137#endif
138
139#define ARCH_ISR_DIRECT_HEADER() arch_isr_direct_header()
140#define ARCH_ISR_DIRECT_FOOTER(swap) arch_isr_direct_footer(swap)
141
142/* arch/arm/core/aarch32/exc_exit.S */
143extern void z_arm_int_exit(void);
144
145#ifdef CONFIG_TRACING_ISR
146extern void sys_trace_isr_enter(void);
147extern void sys_trace_isr_exit(void);
148#endif
149
150static inline void arch_isr_direct_header(void)
151{
152#ifdef CONFIG_TRACING_ISR
154#endif
155}
156
157static inline void arch_isr_direct_footer(int maybe_swap)
158{
159#ifdef CONFIG_TRACING_ISR
161#endif
162 if (maybe_swap != 0) {
163 z_arm_int_exit();
164 }
165}
166
167#define ARCH_ISR_DIRECT_DECLARE(name) \
168 static inline int name##_body(void); \
169 __attribute__ ((interrupt ("IRQ"))) void name(void) \
170 { \
171 int check_reschedule; \
172 ISR_DIRECT_HEADER(); \
173 check_reschedule = name##_body(); \
174 ISR_DIRECT_FOOTER(check_reschedule); \
175 } \
176 static inline int name##_body(void)
177
178#if defined(CONFIG_DYNAMIC_DIRECT_INTERRUPTS)
179
180extern void z_arm_irq_direct_dynamic_dispatch_reschedule(void);
181extern void z_arm_irq_direct_dynamic_dispatch_no_reschedule(void);
182
229#define ARM_IRQ_DIRECT_DYNAMIC_CONNECT(irq_p, priority_p, flags_p, resch) \
230 IRQ_DIRECT_CONNECT(irq_p, priority_p, \
231 CONCAT(z_arm_irq_direct_dynamic_dispatch_, resch), flags_p)
232
233#endif /* CONFIG_DYNAMIC_DIRECT_INTERRUPTS */
234
235/* Spurious interrupt handler. Throws an error if called */
236extern void z_irq_spurious(const void *unused);
237
238#ifdef CONFIG_GEN_SW_ISR_TABLE
239/* Architecture-specific common entry point for interrupts from the vector
240 * table. Most likely implemented in assembly. Looks up the correct handler
241 * and parameter from the _sw_isr_table and executes it.
242 */
243extern void _isr_wrapper(void);
244#endif
245
246#if defined(CONFIG_ARM_SECURE_FIRMWARE)
247/* Architecture-specific definition for the target security
248 * state of an NVIC IRQ line.
249 */
250typedef enum {
251 IRQ_TARGET_STATE_SECURE = 0,
252 IRQ_TARGET_STATE_NON_SECURE
253} irq_target_state_t;
254
255#endif /* CONFIG_ARM_SECURE_FIRMWARE */
256
257#endif /* _ASMLANGUAGE */
258
259#ifdef __cplusplus
260}
261#endif
262
263#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:157
static void arch_isr_direct_header(void)
Definition: irq.h:150
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:60
Software-managed ISR table.