annotate cos/kernel/handlers.c @ 410:6aa9743ed362 tip

Reflect change in c3 public modifier
author Windel Bouwman
date Mon, 23 Feb 2015 21:06:04 +0100
parents 24ce177e01e8
children
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 // Assembler wrapper prototypes:
40
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
4 extern void INT255(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
5 extern void INT0(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
6 extern void INT1(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
7 extern void INT2(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
8 extern void INT3(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
9 extern void INT4(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
10 extern void INT5(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
11 extern void INT6(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
12 extern void INT7(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
13 extern void INT8(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
14 extern void INT9(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
15 extern void INT10(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
16 extern void INT11(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
17 extern void INT12(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
18 extern void INT13(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
19 extern void INT14(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
20 extern void INT16(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
21 extern void INT17(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
22 extern void INT18(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
23 extern void INT19(void);
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
24 // Remapped irq assembler wrappers:
40
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
25 extern void INT32(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
26 extern void INT33(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
27 extern void INT34(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
28 extern void INT35(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
29 extern void INT36(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
30 extern void INT37(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
31 extern void INT38(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
32 extern void INT39(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
33 extern void INT40(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
34 extern void INT41(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
35 extern void INT42(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
36 extern void INT43(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
37 extern void INT44(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
38 extern void INT45(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
39 extern void INT46(void);
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
40 extern void INT47(void);
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
41
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
42 // THE interrupt descriptor table:
24
d8627924d40d Split up in more files and reboot command
windel
parents: 23
diff changeset
43 IDT_entry *idt = (IDT_entry*)0x5000;
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
44 volatile idtPointer idtP;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
45
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
46 void setIDTentry(int num, void (*handler)(), uint16_t selector, uint8_t flags)
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
47 {
36
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
48 // Fill one entry with IDT info:
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
49 uint64_t offset;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
50
36
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
51 // Typecast the function pointer to a number:
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
52 offset = (uint64_t)handler;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
53
36
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
54 // Set offset:
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
55 idt[num].baseLow = offset & 0xFFFF;
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
56 idt[num].baseMid = (offset >> 16) & 0xFFFF;
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
57 idt[num].baseHigh = (offset >> 32) & 0xFFFFFFFF;
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
58
36
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
59 // Set flags and selector:
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
60 idt[num].selector = selector;
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
61 idt[num].flags = flags;
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
62
36
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
63 // Set reserved fields:
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
64 idt[num].reserved1 = 0;
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
65 idt[num].reserved2 = 0;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
66 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
67
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
68 void setupIDT(void) {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
69 int i;
26
dcce92b1efbc Added mm.c
windel
parents: 24
diff changeset
70
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
71 // Fill all vectors with the default handler:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
72 for (i=0; i<256; i++) {
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
73 setIDTentry(i, INT255, 0x08, 0x8E);
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
74 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
75
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
76 // Now set other then default handler:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
77 setIDTentry(0, INT0, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
78 setIDTentry(1, INT1, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
79 setIDTentry(2, INT2, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
80 setIDTentry(3, INT3, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
81 setIDTentry(4, INT4, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
82 setIDTentry(5, INT5, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
83 setIDTentry(6, INT6, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
84 setIDTentry(7, INT7, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
85 setIDTentry(8, INT8, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
86 setIDTentry(9, INT9, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
87 setIDTentry(10, INT10, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
88 setIDTentry(11, INT11, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
89 setIDTentry(12, INT12, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
90 setIDTentry(13, INT13, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
91 setIDTentry(14, INT14, 0x08, 0x8E);
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
92 //setIDTentry(15, INT15, 0x08, 0x8E);
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
93 setIDTentry(16, INT16, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
94 setIDTentry(17, INT17, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
95 setIDTentry(18, INT18, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
96 setIDTentry(19, INT19, 0x08, 0x8E);
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
97 /* reserved interrupts: */
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
98 // From int20 - int31
18
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
99 setIDTentry(32, INT32, 0x08, 0x8F);
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
100 setIDTentry(33, INT33, 0x08, 0x8F);
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
101 setIDTentry(34, INT34, 0x08, 0x8F);
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
102 setIDTentry(35, INT35, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
103 setIDTentry(36, INT36, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
104 setIDTentry(37, INT37, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
105 setIDTentry(38, INT38, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
106 setIDTentry(39, INT39, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
107 setIDTentry(40, INT40, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
108 setIDTentry(41, INT41, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
109 setIDTentry(42, INT42, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
110 setIDTentry(43, INT43, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
111 setIDTentry(44, INT44, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
112 setIDTentry(45, INT45, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
113 setIDTentry(46, INT46, 0x08, 0x8F);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
114 setIDTentry(47, INT47, 0x08, 0x8F);
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
115
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
116 // Set the correct values in the IDT pointer:
21
66e9c332c845 Forgot crucial adjustment to idt pointer
windel
parents: 20
diff changeset
117 idtP.base = (uint64_t)idt;
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
118 idtP.limit = (sizeof(IDT_entry) * 256) - 1;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
119 // call load IDT asm function:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
120 loadIDT();
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
121
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
122 PICremap();
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
123 asm("sti");
14
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
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
126 // PIC functions:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
127 void PICremap() {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
128 unsigned char maskmaster, maskslave, pic1, pic2;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
129 pic1 = 0x20; // remapping location master
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
130 pic2 = 0x28;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
131 maskmaster = inb(0x21); // master cmd=0x20, data=0x21
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
132 maskslave = inb(0xA1); // slave command=0xA0, data=0xA1
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
133
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
134 outb(0x20, 0x20); // end of init
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
135
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
136 outb(0x20, 0x11); // init + ICW1_ICW2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
137 outb(0xA0, 0x11); // init + ICW1_ICW2
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 outb(0x21, pic1); // ICW2, write offset
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
140 outb(0xA1, pic2); // ICW2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
141
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
142 outb(0x21, 4); // ICW3, write a 4!
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
143 outb(0xA1, 2); // ICW3, write a 2!
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 outb(0x21, 1); // ICW4, 8086 mode
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
146 outb(0xA1, 1); // ICW4
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
147
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
148 outb(0x21, maskmaster);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
149 outb(0xA1, maskslave);
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
36
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
152 /* Function that prints the contents of all registers
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
153 on the interrupted stack. */
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
154 void display_registers(uint64_t *regs)
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
155 {
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
156 // Pushed by interrupt handler assembler:
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
157 printf("rax: %x\n", regs[6]);
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
158 printf("rbx: %x\n", regs[3]);
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
159 printf("rcx: %x\n", regs[5]);
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
160 printf("rdx: %x\n", regs[4]);
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
161 printf("rsi: %x\n", regs[1]);
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
162 printf("rdi: %x\n", regs[0]);
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
163 printf("rbp: %x\n", regs[2]);
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
164 // Pushed by CPU:
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
165 printf("rip: %x\n", regs[9]);
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
166 }
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
167
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
168 void gp_fault(uint64_t *regs)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
169 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
170 printf("GP fault\n");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
171 printf("Error code: %x\n", regs[8]);
36
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
172 display_registers(regs);
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
173 panic("No resolution to general protection fault!");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
174 }
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
175
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
176 void page_fault(uint64_t *regs)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
177 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
178 printf("Page fault\n");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
179 uint64_t faulting_address;
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
180 asm volatile("mov %%cr2, %0" : "=r" (faulting_address));
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
181 printf("Error code: %x\n", regs[8]);
36
91f91ff07ea8 Removed test variables
windel
parents: 33
diff changeset
182 display_registers(regs);
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
183 printf("Faulting address: %x\n", faulting_address);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
184 panic("No resolution to page fault!");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
185
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
186 }
40
24ce177e01e8 Added more malloc stuff. Added mem usage
windel
parents: 36
diff changeset
187
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
188 // Global isr handler:
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
189 // Hopefully, this function get called with the correct registers.
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
190 void isr_handler(uint64_t* registers)
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
191 {
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
192 uint64_t intnum = registers[7];
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
193
32
3a6a9b929db0 Added initial ramdisk and some virtual file system functions
windel
parents: 31
diff changeset
194 // TODO: make a list with handler pointers:
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
195 if (intnum == 32)
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
196 {
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
197 timerDriverUpdate();
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
198 }
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
199 else if (intnum == 33)
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
200 {
32
3a6a9b929db0 Added initial ramdisk and some virtual file system functions
windel
parents: 31
diff changeset
201 keyboardDriverUpdate();
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
202 }
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
203 else if (intnum == 13)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
204 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
205 gp_fault(registers);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
206 }
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
207 else if (intnum == 14)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
208 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
209 page_fault(registers);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
210 }
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
211 else if (intnum == 39)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
212 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
213 printf("Spurious interrupt\n");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
214 }
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
215 else
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
216 {
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
217 printf("Interrupt %d called, registers at: %x\n", registers[7], registers);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
218 panic("Paniek! Unhandled interrupt!");
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
219 }
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
220
32
3a6a9b929db0 Added initial ramdisk and some virtual file system functions
windel
parents: 31
diff changeset
221 // TODO: EOI to slave?
3a6a9b929db0 Added initial ramdisk and some virtual file system functions
windel
parents: 31
diff changeset
222 // TODO: replace this with APIC code?
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
223 outb(0x20, 0x20); // EOI to master
14
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