annotate cos/kernel/handlers.c @ 33:d8185ddb6c7b

Added more interrupt handlers
author windel
date Sun, 15 Jan 2012 13:39:49 +0100
parents 3a6a9b929db0
children 91f91ff07ea8
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:
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
4 void INT255(void);
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
5 void INT0(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
6 void INT1(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
7 void INT2(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
8 void INT3(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
9 void INT4(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
10 void INT5(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
11 void INT6(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
12 void INT7(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
13 void INT8(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
14 void INT9(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
15 void INT10(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
16 void INT11(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
17 void INT12(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
18 void INT13(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
19 void INT14(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
20 void INT16(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
21 void INT17(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
22 void INT18(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
23 void INT19(void);
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
24 // Remapped irq assembler wrappers:
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
25 void INT32(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
26 void INT33(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
27 void INT34(void);
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
28 void INT35(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
29 void INT36(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
30 void INT37(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
31 void INT38(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
32 void INT39(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
33 void INT40(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
34 void INT41(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
35 void INT42(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
36 void INT43(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
37 void INT44(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
38 void INT45(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
39 void INT46(void);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
40 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 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
48 // Fill one entry with IDT info:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
49 uint64_t offset;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
50
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
51 // Typecast the function pointer to a number:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
52 offset = (uint64_t)handler;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
53
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
54 // Set offset:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
55 idt[num].baseLow = offset & 0xFFFF;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
56 idt[num].baseMid = (offset >> 16) & 0xFFFF;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
57 idt[num].baseHigh = (offset >> 32) & 0xFFFFFFFF;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
58
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
59 // Set flags and selector:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
60 idt[num].selector = selector;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
61 idt[num].flags = flags;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
62
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
63 // Set reserved fields:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
64 idt[num].reserved1 = 0;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
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
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
152 void gp_fault(uint64_t *regs)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
153 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
154 printf("GP fault\n");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
155 printf("Error code: %x\n", regs[8]);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
156 printf("RIP: %x\n", regs[9]);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
157 panic("No resolution to general protection fault!");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
158 }
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
159
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
160 void page_fault(uint64_t *regs)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
161 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
162 printf("Page fault\n");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
163 uint64_t faulting_address;
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
164 asm volatile("mov %%cr2, %0" : "=r" (faulting_address));
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
165 printf("Error code: %x\n", regs[8]);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
166 printf("RIP: %x\n", regs[9]);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
167 printf("Faulting address: %x\n", faulting_address);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
168 panic("No resolution to page fault!");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
169
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
170 }
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
171 // Global isr handler:
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
172
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
173 // Hopefully, this function get called with the correct registers.
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
174 void isr_handler(uint64_t* registers)
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
175 {
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
176 uint64_t intnum = registers[7];
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
177
32
3a6a9b929db0 Added initial ramdisk and some virtual file system functions
windel
parents: 31
diff changeset
178 // TODO: make a list with handler pointers:
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
179 if (intnum == 32)
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
180 {
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
181 timerDriverUpdate();
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
182 }
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
183 else if (intnum == 33)
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
184 {
32
3a6a9b929db0 Added initial ramdisk and some virtual file system functions
windel
parents: 31
diff changeset
185 keyboardDriverUpdate();
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
186 }
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
187 else if (intnum == 13)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
188 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
189 gp_fault(registers);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
190 }
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
191 else if (intnum == 14)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
192 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
193 page_fault(registers);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
194 }
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
195 else if (intnum == 39)
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
196 {
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
197 printf("Spurious interrupt\n");
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
198 }
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
199 else
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
200 {
33
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
201 printf("Interrupt %d called, registers at: %x\n", registers[7], registers);
d8185ddb6c7b Added more interrupt handlers
windel
parents: 32
diff changeset
202 panic("Paniek! Unhandled interrupt!");
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
203 }
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
204
32
3a6a9b929db0 Added initial ramdisk and some virtual file system functions
windel
parents: 31
diff changeset
205 // TODO: EOI to slave?
3a6a9b929db0 Added initial ramdisk and some virtual file system functions
windel
parents: 31
diff changeset
206 // TODO: replace this with APIC code?
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
207 outb(0x20, 0x20); // EOI to master
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
208 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
209
31
88590c42320f Changed interrupt handler
windel
parents: 30
diff changeset
210 // Interrupt service routines:
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
211
20
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
212 void INT14handler()
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
213 {
20
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
214 uint64_t faulting_address;
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
215
29
7e3bdcb391dc Added get_page function to mm
windel
parents: 26
diff changeset
216 printf("Segfault!\n");
7e3bdcb391dc Added get_page function to mm
windel
parents: 26
diff changeset
217
20
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
218 // Retrieve failed page from CR2:
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
219 asm volatile("mov %%cr2, %0" : "=r" (faulting_address));
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
220
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
221 printf("INT14 called! Page fault for address 0x%X!\n", faulting_address);
14
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 panic("Unhandled exception!");
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 INT15handler()
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("INT15 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
229 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
230 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
231
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
232 void INTDEF_handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
233 {
29
7e3bdcb391dc Added get_page function to mm
windel
parents: 26
diff changeset
234 panic("Default int handler called\n");
14
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