2015-04-10 16:44:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013-2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
2015-12-04 10:09:39 -05:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Cortex-M public interrupt handling
|
|
|
|
*
|
2016-12-23 07:32:56 -05:00
|
|
|
* ARM-specific kernel interrupt handling interface. Included by arm/arch.h.
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2019-11-09 18:48:15 +00:00
|
|
|
#ifndef ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_IRQ_H_
|
|
|
|
#define ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_IRQ_H_
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-02-25 13:21:02 -08:00
|
|
|
#include <irq.h>
|
2015-06-11 13:52:00 -04:00
|
|
|
#include <sw_isr_table.h>
|
2018-09-18 12:32:27 -07:00
|
|
|
#include <stdbool.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-01-22 12:38:49 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#ifdef _ASMLANGUAGE
|
2019-09-30 12:31:07 -07:00
|
|
|
GTEXT(z_arm_int_exit);
|
2019-11-07 12:43:29 -08:00
|
|
|
GTEXT(arch_irq_enable)
|
|
|
|
GTEXT(arch_irq_disable)
|
|
|
|
GTEXT(arch_irq_is_enabled)
|
2015-04-10 16:44:37 -07:00
|
|
|
#else
|
2019-11-07 12:43:29 -08:00
|
|
|
extern void arch_irq_enable(unsigned int irq);
|
|
|
|
extern void arch_irq_disable(unsigned int irq);
|
|
|
|
extern int arch_irq_is_enabled(unsigned int irq);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2019-09-30 12:31:07 -07:00
|
|
|
extern void z_arm_int_exit(void);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2018-06-25 09:15:14 -04:00
|
|
|
#if defined(CONFIG_ARMV7_R)
|
2019-09-30 12:31:07 -07:00
|
|
|
static ALWAYS_INLINE void z_arm_int_lib_init(void)
|
2018-06-25 09:15:14 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#else
|
2019-09-30 12:31:07 -07:00
|
|
|
extern void z_arm_int_lib_init(void);
|
2018-06-25 09:15:14 -04:00
|
|
|
#endif
|
|
|
|
|
2015-06-11 13:52:00 -04:00
|
|
|
/* macros convert value of it's argument to a string */
|
|
|
|
#define DO_TOSTR(s) #s
|
|
|
|
#define TOSTR(s) DO_TOSTR(s)
|
|
|
|
|
|
|
|
/* concatenate the values of the arguments into one */
|
|
|
|
#define DO_CONCAT(x, y) x ## y
|
|
|
|
#define CONCAT(x, y) DO_CONCAT(x, y)
|
|
|
|
|
2016-01-27 10:07:31 -08:00
|
|
|
/* internal routine documented in C file, needed by IRQ_CONNECT() macro */
|
2019-09-30 12:31:07 -07:00
|
|
|
extern void z_arm_irq_priority_set(unsigned int irq, unsigned int prio,
|
|
|
|
u32_t flags);
|
2016-02-04 13:55:57 -08:00
|
|
|
|
|
|
|
|
2016-09-22 11:20:26 -07:00
|
|
|
/* Flags for use with IRQ_CONNECT() */
|
2019-05-15 11:13:59 -04:00
|
|
|
#ifdef CONFIG_ZERO_LATENCY_IRQS
|
2016-02-04 13:55:57 -08:00
|
|
|
/**
|
|
|
|
* Set this interrupt up as a zero-latency IRQ. It has a fixed hardware
|
|
|
|
* priority level (discarding what was supplied in the interrupt's priority
|
|
|
|
* argument), and will run even if irq_lock() is active. Be careful!
|
|
|
|
*/
|
2019-03-08 12:35:46 -08:00
|
|
|
#define IRQ_ZERO_LATENCY BIT(0)
|
2016-02-04 13:55:57 -08:00
|
|
|
#endif
|
2016-01-08 00:46:14 -08:00
|
|
|
|
|
|
|
|
2019-10-03 10:08:13 -07:00
|
|
|
/* All arguments must be computable by the compiler at build time.
|
2015-06-11 13:52:00 -04:00
|
|
|
*
|
2019-03-08 14:19:05 -07:00
|
|
|
* Z_ISR_DECLARE will populate the .intList section with the interrupt's
|
2017-02-08 17:49:51 -08:00
|
|
|
* parameters, which will then be used by gen_irq_tables.py to create
|
|
|
|
* the vector table and the software ISR table. This is all done at
|
|
|
|
* build-time.
|
2015-06-11 13:52:00 -04:00
|
|
|
*
|
2017-02-08 17:49:51 -08:00
|
|
|
* We additionally set the priority in the interrupt controller at
|
|
|
|
* runtime.
|
2015-06-11 13:52:00 -04:00
|
|
|
*/
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
|
2016-01-08 00:46:14 -08:00
|
|
|
({ \
|
2019-03-08 14:19:05 -07:00
|
|
|
Z_ISR_DECLARE(irq_p, 0, isr_p, isr_param_p); \
|
2019-09-30 12:31:07 -07:00
|
|
|
z_arm_irq_priority_set(irq_p, priority_p, flags_p); \
|
2016-01-08 00:46:14 -08:00
|
|
|
irq_p; \
|
|
|
|
})
|
2015-06-11 13:52:00 -04:00
|
|
|
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p) \
|
2017-02-09 12:40:08 -08:00
|
|
|
({ \
|
2019-03-08 14:19:05 -07:00
|
|
|
Z_ISR_DECLARE(irq_p, ISR_FLAG_DIRECT, isr_p, NULL); \
|
2019-09-30 12:31:07 -07:00
|
|
|
z_arm_irq_priority_set(irq_p, priority_p, flags_p); \
|
2017-02-09 12:40:08 -08:00
|
|
|
irq_p; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
|
|
|
extern void _arch_isr_direct_pm(void);
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_ISR_DIRECT_PM() _arch_isr_direct_pm()
|
2017-02-09 12:40:08 -08:00
|
|
|
#else
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_ISR_DIRECT_PM() do { } while (false)
|
2017-02-09 12:40:08 -08:00
|
|
|
#endif
|
|
|
|
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_ISR_DIRECT_HEADER() arch_isr_direct_header()
|
|
|
|
#define ARCH_ISR_DIRECT_FOOTER(swap) arch_isr_direct_footer(swap)
|
2017-02-09 12:40:08 -08:00
|
|
|
|
2019-11-09 17:49:36 +00:00
|
|
|
/* arch/arm/core/aarch32/exc_exit.S */
|
2019-09-30 12:31:07 -07:00
|
|
|
extern void z_arm_int_exit(void);
|
2017-02-09 12:40:08 -08:00
|
|
|
|
2018-07-04 08:03:03 -05:00
|
|
|
#ifdef CONFIG_TRACING
|
2019-11-08 09:33:47 +09:00
|
|
|
extern void sys_trace_isr_enter(void);
|
2019-09-19 09:25:19 +02:00
|
|
|
extern void sys_trace_isr_exit(void);
|
2018-07-04 08:03:03 -05:00
|
|
|
#endif
|
|
|
|
|
2019-11-08 09:33:47 +09:00
|
|
|
static inline void arch_isr_direct_header(void)
|
2017-02-09 12:40:08 -08:00
|
|
|
{
|
2019-11-08 09:33:47 +09:00
|
|
|
#ifdef CONFIG_TRACING
|
|
|
|
sys_trace_isr_enter();
|
|
|
|
#endif
|
|
|
|
}
|
2018-07-04 08:03:03 -05:00
|
|
|
|
2019-11-08 09:33:47 +09:00
|
|
|
static inline void arch_isr_direct_footer(int maybe_swap)
|
|
|
|
{
|
2018-07-04 08:03:03 -05:00
|
|
|
#ifdef CONFIG_TRACING
|
2019-09-19 09:25:19 +02:00
|
|
|
sys_trace_isr_exit();
|
2018-07-04 08:03:03 -05:00
|
|
|
#endif
|
2018-11-06 14:50:48 +01:00
|
|
|
if (maybe_swap) {
|
2019-09-30 12:31:07 -07:00
|
|
|
z_arm_int_exit();
|
2017-02-09 12:40:08 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_ISR_DIRECT_DECLARE(name) \
|
2017-02-09 12:40:08 -08:00
|
|
|
static inline int name##_body(void); \
|
|
|
|
__attribute__ ((interrupt ("IRQ"))) void name(void) \
|
|
|
|
{ \
|
|
|
|
int check_reschedule; \
|
|
|
|
ISR_DIRECT_HEADER(); \
|
|
|
|
check_reschedule = name##_body(); \
|
|
|
|
ISR_DIRECT_FOOTER(check_reschedule); \
|
|
|
|
} \
|
|
|
|
static inline int name##_body(void)
|
|
|
|
|
2017-02-08 17:49:51 -08:00
|
|
|
/* Spurious interrupt handler. Throws an error if called */
|
2019-03-08 14:19:05 -07:00
|
|
|
extern void z_irq_spurious(void *unused);
|
2017-02-08 17:49:51 -08:00
|
|
|
|
|
|
|
#ifdef CONFIG_GEN_SW_ISR_TABLE
|
|
|
|
/* Architecture-specific common entry point for interrupts from the vector
|
|
|
|
* table. Most likely implemented in assembly. Looks up the correct handler
|
|
|
|
* and parameter from the _sw_isr_table and executes it.
|
|
|
|
*/
|
|
|
|
extern void _isr_wrapper(void);
|
|
|
|
#endif
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
2016-01-22 12:38:49 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-11-09 18:48:15 +00:00
|
|
|
#endif /* ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_IRQ_H_ */
|