annotate cos/kernel/handlers.c @ 14:a58904747019

Added asm interrupt handler things, not yet working
author windel
date Mon, 14 Nov 2011 22:45:55 +0100
parents
children f3e3e0e9c4bc
rev   line source
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
1 #include "kernel.h"
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
3 void panic(char *msg) {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
4 printf("Kernel panic: ");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
5 printf(msg);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
6 halt();
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
7 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
8
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
9 // Assembler wrapper prototypes:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
10 void INTDEF(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
11 void INT0(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
12 void INT1(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
13 void INT2(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
14 void INT3(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
15 void INT4(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
16 void INT5(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
17 void INT6(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
18 void INT7(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
19 void INT8(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
20 void INT9(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
21 void INT10(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
22 void INT11(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
23 void INT12(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
24 void INT13(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
25 void INT14(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
26 void INT15(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
27 void INT16(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
28 void INT17(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
29 void INT18(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
30 void INT19(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
31 // Remapped handlers:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
32 void INT32(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
33 void INT33(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
34 void INT34(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
35
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
36 // THE interrupt descriptor table:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
37 static struct IDT_entry idt[256];
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
38
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
39 void setIDTentry(int num, void (*handler)())
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
40 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
41 // Fill one entry with IDT info:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
42 uint64_t offset;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
43 unsigned short selector = 0x8; // Code selector
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
44 unsigned char type = 0x8E; // 32 bits interrupt gate. Thingy is present
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
45
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
46 offset = (uint64_t) handler;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
47
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
48 idt[num].b[0] = offset & 0xFF;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
49 idt[num].b[1] = (offset >> 8) & 0xFF;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
50 idt[num].b[2] = selector & 0xFF;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
51 idt[num].b[3] = (selector >> 8) & 0xFF;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
52 idt[num].b[4] = 0; // reserved
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
53 idt[num].b[5] = type;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
54 idt[num].b[6] = (offset >> 16) & 0xFF;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
55 idt[num].b[7] = (offset >> 24) & 0xFF;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
56 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
57
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
58 void setupIDT(void) {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
59 int i;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
60 // Fill all vectors with the default handler:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
61 for (i=0; i<256; i++) {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
62 setIDTentry(i, &INTDEF);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
63 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
64
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
65 // Now set other then default handler:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
66 setIDTentry(0, INT0);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
67 setIDTentry(1, INT1);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
68 setIDTentry(2, INT2);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
69 setIDTentry(3, INT3);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
70 setIDTentry(4, INT4);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
71 setIDTentry(5, INT5);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
72 setIDTentry(6, INT6);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
73 setIDTentry(7, INT7);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
74 setIDTentry(8, INT8);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
75 setIDTentry(9, INT9);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
76 setIDTentry(10, INT10);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
77 setIDTentry(11, INT11);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
78 setIDTentry(12, INT12);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
79 setIDTentry(13, INT13);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
80 setIDTentry(14, INT14);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
81 setIDTentry(15, INT15);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
82 setIDTentry(16, INT16);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
83 setIDTentry(17, INT17);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
84 setIDTentry(18, INT18);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
85 setIDTentry(19, INT19);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
86 /* reserved interrupts: */
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
87 // From int20 - int31
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
88 setIDTentry(32, INT32);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
89 setIDTentry(33, INT33);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
90 setIDTentry(34, INT34);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
91
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
92 // call load IDT asm function:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
93 loadIDT(idt, 256*8-1);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
94
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
95 PICremap();
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
96 enableinterrupts();
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
97 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
98
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
99 // PIC functions:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
100 void PICremap() {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
101 unsigned char maskmaster, maskslave, pic1, pic2;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
102 pic1 = 0x20; // remapping location master
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
103 pic2 = 0x28;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
104 maskmaster = inb(0x21); // master cmd=0x20, data=0x21
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
105 maskslave = inb(0xA1); // slave command=0xA0, data=0xA1
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
106
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
107 outb(0x20, 0x20); // end of init
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
108
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
109 outb(0x20, 0x11); // init + ICW1_ICW2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
110 outb(0xA0, 0x11); // init + ICW1_ICW2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
111
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
112 outb(0x21, pic1); // ICW2, write offset
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
113 outb(0xA1, pic2); // ICW2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
114
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
115 outb(0x21, 4); // ICW3, write a 4!
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
116 outb(0xA1, 2); // ICW3, write a 2!
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
117
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
118 outb(0x21, 1); // ICW4, 8086 mode
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
119 outb(0xA1, 1); // ICW4
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
120
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
121 outb(0x21, maskmaster);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
122 outb(0xA1, maskslave);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
123 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
124
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
125 // Interrupt service routines:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
126
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
127 void INT0handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
128 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
129 printf("INT0 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
130 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
131 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
132
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
133 void INT1handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
134 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
135 printf("INT1 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
136 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
137 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
138
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
139 void INT2handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
140 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
141 printf("INT2 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
142 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
143 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
144
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
145 void INT3handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
146 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
147 printf("INT3 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
148 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
149 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
150
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
151 void INT4handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
152 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
153 printf("INT4 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
154 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
155 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
156
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
157 void INT5handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
158 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
159 printf("INT5 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
160 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
161 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
162
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
163 void INT6handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
164 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
165 printf("INT6 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
166 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
167 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
168
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
169 void INT7handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
170 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
171 printf("INT7 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
172 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
173 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
174
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
175 void INT8handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
176 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
177 printf("INT8 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
178 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
179 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
180
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
181 void INT9handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
182 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
183 printf("INT9 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
184 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
185 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
186
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
187 void INT10handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
188 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
189 printf("INT10 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
190 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
191 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
192
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
193 void INT11handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
194 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
195 printf("INT11 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
196 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
197 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
198
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
199 void INT12handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
200 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
201 printf("INT12 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
202 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
203 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
204
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
205 void INT13handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
206 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
207 printf("INT13 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
208 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
209 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
210
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
211 void* getUnusedPage() {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
212 return 0;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
213
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
214 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
215
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
216 void mappage(uint32_t address) {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
217 uint32_t pageDirIndex = address >> 22;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
218 uint32_t pageTableIndex = (address >> 12) & 0x3FF;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
219
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
220 printf("Allocating page at %d, tableindex=%d\n", pageDirIndex, pageTableIndex);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
221 //uint32_t *pageTable = (uint32_t*)(pageDirectory[pageDirIndex] & 0xFFFFFC00);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
222
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
223
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
224 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
225
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
226 void INT14handler(unsigned int address)
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
227 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
228 printf("INT14 called! Page fault for address 0x%x!\n", address);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
229 if ( (address & 0xF0000000) == 0xD0000000 ) {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
230 mappage(address & 0xFFFFF000);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
231 return;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
232 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
233
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
234 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
235 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
236
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
237 void INT15handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
238 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
239 printf("INT15 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
240 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
241 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
242
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
243 void INT16handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
244 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
245 printf("INT16 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
246 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
247 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
248
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
249 void INT17handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
250 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
251 printf("INT17 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
252 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
253 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
254
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
255 void INT18handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
256 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
257 printf("INT18 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
258 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
259 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
260
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
261 void INT19handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
262 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
263 printf("INT19 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
264 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
265 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
266
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
267 // remapped IRQ from master PIC:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
268 void INT32handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
269 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
270 // System timer.
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
271 //printf("INT32 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
272 // called very frequent, what is this?
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
273 timerDriverUpdate();
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
274 outb(0x20, 0x20); // EOI to master
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
275 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
276
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
277 void INT33handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
278 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
279 //printf("INT33 called, key pressed????\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
280 unsigned char scancode = inb(0x60);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
281 //printf("Scancode = 0x%x\n", scancode);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
282 keyboardDriverUpdate(scancode);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
283 outb(0x20, 0x20); // EOI to master
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
284 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
285
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
286 void INT34handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
287 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
288 printf("INT34 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
289 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
290
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
291 void INTDEF_handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
292 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
293 printf("Default int handler called\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
294 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
295
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
296