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) 2016 Cadence Design Systems, Inc.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#ifndef ZEPHYR_INCLUDE_ARCH_XTENSA_XTENSA_IRQ_H_
7#define ZEPHYR_INCLUDE_ARCH_XTENSA_XTENSA_IRQ_H_
8
9#include <toolchain.h>
10#include <xtensa/config/core-isa.h>
11
12#define CONFIG_GEN_IRQ_START_VECTOR 0
13
14/*
15 * Call this function to enable the specified interrupts.
16 *
17 * mask - Bit mask of interrupts to be enabled.
18 */
19static inline void z_xt_ints_on(unsigned int mask)
20{
21 int val;
22
23 __asm__ volatile("rsr.intenable %0" : "=r"(val));
24 val |= mask;
25 __asm__ volatile("wsr.intenable %0; rsync" : : "r"(val));
26}
27
28
29/*
30 * Call this function to disable the specified interrupts.
31 *
32 * mask - Bit mask of interrupts to be disabled.
33 */
34static inline void z_xt_ints_off(unsigned int mask)
35{
36 int val;
37
38 __asm__ volatile("rsr.intenable %0" : "=r"(val));
39 val &= ~mask;
40 __asm__ volatile("wsr.intenable %0; rsync" : : "r"(val));
41}
42
43/*
44 * Call this function to set the specified (s/w) interrupt.
45 */
46static inline void z_xt_set_intset(unsigned int arg)
47{
48#if XCHAL_HAVE_INTERRUPTS
49 __asm__ volatile("wsr.intset %0; rsync" : : "r"(arg));
50#else
51 ARG_UNUSED(arg);
52#endif
53}
54
55#ifdef CONFIG_MULTI_LEVEL_INTERRUPTS
56
57/* for _soc_irq_*() */
58#include <soc.h>
59
60#ifdef CONFIG_2ND_LEVEL_INTERRUPTS
61#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
62#define CONFIG_NUM_IRQS (XCHAL_NUM_INTERRUPTS +\
63 (CONFIG_NUM_2ND_LEVEL_AGGREGATORS +\
64 CONFIG_NUM_3RD_LEVEL_AGGREGATORS) *\
65 CONFIG_MAX_IRQ_PER_AGGREGATOR)
66#else
67#define CONFIG_NUM_IRQS (XCHAL_NUM_INTERRUPTS +\
68 CONFIG_NUM_2ND_LEVEL_AGGREGATORS *\
69 CONFIG_MAX_IRQ_PER_AGGREGATOR)
70#endif
71#else
72#define CONFIG_NUM_IRQS XCHAL_NUM_INTERRUPTS
73#endif
74
75#define arch_irq_enable(irq) z_soc_irq_enable(irq)
76#define arch_irq_disable(irq) z_soc_irq_disable(irq)
77
78#define arch_irq_is_enabled(irq) z_soc_irq_is_enabled(irq)
79
80#ifdef CONFIG_DYNAMIC_INTERRUPTS
81extern int z_soc_irq_connect_dynamic(unsigned int irq, unsigned int priority,
82 void (*routine)(const void *parameter),
83 const void *parameter, uint32_t flags);
84#endif
85
86#else
87
88#define CONFIG_NUM_IRQS XCHAL_NUM_INTERRUPTS
89
90#define arch_irq_enable(irq) z_xtensa_irq_enable(irq)
91#define arch_irq_disable(irq) z_xtensa_irq_disable(irq)
92
93#define arch_irq_is_enabled(irq) z_xtensa_irq_is_enabled(irq)
94
95#endif
96
97static ALWAYS_INLINE void z_xtensa_irq_enable(uint32_t irq)
98{
99 z_xt_ints_on(1 << irq);
100}
101
102static ALWAYS_INLINE void z_xtensa_irq_disable(uint32_t irq)
103{
104 z_xt_ints_off(1 << irq);
105}
106
107static ALWAYS_INLINE unsigned int arch_irq_lock(void)
108{
109 unsigned int key;
110
111 __asm__ volatile("rsil %0, %1"
112 : "=r"(key) : "i"(XCHAL_EXCM_LEVEL) : "memory");
113 return key;
114}
115
116static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
117{
118 __asm__ volatile("wsr.ps %0; rsync"
119 :: "r"(key) : "memory");
120}
121
122static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
123{
124 return (key & 0xf) == 0; /* INTLEVEL field */
125}
126
127extern int z_xtensa_irq_is_enabled(unsigned int irq);
128
129#include <irq.h>
130
131#endif /* ZEPHYR_INCLUDE_ARCH_XTENSA_XTENSA_IRQ_H_ */
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Definition: irq.h:107
static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
Definition: irq.h:116
static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
Definition: irq.h:122
#define ALWAYS_INLINE
Definition: common.h:116
flags
Definition: http_parser.h:131
Public interface for configuring interrupts.
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.