refactor: kernel space yield() for controllable, flexible task switching
[lunaix-os.git] / lunaix-os / includes / arch / x86 / interrupts.h
1 #ifndef __LUNAIX_INTERRUPTS_H
2 #define __LUNAIX_INTERRUPTS_H
3
4 #include "vectors.h"
5
6 #ifndef __ASM__
7 #include <hal/cpu.h>
8 typedef struct
9 {
10     struct
11     {
12         reg32 eax;
13         reg32 ebx;
14         reg32 ecx;
15         reg32 edx;
16         reg32 edi;
17         reg32 ebp;
18         reg32 esi;
19         reg32 ds;
20         reg32 es;
21         reg32 fs;
22         reg32 gs;
23         reg32 esp;
24     } registers;
25
26     unsigned int vector;
27     unsigned int err_code;
28     unsigned int eip;
29     unsigned int cs;
30     unsigned int eflags;
31     unsigned int esp;
32     unsigned int ss;
33 } __attribute__((packed)) isr_param;
34
35 typedef void (*int_subscriber)(isr_param*);
36
37 #pragma region ISR_DECLARATION
38
39 #define ISR(iv) void _asm_isr##iv();
40
41 ISR(0)
42 ISR(1)
43 ISR(2)
44 ISR(3)
45 ISR(4)
46 ISR(5)
47 ISR(6)
48 ISR(7)
49 ISR(8)
50 ISR(9)
51 ISR(10)
52 ISR(11)
53 ISR(12)
54 ISR(13)
55 ISR(14)
56 ISR(15)
57 ISR(16)
58 ISR(17)
59 ISR(18)
60 ISR(19)
61 ISR(20)
62 ISR(21)
63
64 ISR(32)
65 ISR(33)
66 ISR(34)
67
68 ISR(201)
69 ISR(202)
70
71 ISR(210)
72
73 ISR(250)
74 ISR(251)
75 ISR(252)
76 ISR(253)
77 ISR(254)
78
79 #pragma endregion
80
81 void
82 intr_subscribe(const uint8_t vector, int_subscriber);
83
84 void
85 intr_unsubscribe(const uint8_t vector, int_subscriber);
86
87 void intr_set_fallback_handler(int_subscriber);
88
89 void
90 intr_handler(isr_param* param);
91
92 void
93 intr_routine_init();
94
95 #endif
96
97 #endif /* __LUNAIX_INTERRUPTS_H */