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_NRF52_BSIM_BOARD_IRQ_H 9 #define BOARDS_POSIX_NRF52_BSIM_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 void nrfbsim_WFE_model(void); 23 void nrfbsim_SEV_model(void); 24 25 /** 26 * Configure a static interrupt. 27 * 28 * @param irq_p IRQ line number 29 * @param priority_p Interrupt priority 30 * @param isr_p Interrupt service routine 31 * @param isr_param_p ISR parameter 32 * @param flags_p IRQ options 33 */ 34 #define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \ 35 { \ 36 posix_isr_declare(irq_p, 0, isr_p, isr_param_p); \ 37 posix_irq_priority_set(irq_p, priority_p, flags_p); \ 38 } 39 40 41 /** 42 * Configure a 'direct' static interrupt. 43 * 44 * See include/irq.h for details. 45 */ 46 #define ARCH_IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p) \ 47 { \ 48 posix_isr_declare(irq_p, ISR_FLAG_DIRECT, \ 49 (void (*)(const void *))isr_p, NULL); \ 50 posix_irq_priority_set(irq_p, priority_p, flags_p); \ 51 } 52 53 /** 54 * POSIX Architecture (board) specific ISR_DIRECT_DECLARE(), 55 * See include/irq.h for more information. 56 * 57 * The return of "name##_body(void)" is the indication of the interrupt 58 * (maybe) having caused a kernel decision to context switch 59 * 60 * Note that this convention is changed relative to the ARM and x86 archs 61 * 62 * All pre/post irq work of the interrupt is handled in the board 63 * posix_irq_handler() both for direct and normal interrupts together 64 */ 65 #define ARCH_ISR_DIRECT_DECLARE(name) \ 66 static inline int name##_body(void); \ 67 int name(void) \ 68 { \ 69 int check_reschedule; \ 70 check_reschedule = name##_body(); \ 71 return check_reschedule; \ 72 } \ 73 static inline int name##_body(void) 74 75 #define ARCH_ISR_DIRECT_HEADER() do { } while (false) 76 #define ARCH_ISR_DIRECT_FOOTER(a) do { } while (false) 77 78 #ifdef CONFIG_PM 79 extern void posix_irq_check_idle_exit(void); 80 #define ARCH_ISR_DIRECT_PM() posix_irq_check_idle_exit() 81 #else 82 #define ARCH_ISR_DIRECT_PM() do { } while (false) 83 #endif 84 85 #define IRQ_ZERO_LATENCY BIT(1) /* Unused in this board*/ 86 87 #ifdef __cplusplus 88 } 89 #endif 90 91 #endif /* BOARDS_POSIX_NRF52_BSIM_BOARD_IRQ_H */ 92