Branch data Line data Source code
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 : : #include <zephyr/irq.h>
10 : :
11 : : #ifdef CONFIG_IRQ_OFFLOAD
12 : : #include <zephyr/irq_offload.h>
13 : :
14 : : void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
15 : : {
16 : : posix_irq_offload(routine, parameter);
17 : : }
18 : :
19 : : void arch_irq_offload_init(void)
20 : : {
21 : : /* Nothing to be done for this architecture */
22 : : }
23 : : #endif
24 : :
25 : 1 : void arch_irq_enable(unsigned int irq)
26 : : {
27 : 1 : posix_irq_enable(irq);
28 : 1 : }
29 : :
30 : 0 : void arch_irq_disable(unsigned int irq)
31 : : {
32 : 0 : posix_irq_disable(irq);
33 : 0 : }
34 : :
35 : 0 : int arch_irq_is_enabled(unsigned int irq)
36 : : {
37 : 0 : return posix_irq_is_enabled(irq);
38 : : }
39 : :
40 : : #ifdef CONFIG_ARCH_HAS_IRQ_PENDING_OPS
41 : 0 : void arch_irq_set_pending(unsigned int irq)
42 : : {
43 : 0 : posix_sw_set_pending_IRQ(irq);
44 : 0 : }
45 : :
46 : 0 : void arch_irq_clear_pending(unsigned int irq)
47 : : {
48 : 0 : posix_sw_clear_pending_IRQ(irq);
49 : 0 : }
50 : :
51 : 0 : bool arch_irq_is_pending(unsigned int irq)
52 : : {
53 : 0 : return posix_irq_is_pending(irq);
54 : : }
55 : : #endif /* CONFIG_ARCH_HAS_IRQ_PENDING_OPS */
56 : :
57 : : #ifdef CONFIG_ARCH_HAS_IRQ_GET_ACTIVE
58 : 0 : unsigned int arch_irq_get_active(void)
59 : : {
60 : 0 : int current = posix_get_current_irq();
61 : :
62 [ # # ]: 0 : if (current == -1) {
63 : : return K_IRQ_ACTIVE_NONE;
64 : : } else {
65 : 0 : return current;
66 : : }
67 : : }
68 : : #endif
69 : :
70 : : #ifdef CONFIG_DYNAMIC_INTERRUPTS
71 : : /**
72 : : * Configure a dynamic interrupt.
73 : : *
74 : : * Use this instead of IRQ_CONNECT() if arguments cannot be known at build time.
75 : : *
76 : : * @param irq IRQ line number
77 : : * @param priority Interrupt priority
78 : : * @param routine Interrupt service routine
79 : : * @param parameter ISR parameter
80 : : * @param flags Arch-specific IRQ configuration flags
81 : : *
82 : : * @return The vector assigned to this interrupt
83 : : */
84 : : int arch_irq_connect_dynamic(unsigned int irq, unsigned int priority,
85 : : void (*routine)(const void *parameter),
86 : : const void *parameter, uint32_t flags)
87 : : {
88 : : posix_isr_declare(irq, (int)flags, routine, parameter);
89 : : posix_irq_priority_set(irq, priority, flags);
90 : : return irq;
91 : : }
92 : : #endif /* CONFIG_DYNAMIC_INTERRUPTS */
|