-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
idt.asm
126 lines (110 loc) · 1.68 KB
/
idt.asm
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
; Copyright (C) 2021 Mateus de Lima Oliveira
[bits 32]
extern isrHandler
global load_idt
global EnableInterrupts
global DisableInterrupts
load_idt:
mov eax, [esp + 4]
lidt [eax]
; Test interrupts
int 3
int 4
ret
EnableInterrupts:
sti
ret
DisableInterrupts:
cli
ret
%macro isr_noerror 1
global isr%1
isr%1:
cli
push 0
push %1
jmp isr_stub
%endmacro
%macro isr_error 1
global isr%1
isr%1:
cli
push %1
jmp isr_stub
%endmacro
isr_noerror 0
isr_noerror 1
isr_noerror 2
isr_noerror 3
isr_noerror 4
isr_noerror 5
isr_noerror 6
isr_noerror 7
isr_error 8
isr_noerror 9
isr_error 10
isr_error 11
isr_error 12
isr_error 13
isr_error 14
isr_noerror 15
isr_noerror 16
isr_noerror 17
isr_noerror 18
isr_noerror 19
isr_noerror 20
isr_noerror 21
isr_noerror 22
isr_noerror 23
isr_noerror 24
isr_noerror 25
isr_noerror 26
isr_noerror 27
isr_noerror 28
isr_noerror 29
isr_noerror 30
isr_noerror 31
; IRQs
isr_noerror 32
isr_noerror 33
isr_noerror 34
isr_noerror 35
isr_noerror 36
isr_noerror 37
isr_noerror 38
isr_noerror 39
isr_noerror 40
isr_noerror 41
isr_noerror 42
isr_noerror 43
isr_noerror 44
isr_noerror 45
isr_noerror 46
isr_noerror 47
; syscall
isr_noerror 128 ; 0x80
isr_stub:
pusha ; Push All General-Purpose Registers
; Push the segment for the IDT handler function
; and save it on the esi register to be restored
; after the function call.
mov ax, ds
push eax
;mov esi, eax
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
call isrHandler
pop eax
; Restore segment registers
;mov eax, esi
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
popa ; Restore general-purpose registers from the stack
add esp, 8 ; Remove the values pushed by the isr# routine
sti
iret