1 /*
2  * Copyright (c) 2017 Oticon A/S
3  * Copyright (c) 2023 Nordic Semiconductor ASA
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #ifndef _NRF_HW_MODEL_SRC_HW_MODELS_IRQ_CTRL_H
9 #define _NRF_HW_MODEL_SRC_HW_MODELS_IRQ_CTRL_H
10 
11 #include <stdint.h>
12 #include "NHW_common_types.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 void hw_irq_ctrl_clear_all_irqs(unsigned int inst);
19 void hw_irq_ctrl_clear_irq(unsigned int inst, unsigned int irq);
20 void hw_irq_ctrl_reeval_level_irq(unsigned int inst, unsigned int irq);
21 void nhw_irq_controller_set_irq_mask(unsigned int inst, uint64_t mask);
22 void hw_irq_ctrl_enable_irq(unsigned int inst, unsigned int irq);
23 void hw_irq_ctrl_disable_irq(unsigned int inst, unsigned int irq);
24 int hw_irq_ctrl_is_irq_enabled(unsigned int inst, unsigned int irq);
25 void hw_irq_ctrl_raise_im(unsigned int inst, uint32_t irq);
26 void hw_irq_ctrl_set_irq(unsigned int inst, unsigned int irq);
27 void hw_irq_ctrl_raise_level_irq_line(unsigned int inst, unsigned int irq);
28 void hw_irq_ctrl_lower_level_irq_line(unsigned int inst, unsigned int irq);
29 void hw_irq_ctrl_raise_im_from_sw(unsigned int inst, unsigned int irq);
30 uint32_t hw_irq_ctrl_get_current_lock(unsigned int inst);
31 int hw_irq_ctrl_get_highest_prio_irq(unsigned int inst);
32 int hw_irq_ctrl_get_cur_prio(unsigned int inst);
33 void hw_irq_ctrl_set_cur_prio(unsigned int inst, int new);
34 uint8_t hw_irq_ctrl_get_prio(unsigned int inst, unsigned int irq);
35 void hw_irq_ctrl_prio_set(unsigned int inst, unsigned int irq, unsigned int prio);
36 uint32_t hw_irq_ctrl_change_lock(unsigned int inst, uint32_t new_lock);
37 const char *hw_irq_ctrl_get_name(unsigned int inst, unsigned int irq);
38 void hw_irq_ctrl_toggle_level_irq_line_if(bool *int_line,
39                                           bool new_int_line,
40                                           struct nhw_irq_mapping *irq_map);
41 
42 /*
43  * This interrupt will awake the CPU if IRQs are not locked,
44  * This interrupt does not have an associated status bit or handler
45  */
46 #define PHONY_WEAK_IRQ 0xFFFE
47 /*
48  * This interrupt will awake the CPU even if IRQs are locked,
49  * This interrupt does not have an associated status bit or handler
50  * (the lock is only ignored when the interrupt is raised from the HW models,
51  * SW threads should not try to use this)
52  */
53 #define PHONY_HARD_IRQ 0xFFFF
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 #endif /* _NRF_HW_MODEL_SRC_HW_MODELS_IRQ_CTRL_H */
60