Zephyr Project API  3.2.0
A Scalable Open Source RTOS
irq.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Wind River Systems, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
14#ifndef ZEPHYR_INCLUDE_ARCH_ARC_V2_IRQ_H_
15#define ZEPHYR_INCLUDE_ARCH_ARC_V2_IRQ_H_
16
19#include <zephyr/irq.h>
20#include <zephyr/sys/util.h>
21#include <zephyr/sw_isr_table.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#ifndef _ASMLANGUAGE
28
29extern void z_arc_firq_stack_set(void);
30extern void arch_irq_enable(unsigned int irq);
31extern void arch_irq_disable(unsigned int irq);
32extern int arch_irq_is_enabled(unsigned int irq);
33#ifdef CONFIG_TRACING_ISR
34extern void sys_trace_isr_enter(void);
35extern void sys_trace_isr_exit(void);
36#endif
37
38extern void z_irq_priority_set(unsigned int irq, unsigned int prio,
40
41/* Z_ISR_DECLARE will populate the .intList section with the interrupt's
42 * parameters, which will then be used by gen_irq_tables.py to create
43 * the vector table and the software ISR table. This is all done at
44 * build-time.
45 *
46 * We additionally set the priority in the interrupt controller at
47 * runtime.
48 */
49#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
50{ \
51 Z_ISR_DECLARE(irq_p, 0, isr_p, isr_param_p); \
52 z_irq_priority_set(irq_p, priority_p, flags_p); \
53}
54
76#define ARCH_IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p) \
77{ \
78 Z_ISR_DECLARE(irq_p, ISR_FLAG_DIRECT, isr_p, NULL); \
79 BUILD_ASSERT(priority_p || !IS_ENABLED(CONFIG_ARC_FIRQ) || \
80 (IS_ENABLED(CONFIG_ARC_FIRQ_STACK) && \
81 !IS_ENABLED(CONFIG_ARC_STACK_CHECKING)), \
82 "irq priority cannot be set to 0 when CONFIG_ARC_FIRQ_STACK" \
83 "is not configured or CONFIG_ARC_FIRQ_STACK " \
84 "and CONFIG_ARC_STACK_CHECKING are configured together"); \
85 z_irq_priority_set(irq_p, priority_p, flags_p); \
86}
87
88
89static inline void arch_isr_direct_header(void)
90{
91#ifdef CONFIG_TRACING_ISR
93#endif
94}
95
96static inline void arch_isr_direct_footer(int maybe_swap)
97{
98 /* clear SW generated interrupt */
99 if (z_arc_v2_aux_reg_read(_ARC_V2_ICAUSE) ==
100 z_arc_v2_aux_reg_read(_ARC_V2_AUX_IRQ_HINT)) {
101 z_arc_v2_aux_reg_write(_ARC_V2_AUX_IRQ_HINT, 0);
102 }
103#ifdef CONFIG_TRACING_ISR
105#endif
106}
107
108#define ARCH_ISR_DIRECT_HEADER() arch_isr_direct_header()
109extern void arch_isr_direct_header(void);
110
111#define ARCH_ISR_DIRECT_FOOTER(swap) arch_isr_direct_footer(swap)
112
113#if defined(__CCAC__)
114#define _ARC_DIRECT_ISR_FUNC_ATTRIBUTE __interrupt__
115#else
116#define _ARC_DIRECT_ISR_FUNC_ATTRIBUTE interrupt("ilink")
117#endif
118
119/*
120 * Scheduling can not be done in direct isr. If required, please use kernel
121 * aware interrupt handling
122 */
123#define ARCH_ISR_DIRECT_DECLARE(name) \
124 static inline int name##_body(void); \
125 __attribute__ ((_ARC_DIRECT_ISR_FUNC_ATTRIBUTE))void name(void) \
126 { \
127 ISR_DIRECT_HEADER(); \
128 name##_body(); \
129 ISR_DIRECT_FOOTER(0); \
130 } \
131 static inline int name##_body(void)
132
133
166static ALWAYS_INLINE unsigned int arch_irq_lock(void)
167{
168 unsigned int key;
169
170 __asm__ volatile("clri %0" : "=r"(key):: "memory");
171 return key;
172}
173
174static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
175{
176 __asm__ volatile("seti %0" : : "ir"(key) : "memory");
177}
178
179static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
180{
181 /* ARC irq lock uses instruction "clri r0",
182 * r0 == {26’d0, 1’b1, STATUS32.IE, STATUS32.E[3:0] }
183 * bit4 is used to record IE (Interrupt Enable) bit
184 */
185 return (key & 0x10) == 0x10;
186}
187
188#endif /* _ASMLANGUAGE */
189
190#ifdef __cplusplus
191}
192#endif
193
194#endif /* ZEPHYR_INCLUDE_ARCH_ARC_V2_IRQ_H_ */
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Disable all interrupts on the local CPU.
Definition: irq.h:166
static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
Definition: irq.h:174
void arch_irq_disable(unsigned int irq)
int arch_irq_is_enabled(unsigned int irq)
static void arch_isr_direct_header(void)
Definition: irq.h:89
static void arch_isr_direct_footer(int maybe_swap)
Definition: irq.h:96
void arch_irq_enable(unsigned int irq)
static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
Definition: irq.h:179
ARCv2 auxiliary registers definitions.
Common toolchain abstraction.
#define ALWAYS_INLINE
Definition: common.h:124
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.
static k_spinlock_key_t key
Definition: spinlock_error_case.c:14
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
Software-managed ISR table.
Misc utilities.