2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
29 * @return 0=Success; -1=Failure
33 //idt = calloc(ISR_NUM,sizeof(idtdesc_t));
34 memset(idt
,0,ISR_NUM
*sizeof(idtdesc_t
));
36 selector_t selector
= {
41 for (i
=0;i
<ISR_NUM
;i
++) {
42 idt_set_descriptor(i
,isr
[i
],selector
,i
==SYSCALL_INT
?PRIV_USER
:PRIV_KERNEL
,IDT_INTGATE32
|IDT_PRESENT
);
46 .size
= ISR_NUM
*sizeof(idtdesc_t
)-1,
47 .offset
= (uint32_t)&idt
49 asm("lidt (%0)"::"r"(&idtsel
));
54 void idt_set_descriptor(int i
,void *addr
,selector_t selector
,priv_t priv
,int type
) {
56 idt
[i
].address0_15
= ((unsigned int)addr
)&0xFFFF;
57 idt
[i
].address16_31
= (((unsigned int)addr
)>>16)&0xFFFF;
58 idt
[i
].selector
= selector
;
59 idt
[i
].type
= type
|((priv
&3)<<5);