POK(kernelpart)
interrupt.h
Go to the documentation of this file.
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 
18 #ifndef __POK_INTERRUPT_H__
19 #define __POK_INTERRUPT_H__
20 
21 
22 #include <types.h>
23 
24 typedef struct
25 {
36 
37  /* These are pushed by interrupt */
38  uint32_t error; /* Error code or padding */
42 
43  /* Only pushed with privilege switch */
44  /* (Check cs content to have original CPL) */
48 
49 extern uint32_t pok_tss;
50 
51 void update_tss (interrupt_frame* frame);
52 
53 #define INTERRUPT_HANDLER(name) \
54 void name (void); \
55 void name##_handler(interrupt_frame* frame); \
56  asm ( \
57  ".global "#name " \n" \
58  "\t.type "#name",@function \n" \
59  #name": \n" \
60  "cli \n" \
61  "subl $4, %esp \n" \
62  "pusha \n" \
63  "push %ds \n" \
64  "push %es \n" \
65  "push %esp \n" \
66  "mov $0x10, %ax \n" \
67  "mov %ax, %ds \n" \
68  "mov %ax, %es \n" \
69  "call " #name"_handler \n" \
70  "call update_tss \n" \
71  "addl $4, %esp \n" \
72  "pop %es \n" \
73  "pop %ds \n" \
74  "popa \n" \
75  "addl $4, %esp \n" \
76  "sti \n" \
77  "iret \n" \
78  ); \
79 void name##_handler(interrupt_frame* frame)
80 
81 #define INTERRUPT_HANDLER_errorcode(name) \
82 void name (void); \
83 void name##_handler(interrupt_frame* frame); \
84  asm ( \
85  ".global "#name " \n" \
86  "\t.type "#name",@function \n" \
87  #name": \n" \
88  "cli \n" \
89  "pusha \n" \
90  "push %ds \n" \
91  "push %es \n" \
92  "push %esp \n" \
93  "mov $0x10, %ax \n" \
94  "mov %ax, %ds \n" \
95  "mov %ax, %es \n" \
96  "call " #name"_handler \n" \
97  "call update_tss \n" \
98  "addl $4, %esp \n" \
99  "pop %es \n" \
100  "pop %ds \n" \
101  "popa \n" \
102  "addl $4, %esp \n" \
103  "sti \n" \
104  "iret \n" \
105  ); \
106 void name##_handler(interrupt_frame* frame)
107 
108 #define INTERRUPT_HANDLER_syscall(name) \
109 int name (void); \
110 void name##_handler(interrupt_frame* frame); \
111  asm ( \
112  ".global "#name " \n" \
113  "\t.type "#name",@function \n" \
114  #name": \n" \
115  "cli \n" \
116  "subl $4, %esp \n" \
117  "pusha \n" \
118  "push %ds \n" \
119  "push %es \n" \
120  "push %esp \n" \
121  "mov $0x10, %ax \n" \
122  "mov %ax, %ds \n" \
123  "mov %ax, %es \n" \
124  "call " #name"_handler \n" \
125  "movl %eax, 40(%esp) \n" /* return value */ \
126  "call update_tss \n" \
127  "addl $4, %esp \n" \
128  "pop %es \n" \
129  "pop %ds \n" \
130  "popa \n" \
131  "addl $4, %esp \n" \
132  "sti \n" \
133  "iret \n" \
134  ); \
135 void name##_handler(interrupt_frame* frame)
136 
137 
138 #endif /* !__POK_INTERRUPT_H__ */