refactor: add a async read/write variant to device ops, with allow async io to be...
[lunaix-os.git] / lunaix-os / arch / i386 / includes / sys / interrupts.h
1 #ifndef __LUNAIX_INTERRUPTS_H
2 #define __LUNAIX_INTERRUPTS_H
3
4 #include "vectors.h"
5
6 #ifndef __ASM__
7 #include <sys/cpu.h>
8
9 #define saved_fp(isrm) ((isrm)->registers.ebp)
10 #define uspace_context(isrm) (((isrm)->execp->cs) == 0x8)
11
12 struct exec_param;
13
14 struct regcontext
15 {
16     u32_t eax;
17     u32_t ebx;
18     u32_t ecx;
19     u32_t edx;
20     u32_t edi;
21     u32_t ebp;
22     u32_t esi;
23     u32_t ds;
24     u32_t es;
25     u32_t fs;
26     u32_t gs;
27 } __attribute__((packed));
28
29 typedef struct
30 {
31     unsigned int depth;
32     struct regcontext registers;
33     union
34     {
35         u32_t esp;
36         volatile struct exec_param* execp;
37     };
38 } __attribute__((packed)) isr_param;
39
40 struct exec_param
41 {
42     isr_param* saved_prev_ctx;
43     u32_t vector;
44     u32_t err_code;
45     u32_t eip;
46     u32_t cs;
47     u32_t eflags;
48     u32_t esp;
49     u32_t ss;
50 } __attribute__((packed));
51
52 #define ISR_PARAM_SIZE sizeof(isr_param)
53
54 void
55 exception_init();
56
57 #endif
58
59 #endif /* __LUNAIX_INTERRUPTS_H */