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) 2015 Intel corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
11#ifndef ZEPHYR_INCLUDE_IRQ_H_
12#define ZEPHYR_INCLUDE_IRQ_H_
13
14/* Pull in the arch-specific implementations */
15#include <arch/cpu.h>
16
17#ifndef _ASMLANGUAGE
18#include <toolchain.h>
19#include <zephyr/types.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
48#define IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
49 ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p)
50
64static inline int
65irq_connect_dynamic(unsigned int irq, unsigned int priority,
66 void (*routine)(const void *parameter),
67 const void *parameter, uint32_t flags)
68{
69 return arch_irq_connect_dynamic(irq, priority, routine, parameter,
70 flags);
71}
72
111#define IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p) \
112 ARCH_IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p)
113
121#define ISR_DIRECT_HEADER() ARCH_ISR_DIRECT_HEADER()
122
138#define ISR_DIRECT_FOOTER(check_reschedule) \
139 ARCH_ISR_DIRECT_FOOTER(check_reschedule)
140
149#define ISR_DIRECT_PM() ARCH_ISR_DIRECT_PM()
150
180#define ISR_DIRECT_DECLARE(name) ARCH_ISR_DIRECT_DECLARE(name)
181
223#ifdef CONFIG_SMP
224unsigned int z_smp_global_lock(void);
225#define irq_lock() z_smp_global_lock()
226#else
227#define irq_lock() arch_irq_lock()
228#endif
229
253#ifdef CONFIG_SMP
254void z_smp_global_unlock(unsigned int key);
255#define irq_unlock(key) z_smp_global_unlock(key)
256#else
257#define irq_unlock(key) arch_irq_unlock(key)
258#endif
259
270static inline unsigned int irq_get_level(unsigned int irq)
271{
272#if defined(CONFIG_3RD_LEVEL_INTERRUPTS)
273 return ((irq >> 16) & 0xFF) != 0 ? 3 :
274 (((irq >> 8) & 0xFF) == 0 ? 1 : 2);
275#elif defined(CONFIG_2ND_LEVEL_INTERRUPTS)
276 return ((irq >> 8) & 0xFF) == 0 ? 1 : 2;
277#else
278 ARG_UNUSED(irq);
279
280 return 1;
281#endif
282}
283
284#ifdef CONFIG_2ND_LEVEL_INTERRUPTS
296static inline unsigned int irq_from_level_2(unsigned int irq)
297{
298#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
299 return ((irq >> 8) & 0xFF) - 1;
300#else
301 return (irq >> 8) - 1;
302#endif
303}
304
317static inline unsigned int irq_to_level_2(unsigned int irq)
318{
319 return (irq + 1) << 8;
320}
321
332static inline unsigned int irq_parent_level_2(unsigned int irq)
333{
334 return irq & 0xFF;
335}
336#endif
337
338#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
350static inline unsigned int irq_from_level_3(unsigned int irq)
351{
352 return (irq >> 16) - 1;
353}
354
367static inline unsigned int irq_to_level_3(unsigned int irq)
368{
369 return (irq + 1) << 16;
370}
371
382static inline unsigned int irq_parent_level_3(unsigned int irq)
383{
384 return (irq >> 8) & 0xFF;
385}
386#endif
387
397#define irq_enable(irq) arch_irq_enable(irq)
398
408#define irq_disable(irq) arch_irq_disable(irq)
409
419#define irq_is_enabled(irq) arch_irq_is_enabled(irq)
420
425#ifdef __cplusplus
426}
427#endif
428
429#endif /* ASMLANGUAGE */
430#endif /* ZEPHYR_INCLUDE_IRQ_H_ */
int arch_irq_connect_dynamic(unsigned int irq, unsigned int priority, void(*routine)(const void *parameter), const void *parameter, uint32_t flags)
static unsigned int irq_get_level(unsigned int irq)
Definition: irq.h:270
static int irq_connect_dynamic(unsigned int irq, unsigned int priority, void(*routine)(const void *parameter), const void *parameter, uint32_t flags)
Definition: irq.h:65
flags
Definition: http_parser.h:131
static k_spinlock_key_t key
Definition: spinlock_error_case.c:14
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
Macros to abstract toolchain specific capabilities.