annotate cos/kernel/handlers.c @ 21:66e9c332c845

Forgot crucial adjustment to idt pointer
author windel
date Tue, 29 Nov 2011 19:32:31 +0100
parents b1fed2171e1a
children 5dd47d6eebac
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);
18
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
6 magicBochsBreak();
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
7 halt();
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
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
10 // Assembler wrapper prototypes:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
11 void INTDEF(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
12 void INT0(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
13 void INT1(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
14 void INT2(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
15 void INT3(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
16 void INT4(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
17 void INT5(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
18 void INT6(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
19 void INT7(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
20 void INT8(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
21 void INT9(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
22 void INT10(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
23 void INT11(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
24 void INT12(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
25 void INT13(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
26 void INT14(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
27 void INT15(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
28 void INT16(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
29 void INT17(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
30 void INT18(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
31 void INT19(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
32 // Remapped handlers:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
33 void INT32(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
34 void INT33(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
35 void INT34(void);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
36
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
37 // THE interrupt descriptor table:
20
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
38 IDT_entry *idt = (IDT_entry*)0x0;
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
39 volatile idtPointer idtP;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
40
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
41 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
42 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
43 // Fill one entry with IDT info:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
44 uint64_t offset;
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 // Typecast the function pointer to a number:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
47 offset = (uint64_t)handler;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
48
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
49 // Set offset:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
50 idt[num].baseLow = offset & 0xFFFF;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
51 idt[num].baseMid = (offset >> 16) & 0xFFFF;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
52 idt[num].baseHigh = (offset >> 32) & 0xFFFFFFFF;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
53
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
54 // Set flags and selector:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
55 idt[num].selector = selector;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
56 idt[num].flags = flags;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
57
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
58 // Set reserved fields:
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
59 idt[num].reserved1 = 0;
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
60 idt[num].reserved2 = 0;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
61 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
62
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
63 void setupIDT(void) {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
64 int i;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
65 // Fill all vectors with the default handler:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
66 for (i=0; i<256; i++) {
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
67 setIDTentry(i, &INTDEF, 0x08, 0x8E);
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
68 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
69
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
70 // Now set other then default handler:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
71 setIDTentry(0, INT0, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
72 setIDTentry(1, INT1, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
73 setIDTentry(2, INT2, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
74 setIDTentry(3, INT3, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
75 setIDTentry(4, INT4, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
76 setIDTentry(5, INT5, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
77 setIDTentry(6, INT6, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
78 setIDTentry(7, INT7, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
79 setIDTentry(8, INT8, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
80 setIDTentry(9, INT9, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
81 setIDTentry(10, INT10, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
82 setIDTentry(11, INT11, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
83 setIDTentry(12, INT12, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
84 setIDTentry(13, INT13, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
85 setIDTentry(14, INT14, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
86 setIDTentry(15, INT15, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
87 setIDTentry(16, INT16, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
88 setIDTentry(17, INT17, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
89 setIDTentry(18, INT18, 0x08, 0x8E);
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
90 setIDTentry(19, INT19, 0x08, 0x8E);
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
91 /* reserved interrupts: */
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
92 // From int20 - int31
18
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
93 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
94 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
95 setIDTentry(34, INT34, 0x08, 0x8F);
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
96
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
97 // Set the correct values in the IDT pointer:
21
66e9c332c845 Forgot crucial adjustment to idt pointer
windel
parents: 20
diff changeset
98 idtP.base = (uint64_t)idt;
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
99 idtP.limit = (sizeof(IDT_entry) * 256) - 1;
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
100 // call load IDT asm function:
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
101 loadIDT();
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
102
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
103 PICremap();
18
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
104 magicBochsBreak();
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
105 printf("enable ints\n");
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
106 asm("sti");
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
107 printf("Done!\n");
14
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
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
110 // PIC functions:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
111 void PICremap() {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
112 unsigned char maskmaster, maskslave, pic1, pic2;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
113 pic1 = 0x20; // remapping location master
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
114 pic2 = 0x28;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
115 maskmaster = inb(0x21); // master cmd=0x20, data=0x21
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
116 maskslave = inb(0xA1); // slave command=0xA0, data=0xA1
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(0x20, 0x20); // end of init
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
119
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
120 outb(0x20, 0x11); // init + ICW1_ICW2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
121 outb(0xA0, 0x11); // init + ICW1_ICW2
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
122
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
123 outb(0x21, pic1); // ICW2, write offset
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
124 outb(0xA1, pic2); // ICW2
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 outb(0x21, 4); // ICW3, write a 4!
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
127 outb(0xA1, 2); // ICW3, write a 2!
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 outb(0x21, 1); // ICW4, 8086 mode
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
130 outb(0xA1, 1); // ICW4
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 outb(0x21, maskmaster);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
133 outb(0xA1, maskslave);
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
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
136 // Interrupt service routines:
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 void INT0handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
139 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
140 printf("INT0 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
141 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
142 }
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 void INT1handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
145 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
146 printf("INT1 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
147 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
148 }
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 void INT2handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
151 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
152 printf("INT2 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
153 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
154 }
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 void INT3handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
157 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
158 printf("INT3 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
159 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
160 }
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 void INT4handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
163 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
164 printf("INT4 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
165 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
166 }
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 void INT5handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
169 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
170 printf("INT5 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
171 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
172 }
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 void INT6handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
175 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
176 printf("INT6 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
177 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
178 }
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 void INT7handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
181 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
182 printf("INT7 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
183 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
184 }
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 void INT8handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
187 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
188 printf("INT8 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
189 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
190 }
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 void INT9handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
193 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
194 printf("INT9 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
195 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
196 }
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 void INT10handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
199 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
200 printf("INT10 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
201 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
202 }
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 void INT11handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
205 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
206 printf("INT11 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
207 panic("Unhandled exception!");
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
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
210 void INT12handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
211 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
212 printf("INT12 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
213 panic("Unhandled exception!");
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 INT13handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
217 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
218 printf("INT13 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
219 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
220 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
221
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
222 void* getUnusedPage()
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
223 {
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
224 return 0;
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
17
f3e3e0e9c4bc First attempt IDT loader 64 bits. INT13 occurs
windel
parents: 14
diff changeset
227 void mappage(uint64_t address) {
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
228 uint32_t pageDirIndex = address >> 22;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
229 uint32_t pageTableIndex = (address >> 12) & 0x3FF;
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 printf("Allocating page at %d, tableindex=%d\n", pageDirIndex, pageTableIndex);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
232 //uint32_t *pageTable = (uint32_t*)(pageDirectory[pageDirIndex] & 0xFFFFFC00);
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
20
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
235 void INT14handler()
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
236 {
20
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
237 uint64_t faulting_address;
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
238
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
239 // Retrieve failed page from CR2:
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
240 asm volatile("mov %%cr2, %0" : "=r" (faulting_address));
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
241
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
242 printf("INT14 called! Page fault for address 0x%X!\n", faulting_address);
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
243 if ( (faulting_address & 0xF0000000) == 0xD0000000 ) {
b1fed2171e1a Now working with 2 MB pages
windel
parents: 18
diff changeset
244 mappage(faulting_address & 0xFFFFF000);
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
245 return;
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
246 }
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 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
249 }
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 void INT15handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
252 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
253 printf("INT15 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
254 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
255 }
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 void INT16handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
258 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
259 printf("INT16 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
260 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
261 }
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 void INT17handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
264 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
265 printf("INT17 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
266 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
267 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
268
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
269 void INT18handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
270 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
271 printf("INT18 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
272 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
273 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
274
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
275 void INT19handler()
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 printf("INT19 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
278 panic("Unhandled exception!");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
279 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
280
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
281 // remapped IRQ from master PIC:
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
282 void INT32handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
283 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
284 // System timer.
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
285 //printf("INT32 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
286 // called very frequent, what is this?
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
287 timerDriverUpdate();
18
6129643f5c34 Fixed interrupt issue, ds, es, ss, fs and gs were not initialized to 0
windel
parents: 17
diff changeset
288 // Acknowledge int:
14
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
289 outb(0x20, 0x20); // EOI to master
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
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
292 void INT33handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
293 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
294 //printf("INT33 called, key pressed????\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
295 unsigned char scancode = inb(0x60);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
296 //printf("Scancode = 0x%x\n", scancode);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
297 keyboardDriverUpdate(scancode);
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
298 outb(0x20, 0x20); // EOI to master
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
299 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
300
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
301 void INT34handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
302 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
303 printf("INT34 called!\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
304 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
305
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
306 void INTDEF_handler()
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
307 {
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
308 printf("Default int handler called\n");
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
309 }
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
310
a58904747019 Added asm interrupt handler things, not yet working
windel
parents:
diff changeset
311