Zephyr Project API  3.2.0
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 <zephyr/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 /* CONFIG_3RD_LEVEL_INTERRUPTS */
71#else
72#define CONFIG_NUM_IRQS XCHAL_NUM_INTERRUPTS
73#endif /* CONFIG_2ND_LEVEL_INTERRUPTS */
74
75void z_soc_irq_init(void);
76void z_soc_irq_enable(unsigned int irq);
77void z_soc_irq_disable(unsigned int irq);
78int z_soc_irq_is_enabled(unsigned int irq);
79
80#define arch_irq_enable(irq) z_soc_irq_enable(irq)
81#define arch_irq_disable(irq) z_soc_irq_disable(irq)
82
83#define arch_irq_is_enabled(irq) z_soc_irq_is_enabled(irq)
84
85#ifdef CONFIG_DYNAMIC_INTERRUPTS
86extern int z_soc_irq_connect_dynamic(unsigned int irq, unsigned int priority,
87 void (*routine)(const void *parameter),
88 const void *parameter, uint32_t flags);
89#endif
90
91#else
92
93#define CONFIG_NUM_IRQS XCHAL_NUM_INTERRUPTS
94
95#define arch_irq_enable(irq) z_xtensa_irq_enable(irq)
96#define arch_irq_disable(irq) z_xtensa_irq_disable(irq)
97
98#define arch_irq_is_enabled(irq) z_xtensa_irq_is_enabled(irq)
99
100#endif
101
102static ALWAYS_INLINE void z_xtensa_irq_enable(uint32_t irq)
103{
104 z_xt_ints_on(1 << irq);
105}
106
107static ALWAYS_INLINE void z_xtensa_irq_disable(uint32_t irq)
108{
109 z_xt_ints_off(1 << irq);
110}
111
112static ALWAYS_INLINE unsigned int arch_irq_lock(void)
113{
114 unsigned int key;
115
116 __asm__ volatile("rsil %0, %1"
117 : "=r"(key) : "i"(XCHAL_EXCM_LEVEL) : "memory");
118 return key;
119}
120
121static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
122{
123 __asm__ volatile("wsr.ps %0; rsync"
124 :: "r"(key) : "memory");
125}
126
127static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
128{
129 return (key & 0xf) == 0; /* INTLEVEL field */
130}
131
132extern int z_xtensa_irq_is_enabled(unsigned int irq);
133
134#include <zephyr/irq.h>
135
136#endif /* ZEPHYR_INCLUDE_ARCH_XTENSA_XTENSA_IRQ_H_ */
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Definition: irq.h:112
static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
Definition: irq.h:121
static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
Definition: irq.h:127
#define ALWAYS_INLINE
Definition: common.h:124
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:90
Macros to abstract toolchain specific capabilities.