-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcameronsmain.c
447 lines (407 loc) · 18 KB
/
cameronsmain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
#include "globals.h"
//forward declare functions... this normally goes in the header file
void print(char text[]);
void println(char text[]);
void shiftTextUpOneLine();
void delay();
extern unsigned int Page_Table1[1024 * 1024];
extern unsigned int Page_Directory[1024 * 1];
extern unsigned int IDT_Contents;
extern unsigned int IDT_Pointer;
typedef struct IDT_ENTRY_s {
unsigned short handlePointerLow;
unsigned short selector;
unsigned char reserved;
unsigned char gateType: 4;
unsigned char storageSegment: 1;
unsigned char DPL: 2;
unsigned char present: 1;
unsigned short handlePointerHigh;
} IDT_Entry_t;
typedef struct IDT_Pointer_s {
unsigned short tableSize;
IDT_Entry_t* IDT_Ptr;
} IDT_Pointer_t;
//void outb(unsigned short port, unsigned char value) {
//when outb is declared, EBP points to top of stack along with esp
//value is pushed to stack. ESP increments by 4, EBP stays the same
//port is pushed to stack. ESP increments by 8, EBP stays the same
//ebp+12 means 12 bytes up the stack... which is where value starts
//ebp+8 grabs the port, which starts 8 bytes up the stack
// __asm__(
// "mov AL, [ebp+12]\n"
// "mov DX, [ebp+8]\n"
// "outb DX, AL\n"
// );
//} //function ends, everything is popped of the stack up to EBP, ESP = EBP
void delay() {
unsigned int i = 0x400000;
while(i-- > 0 ){}
}
//COMMON_INTERRUPT_HANDLER goes here
//method to print display color goes here...
//keyboard driver goes here...
//interrupt issuer goes here...
void main() {
// at this point no functions can be called, because they are assigned to virtual memory
// by the linker. You can call them after setting up paging and after the pageing
// enabled bit is set in CR0
unsigned int physicalAddressAndFlags = 7; // 0b111 - Sets page table flags
// Present: ON, R/W: ON, User/Supervisor: ON
unsigned int numberOfPageTables = 4; //
unsigned int entriesPerPageTable = 1024; // always 1024 pages
unsigned int startPageTableEntryIndex = 0;
unsigned int sizeOfPageTables = numberOfPageTables * entriesPerPageTable;
unsigned int* Page_Table1_Physical = (unsigned int*)((unsigned int)Page_Table1 - KERNEL_VIRTUAL_BASE);
unsigned int* Page_Directory_Physical = (unsigned int*)((unsigned int)Page_Directory - KERNEL_VIRTUAL_BASE);
// set up identity mapping
unsigned int index = 0;
while(index < (sizeOfPageTables + startPageTableEntryIndex)) {
Page_Table1_Physical[index] = physicalAddressAndFlags; // set physicalAddressAndFlags for page entry
index += 1; // MAY NEED INDEX = INDEX + 1 ? .... // move to next page entry
physicalAddressAndFlags += 4096; // increment physical address of flags
}
// do the same thing as ^ with different index and startPageTableEntry... need to find out why
physicalAddressAndFlags = 7;
index = (KERNEL_PAGE_TABLE * 1024);
startPageTableEntryIndex = (KERNEL_PAGE_TABLE * 1024);
while(index < (sizeOfPageTables + startPageTableEntryIndex)) {
Page_Table1_Physical[index] = physicalAddressAndFlags;
index += 1;
physicalAddressAndFlags += 4096;
}
//
physicalAddressAndFlags = (unsigned int) & Page_Table1_Physical[0];
physicalAddressAndFlags = physicalAddressAndFlags | 7;
unsigned int entriesOfPageDirectory = 1024;
index = 0;
while(index < entriesOfPageDirectory) {
Page_Directory_Physical[index] = physicalAddressAndFlags;
index += 1;
physicalAddressAndFlags += 4096;
}
// set virtual addressing via CR3
__asm__ (
"lea ECX, [Page_Directory - 0xC0000000]\n"
"mov CR3, ECX\n"
);
// set paging bit via bit 32 of CR0
__asm__ (
"mov ECX, CR0\n"
"or ECX, 0x80000000\n"
"mov CR0, ECX\n"
);
// here and only here we are at PHYSICAL higher half mode
// now to switch to virtual higher half:
__asm__ (
"lea ECX, [StartInHigherHalf]\n"
"jmp ECX\n"
"StartInHigherHalf:\n"
"nop\n"
);
// end of setting virtual memory
//unsigned short* displayMemoryPointer = (unsigned short*) 0xB8000;
//unsigned int i = 0;
//while (i < DISPLAY_SIZE) {
// displayMemoryPointer[i++] = (0x0200 | ' ');
//}
IDT_Entry_t* IDT_Ptr = (IDT_Entry_t*)IDT_Contents;
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(0);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(1);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(2);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(3);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(4);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(5);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(6);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(7);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(8);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(9);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(10);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(11);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(12);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(13);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(14);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(15);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(16);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(17);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(18);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(19);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(20);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(21);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(22);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(23);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(24);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(25);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(26);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(27);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(28);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(29);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(30);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(31);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(32);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(33);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(34);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(35);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(36);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(37);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(38);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(39);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(40);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(41);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(42);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(43);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(44);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(45);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(46);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(47);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(48);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(49);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(50);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(51);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(52);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(53);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(54);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(55);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(56);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(57);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(58);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(59);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(60);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(61);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(62);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(63);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(64);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(65);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(66);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(67);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(68);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(69);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(70);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(71);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(72);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(73);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(74);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(75);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(76);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(77);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(78);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(79);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(80);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(81);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(82);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(83);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(84);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(85);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(86);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(87);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(88);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(89);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(90);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(91);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(92);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(93);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(94);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(95);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(96);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(97);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(98);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(99);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(100);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(101);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(102);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(103);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(104);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(105);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(106);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(107);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(108);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(109);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(110);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(111);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(112);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(113);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(114);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(115);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(116);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(117);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(118);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(119);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(120);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(121);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(122);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(123);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(124);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(125);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(126);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(127);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(128);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(129);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(130);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(131);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(132);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(133);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(134);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(135);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(136);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(137);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(138);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(139);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(140);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(141);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(142);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(143);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(144);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(145);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(146);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(147);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(148);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(149);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(150);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(151);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(152);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(153);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(154);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(155);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(156);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(157);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(158);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(159);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(160);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(161);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(162);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(163);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(164);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(165);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(166);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(167);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(168);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(169);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(170);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(171);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(172);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(173);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(174);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(175);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(176);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(177);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(178);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(179);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(180);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(181);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(182);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(183);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(184);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(185);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(186);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(187);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(188);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(189);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(190);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(191);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(192);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(193);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(194);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(195);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(196);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(197);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(198);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(199);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(200);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(201);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(202);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(203);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(204);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(205);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(206);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(207);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(208);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(209);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(210);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(211);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(212);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(213);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(214);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(215);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(216);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(217);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(218);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(219);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(220);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(221);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(222);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(223);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(224);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(225);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(226);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(227);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(228);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(229);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(230);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(231);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(232);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(233);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(234);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(235);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(236);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(237);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(238);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(239);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(240);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(241);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(242);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(243);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(244);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(245);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(246);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(247);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(248);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(249);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(250);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(251);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(252);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(253);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(254);
COMMON_INTERRUPT_HANDLER_SETUP_ENTRY(255);
IDT_Pointer_t* IDT_Ptr_Ptr = (IDT_Pointer_t*)IDT_Pointer;
IDT_Ptr_Ptr->tableSize = (unsigned short)((256 * sizeof(IDT_Entry_t)) - 1);
IDT_Ptr_Ptr->IDT_Ptr = IDT_Ptr;
__asm__
(
"lea EAX, [IDT_Pointer]\n" // Load address of (/pointer to) IDT pointer structure
"lidt [EAX]\n" // Load IDT register with pointer to IDT pointer structure
);
// END - Interrupt descriptor Table setup
// BEGIN - PIC setup and remap
// Remap IRQs 0-7 to ISRs 32-39
// and IRQs 8-15 to ISRs 40-47
outb(0x20, 0x11);
outb(0xA0, 0x11);
outb(0x21, 0x20);
outb(0xA1, 0x28);
outb(0x21, 0x04);
outb(0xA1, 0x02);
outb(0x21, 0x01);
outb(0xA1, 0x01);
outb(0x21, 0xFF);
outb(0xA1, 0xFF);
STI
// END - PIC setup and remap
// BEGIN - Configure PIT (The Timer)
CLI
__asm__
(
"in AL, 0x21\n"
"and AL, 0xFC\n" // Also enables keyboard interrupt (IRQ 1)
"out 0x21, AL\n"
);
outb(0x43, 0x34);
outb(0x40, 0xFF);
outb(0x40, 0xFF);
STI
// END - Configure PIT (The Timer)
PrintLine("Goodbye!");
// delay loop
while (1) {
;
}
}