summaryrefslogtreecommitdiff
path: root/kernel/src/interrupt/idt.asm
blob: 6cccdc652b116f3ac220c34e8e60163e2ff0f206 (plain)
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
extern idt_exception_handler
extern idt_pic_timer
extern idt_pic_keyboard
extern idt_pic_mouse
extern idt_pic_eoi
global isr_stub_table

%macro ISRErrorStub 1
isr_stub_%+%1:
    push dword %1
    call idt_exception_handler
    pop eax
    iret
%endmacro

%macro PICGeneric 1
isr_stub_%+%1:
    push dword %1
    call idt_pic_eoi
    pop eax
    iret
%endmacro

%macro PICTimer 1
isr_stub_%+%1:
    call idt_pic_timer
    push dword %1
    call idt_pic_eoi
    pop eax
    iret
%endmacro

%macro PICKeyboard 1
isr_stub_%+%1:
    call idt_pic_keyboard
    push dword %1
    call idt_pic_eoi
    pop eax
    iret
%endmacro

%macro PICMouse 1
isr_stub_%+%1:
    call idt_pic_mouse
    push dword %1
    call idt_pic_eoi
    pop eax
    iret
%endmacro

%macro ISRSyscall 1
isr_stub_%+%1:
    push eax
    push ebx
    push ecx
    push edx
    call idt_syscall
    add esp, 16
    pop eax
    iret
%endmacro

section .text
align 8
%assign i 0
%rep    32
    ISRErrorStub i
%assign i i+1
%endrep
PICTimer    32 ; 0 
PICKeyboard 33 ; 1
PICGeneric  34 ; 2
PICGeneric  35 ; 3
PICGeneric  36 ; 4
PICGeneric  37 ; 5
PICGeneric  38 ; 6
PICGeneric  39 ; 7
PICGeneric  40 ; 8
PICGeneric  41 ; 9
PICGeneric  42 ; 10
PICGeneric  43 ; 11
PICMouse    44 ; 12
PICGeneric  45 ; 13
PICGeneric  46 ; 14
PICGeneric  47 ; 15
%assign i 48
%rep    256 - 48
    ISRErrorStub i
%assign i i+1
%endrep

section .rodata
align 8
isr_stub_table:
%assign i 0x00
%rep    256
    dd isr_stub_%+i
%assign i i+0x01
%endrep