feat: support user-spcae pci rescan
[lunaix-os.git] / lunaix-os / includes / lunaix / isrm.h
1 /**
2  * @file irqm.h
3  * @author Lunaixsky
4  * @brief ISR Manager, managing the interrupt service routine allocations
5  * @version 0.1
6  * @date 2022-10-18
7  *
8  * @copyright Copyright (c) 2022
9  *
10  */
11 #ifndef __LUNAIX_ISRM_H
12 #define __LUNAIX_ISRM_H
13
14 #include <lunaix/types.h>
15 #include <sys/interrupts.h>
16
17 typedef void (*isr_cb)(const isr_param*);
18
19 void
20 isrm_init();
21
22 /**
23  * @brief Release a iv resource
24  *
25  * @param iv
26  */
27 void
28 isrm_ivfree(int iv);
29
30 /**
31  * @brief Allocate an iv resource for os services
32  *
33  * @param iv
34  */
35 int
36 isrm_ivosalloc(isr_cb handler);
37
38 /**
39  * @brief Allocate an iv resource for external events
40  *
41  * @param iv
42  */
43 int
44 isrm_ivexalloc(isr_cb handler);
45
46 /**
47  * @brief Bind a given irq and associated handler to an iv
48  *
49  * @param iv iv allocated by system
50  */
51 int
52 isrm_bindirq(int irq, isr_cb irq_handler);
53
54 /**
55  * @brief Bind given iv with it's associated handler
56  *
57  * @param iv
58  * @param handler
59  */
60 void
61 isrm_bindiv(int iv, isr_cb handler);
62
63 /**
64  * @brief Get the handler associated with the given iv
65  *
66  * @param iv
67  * @return isr_cb
68  */
69 isr_cb
70 isrm_get(int iv);
71
72 ptr_t
73 isrm_get_payload(const isr_param*);
74
75 void
76 isrm_set_payload(int iv, ptr_t);
77
78 #endif /* __LUNAIX_ISRM_H */