forked from Absurdponcho/YoutubeOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIDT.cpp
More file actions
52 lines (43 loc) · 1.1 KB
/
IDT.cpp
File metadata and controls
52 lines (43 loc) · 1.1 KB
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
#pragma once
#include "Typedefs.cpp"
#include "KBScanCodeSet1.cpp"
#include "IO.cpp"
#include "TextPrint.cpp"
struct IDT64{
uint_16 offset_low;
uint_16 selector;
uint_8 ist;
uint_8 types_attr;
uint_16 offset_mid;
uint_32 offset_high;
uint_32 zero;
};
extern IDT64 _idt[256];
extern uint_64 isr1;
extern "C" void LoadIDT();
void InitializeIDT(){
_idt[1].zero = 0;
_idt[1].offset_low = (uint_16)(((uint_64)&isr1 & 0x000000000000ffff));
_idt[1].offset_mid = (uint_16)(((uint_64)&isr1 & 0x00000000ffff0000) >> 16);
_idt[1].offset_high = (uint_32)(((uint_64)&isr1 & 0xffffffff00000000) >> 32);
_idt[1].ist = 0;
_idt[1].selector = 0x08;
_idt[1].types_attr = 0x8e;
RemapPic();
outb(0x21, 0xfd);
outb(0xa1, 0xff);
LoadIDT();
}
void(*MainKeyboardHandler)(uint_8 scanCode, uint_8 chr);
extern "C" void isr1_handler(){
uint_8 scanCode = inb(0x60);
uint_8 chr = 0;
if (scanCode < 0x3A){
chr = KBSet1::ScanCodeLookupTable[scanCode];
}
if (MainKeyboardHandler != 0) {
MainKeyboardHandler(scanCode, chr);
}
outb(0x20, 0x20);
outb(0xa0, 0x20);
}