Mercurial > lcfOS
comparison cos/kernel/handlers.c @ 40:24ce177e01e8
Added more malloc stuff. Added mem usage
author | windel |
---|---|
date | Tue, 24 Jan 2012 17:54:16 +0100 |
parents | 91f91ff07ea8 |
children |
comparison
equal
deleted
inserted
replaced
37:5c20bd53cccd | 40:24ce177e01e8 |
---|---|
1 #include "kernel.h" | 1 #include "kernel.h" |
2 | 2 |
3 // Assembler wrapper prototypes: | 3 // Assembler wrapper prototypes: |
4 void INT255(void); | 4 extern void INT255(void); |
5 void INT0(void); | 5 extern void INT0(void); |
6 void INT1(void); | 6 extern void INT1(void); |
7 void INT2(void); | 7 extern void INT2(void); |
8 void INT3(void); | 8 extern void INT3(void); |
9 void INT4(void); | 9 extern void INT4(void); |
10 void INT5(void); | 10 extern void INT5(void); |
11 void INT6(void); | 11 extern void INT6(void); |
12 void INT7(void); | 12 extern void INT7(void); |
13 void INT8(void); | 13 extern void INT8(void); |
14 void INT9(void); | 14 extern void INT9(void); |
15 void INT10(void); | 15 extern void INT10(void); |
16 void INT11(void); | 16 extern void INT11(void); |
17 void INT12(void); | 17 extern void INT12(void); |
18 void INT13(void); | 18 extern void INT13(void); |
19 void INT14(void); | 19 extern void INT14(void); |
20 void INT16(void); | 20 extern void INT16(void); |
21 void INT17(void); | 21 extern void INT17(void); |
22 void INT18(void); | 22 extern void INT18(void); |
23 void INT19(void); | 23 extern void INT19(void); |
24 // Remapped irq assembler wrappers: | 24 // Remapped irq assembler wrappers: |
25 void INT32(void); | 25 extern void INT32(void); |
26 void INT33(void); | 26 extern void INT33(void); |
27 void INT34(void); | 27 extern void INT34(void); |
28 void INT35(void); | 28 extern void INT35(void); |
29 void INT36(void); | 29 extern void INT36(void); |
30 void INT37(void); | 30 extern void INT37(void); |
31 void INT38(void); | 31 extern void INT38(void); |
32 void INT39(void); | 32 extern void INT39(void); |
33 void INT40(void); | 33 extern void INT40(void); |
34 void INT41(void); | 34 extern void INT41(void); |
35 void INT42(void); | 35 extern void INT42(void); |
36 void INT43(void); | 36 extern void INT43(void); |
37 void INT44(void); | 37 extern void INT44(void); |
38 void INT45(void); | 38 extern void INT45(void); |
39 void INT46(void); | 39 extern void INT46(void); |
40 void INT47(void); | 40 extern void INT47(void); |
41 | 41 |
42 // THE interrupt descriptor table: | 42 // THE interrupt descriptor table: |
43 IDT_entry *idt = (IDT_entry*)0x5000; | 43 IDT_entry *idt = (IDT_entry*)0x5000; |
44 volatile idtPointer idtP; | 44 volatile idtPointer idtP; |
45 | 45 |
182 display_registers(regs); | 182 display_registers(regs); |
183 printf("Faulting address: %x\n", faulting_address); | 183 printf("Faulting address: %x\n", faulting_address); |
184 panic("No resolution to page fault!"); | 184 panic("No resolution to page fault!"); |
185 | 185 |
186 } | 186 } |
187 | |
187 // Global isr handler: | 188 // Global isr handler: |
188 | |
189 // Hopefully, this function get called with the correct registers. | 189 // Hopefully, this function get called with the correct registers. |
190 void isr_handler(uint64_t* registers) | 190 void isr_handler(uint64_t* registers) |
191 { | 191 { |
192 uint64_t intnum = registers[7]; | 192 uint64_t intnum = registers[7]; |
193 | 193 |
221 // TODO: EOI to slave? | 221 // TODO: EOI to slave? |
222 // TODO: replace this with APIC code? | 222 // TODO: replace this with APIC code? |
223 outb(0x20, 0x20); // EOI to master | 223 outb(0x20, 0x20); // EOI to master |
224 } | 224 } |
225 | 225 |
226 // Interrupt service routines: | |
227 | |
228 void INT14handler() | |
229 { | |
230 uint64_t faulting_address; | |
231 | |
232 printf("Segfault!\n"); | |
233 | |
234 // Retrieve failed page from CR2: | |
235 asm volatile("mov %%cr2, %0" : "=r" (faulting_address)); | |
236 | |
237 printf("INT14 called! Page fault for address 0x%X!\n", faulting_address); | |
238 | |
239 panic("Unhandled exception!"); | |
240 } | |
241 | |
242 void INT15handler() | |
243 { | |
244 printf("INT15 called!\n"); | |
245 panic("Unhandled exception!"); | |
246 } | |
247 | |
248 void INTDEF_handler() | |
249 { | |
250 panic("Default int handler called\n"); | |
251 } | |
252 |