1 /*
2  * Copyright (c) 2019 Oticon A/S
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/arch/posix/posix_soc_if.h>
8 #include "board_irq.h"
9 
10 #ifdef CONFIG_IRQ_OFFLOAD
11 #include <zephyr/irq_offload.h>
12 
arch_irq_offload(irq_offload_routine_t routine,const void * parameter)13 void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
14 {
15 	posix_irq_offload(routine, parameter);
16 }
17 
arch_irq_offload_init(void)18 void arch_irq_offload_init(void)
19 {
20 }
21 #endif
22 
arch_irq_enable(unsigned int irq)23 void arch_irq_enable(unsigned int irq)
24 {
25 	posix_irq_enable(irq);
26 }
27 
arch_irq_disable(unsigned int irq)28 void arch_irq_disable(unsigned int irq)
29 {
30 	posix_irq_disable(irq);
31 }
32 
arch_irq_is_enabled(unsigned int irq)33 int arch_irq_is_enabled(unsigned int irq)
34 {
35 	return posix_irq_is_enabled(irq);
36 }
37 
38 #ifdef CONFIG_DYNAMIC_INTERRUPTS
39 /**
40  * Configure a dynamic interrupt.
41  *
42  * Use this instead of IRQ_CONNECT() if arguments cannot be known at build time.
43  *
44  * @param irq IRQ line number
45  * @param priority Interrupt priority
46  * @param routine Interrupt service routine
47  * @param parameter ISR parameter
48  * @param flags Arch-specific IRQ configuration flags
49  *
50  * @return The vector assigned to this interrupt
51  */
arch_irq_connect_dynamic(unsigned int irq,unsigned int priority,void (* routine)(const void * parameter),const void * parameter,uint32_t flags)52 int arch_irq_connect_dynamic(unsigned int irq, unsigned int priority,
53 			     void (*routine)(const void *parameter),
54 			     const void *parameter, uint32_t flags)
55 {
56 	posix_isr_declare(irq, (int)flags, routine, parameter);
57 	posix_irq_priority_set(irq, priority, flags);
58 	return irq;
59 }
60 #endif /* CONFIG_DYNAMIC_INTERRUPTS */
61