1 /*
2 * Copyright (c) 2019 Carlo Caione <ccaione@baylibre.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 /**
8 * @file
9 * @brief ARM64 Cortex-A interrupt management
10 */
11
12 #include <zephyr/kernel.h>
13 #include <zephyr/arch/cpu.h>
14 #include <zephyr/tracing/tracing.h>
15 #include <zephyr/irq.h>
16 #include <zephyr/toolchain.h>
17 #include <zephyr/linker/sections.h>
18 #include <zephyr/sw_isr_table.h>
19 #include <zephyr/drivers/interrupt_controller/gic.h>
20
21 void z_arm64_fatal_error(unsigned int reason, struct arch_esf *esf);
22
23 #if !defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER)
24 /*
25 * The default interrupt controller for AArch64 is the ARM Generic Interrupt
26 * Controller (GIC) and therefore the architecture interrupt control functions
27 * are mapped to the GIC driver interface.
28 *
29 * When a custom interrupt controller is used (i.e.
30 * CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER is enabled), the architecture
31 * interrupt control functions are mapped to the SoC layer in
32 * `include/arch/arm64/irq.h`.
33 */
34
arch_irq_enable(unsigned int irq)35 void arch_irq_enable(unsigned int irq)
36 {
37 arm_gic_irq_enable(irq);
38 }
39
arch_irq_disable(unsigned int irq)40 void arch_irq_disable(unsigned int irq)
41 {
42 arm_gic_irq_disable(irq);
43 }
44
arch_irq_is_enabled(unsigned int irq)45 int arch_irq_is_enabled(unsigned int irq)
46 {
47 return arm_gic_irq_is_enabled(irq);
48 }
49
z_arm64_irq_priority_set(unsigned int irq,unsigned int prio,uint32_t flags)50 void z_arm64_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
51 {
52 arm_gic_irq_set_priority(irq, prio, flags);
53 }
54 #endif /* !CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER */
55
56 #ifdef CONFIG_DYNAMIC_INTERRUPTS
arch_irq_connect_dynamic(unsigned int irq,unsigned int priority,void (* routine)(const void * parameter),const void * parameter,uint32_t flags)57 int arch_irq_connect_dynamic(unsigned int irq, unsigned int priority,
58 void (*routine)(const void *parameter),
59 const void *parameter, uint32_t flags)
60 {
61 z_isr_install(irq, routine, parameter);
62 z_arm64_irq_priority_set(irq, priority, flags);
63 return irq;
64 }
65 #endif
66
z_irq_spurious(const void * unused)67 void z_irq_spurious(const void *unused)
68 {
69 ARG_UNUSED(unused);
70
71 z_arm64_fatal_error(K_ERR_SPURIOUS_IRQ, NULL);
72 }
73