1 /* 2 * Copyright (c) 2013-2014 Wind River Systems, Inc. 3 * Copyright (c) 2017 Oticon A/S 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #ifndef BOARDS_POSIX_COMMON_BOARD_IRQ_H 9 #define BOARDS_POSIX_COMMON_BOARD_IRQ_H 10 11 #include <zephyr/sw_isr_table.h> 12 #include <zephyr/types.h> 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 void posix_isr_declare(unsigned int irq_p, int flags, void isr_p(const void *), 19 const void *isr_param_p); 20 void posix_irq_priority_set(unsigned int irq, unsigned int prio, 21 uint32_t flags); 22 23 /** 24 * Configure a static interrupt. 25 * 26 * @param irq_p IRQ line number 27 * @param priority_p Interrupt priority 28 * @param isr_p Interrupt service routine 29 * @param isr_param_p ISR parameter 30 * @param flags_p IRQ options 31 */ 32 #define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \ 33 { \ 34 posix_isr_declare(irq_p, 0, isr_p, isr_param_p); \ 35 posix_irq_priority_set(irq_p, priority_p, flags_p); \ 36 } 37 38 39 /** 40 * Configure a 'direct' static interrupt. 41 * 42 * See include/irq.h for details. 43 */ 44 #define ARCH_IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p) \ 45 { \ 46 posix_isr_declare(irq_p, ISR_FLAG_DIRECT, \ 47 (void (*)(const void *))isr_p, NULL); \ 48 posix_irq_priority_set(irq_p, priority_p, flags_p); \ 49 } 50 51 /** 52 * POSIX Architecture (board) specific ISR_DIRECT_DECLARE(), 53 * See include/irq.h for more information. 54 * 55 * The return of "name##_body(void)" is the indication of the interrupt 56 * (maybe) having caused a kernel decision to context switch 57 * 58 * Note that this convention is changed relative to the ARM and x86 archs 59 * 60 * All pre/post irq work of the interrupt is handled in the board 61 * posix_irq_handler() both for direct and normal interrupts together 62 */ 63 #define ARCH_ISR_DIRECT_DECLARE(name) \ 64 static inline int name##_body(void); \ 65 int name(void) \ 66 { \ 67 int check_reschedule; \ 68 check_reschedule = name##_body(); \ 69 return check_reschedule; \ 70 } \ 71 static inline int name##_body(void) 72 73 #define ARCH_ISR_DIRECT_HEADER() do { } while (false) 74 #define ARCH_ISR_DIRECT_FOOTER(a) do { } while (false) 75 76 #ifdef CONFIG_PM 77 extern void posix_irq_check_idle_exit(void); 78 #define ARCH_ISR_DIRECT_PM() posix_irq_check_idle_exit() 79 #else 80 #define ARCH_ISR_DIRECT_PM() do { } while (false) 81 #endif 82 83 #ifdef __cplusplus 84 } 85 #endif 86 87 #endif /* BOARDS_POSIX_COMMON_BOARD_IRQ_H */ 88