]> wirehaze git hosting - BOS.git/blob - kernel/int/idt.asm

wirehaze git hosting

cafbc63fc5dd368645431a0a1f513147232b1ea1
[BOS.git] / kernel / int / idt.asm
1 ;----------------------------------------------------------;
2 ; BOS kernel Christoffer Bubach, 2003-2005. ;
3 ;----------------------------------------------------------;
4 ; ;
5 ; set/modify IDT entries ;
6 ; ;
7 ;----------------------------------------------------------;
8
9
10
11 ;--------------------------------------------------;
12 ; set up IDT ;
13 ; in: edi = pointer to "unhandled int"-function. ;
14 ;--------------------------------------------------;
15 init_idt:
16 push eax
17 push ecx
18
19 mov ecx, 0
20 .loop: ; loop
21 mov eax, edi ; and
22 mov [(0x6c00+ecx)], ax ; set whole IDT
23 add ecx, 2 ; to one ISR
24
25 mov dword [(0x6c00+ecx)], 0x8E000008 ; 0x6c00 is where
26 add ecx, 4 ; we put the IDT
27
28 mov eax, edi
29 shr eax, 16
30 mov [(0x6c00+ecx)], ax
31 add ecx, 2
32
33 cmp ecx, 0x800 ; 256 ints
34 jb .loop ; * 8 bytes each
35
36 pop ecx
37 pop eax
38 ret
39
40
41
42 ;--------------------------------------;
43 ; modify IDT, set any int ;
44 ; in: cl = int number ;
45 ; edi = int function pointer ;
46 ;--------------------------------------;
47 set_int:
48 push eax
49 push ecx
50
51 mov al, 8 ; 8 bytes for each int
52 mul cl ; cl * al = ax
53 movzx ecx, ax ; ecx = offset in IDT (1/2 for dword list)
54 ;;mov [(idt_list+ecx/2)], edi ; add new int to idt entry list
55 mov dword [(idt_list+ecx)], edi ; add new int to idt entry list
56
57 mov eax, edi
58 mov [(0x6c00+ecx)], ax
59 add ecx, 2
60
61 mov dword [(0x6c00+ecx)], 0x8E000008
62 add ecx, 4
63
64 mov eax, edi
65 shr eax, 16
66 mov [(0x6c00+ecx)], ax
67
68 pop ecx
69 pop eax
70 ret
71
72
73
74 ;------------------------------------------------;
75 ; get int address ;
76 ; in: cl = int number ;
77 ; out: esi = address or 0 if none present ;
78 ;------------------------------------------------;
79 get_int:
80 push eax
81
82 mov eax, 4 ; 4 bytes for each address
83 mul cl ; cl * al = ax
84 mov esi, idt_list
85 add esi, eax
86
87 pop eax
88 ret
89
90
91
92
93 ;----------------------------------------;
94 ; sets ints from list ;
95 ; in: esi = pointer to int list ;
96 ;----------------------------------------;
97 set_idt_list:
98 push eax
99 push edi
100
101 mov ecx, 0
102 .loop:
103 lodsd
104 or eax, eax
105 jz .next
106 mov edi, eax
107 call set_int
108 .next:
109 inc ecx
110 cmp ecx, 0x100
111 jb .loop
112
113 pop edi
114 pop eax
115 ret
116
117
118
119 ;------------------------------;
120 ; list of idt entries. ;
121 ; 0 = not handled ;
122 ;------------------------------;
123 idt_list: dd isr00
124 dd isr01
125 dd isr02
126 dd isr03
127 dd isr04
128 dd isr05
129 dd isr06
130 dd isr07
131 dd isr08
132 dd isr09
133 dd isr0A
134 dd isr0B
135 dd isr0C
136 dd isr0D
137 dd isr0E
138 dd 0
139 dd isr10
140 dd isr11
141 dd isr12
142 dd isr13
143 times 12 dd 0 ; 12 unused ints
144 dd isr20
145 dd isr21
146 times 16 dd 0 ; 16 unused ints
147 dd isr32 ; First free and BOS system interrupt.
148 times 205 dd 0 ; 205 unused ints