1 /* Generated from i386_isrdef.c.j2. Do NOT modify */
3 #include <lunaix/types.h>
4 #include "sys/int_handler.h"
5 #include "sys/vectors.h"
6 #include "sys/x86_isa.h"
8 #define IDT_INTERRUPT 0x70
9 #define IDT_ATTR(dpl, type) (((type) << 5) | ((dpl & 3) << 13) | (1 << 15))
12 #define __expand_iv(iv) _asm_isr##iv()
13 #define DECLARE_ISR(iv) extern void __expand_iv(iv);
15 #ifndef CONFIG_ARCH_X86_64
18 install_idte(struct x86_sysdesc* idt, int iv, ptr_t isr, int dpl)
20 struct x86_sysdesc* idte = &idt[iv];
22 idte->hi = ((ptr_t)isr & 0xffff0000) | IDT_ATTR(dpl, IDT_INTERRUPT);
23 idte->lo = (KCODE_SEG << 16) | ((ptr_t)isr & 0x0000ffff);
25 struct x86_sysdesc _idt[IDT_ENTRY];
26 u16_t _idt_limit = sizeof(_idt) - 1;
30 static inline must_inline void
31 install_idte(struct x86_sysdesc* idt, int iv, ptr_t isr, int dpl)
33 struct x86_sysdesc* idte = &idt[iv];
37 idte->lo = (isr & 0xffff0000UL) | IDT_ATTR(dpl, IDT_INTERRUPT);
40 idte->lo |= (KCODE_SEG << 16) | (isr & 0x0000ffffUL);
43 struct x86_sysdesc _idt[IDT_ENTRY];
44 u16_t _idt_limit = sizeof(_idt) - 1;
52 exception_install_handler()
54 ptr_t start = (ptr_t)_asm_isr0;
56 for (int i = 0; i < 256; i++) {
57 install_idte(_idt, i, start, 0);
61 install_idte(_idt, 33, (ptr_t)_asm_isr33, 3);
63 #ifdef CONFIG_ARCH_X86_64
64 // TODO set different IST to some exception so it can get a
65 // better and safe stack to work with