1 /* Generated from i386_isrdef.c.j2. Do NOT modify */
3 #include <lunaix/types.h>
4 #include "asm/x86_ivs.h"
7 #define IDT_INTERRUPT 0x70
8 #define IDT_ATTR(dpl, type) (((type) << 5) | ((dpl & 3) << 13) | (1 << 15))
11 #define __expand_iv(iv) _asm_isr##iv()
12 #define DECLARE_ISR(iv) extern void __expand_iv(iv);
14 #ifndef CONFIG_ARCH_X86_64
17 install_idte(struct x86_sysdesc* idt, int iv, ptr_t isr, int dpl)
19 struct x86_sysdesc* idte = &idt[iv];
21 idte->hi = ((ptr_t)isr & 0xffff0000) | IDT_ATTR(dpl, IDT_INTERRUPT);
22 idte->lo = (KCODE_SEG << 16) | ((ptr_t)isr & 0x0000ffff);
24 struct x86_sysdesc _idt[IDT_ENTRY];
25 u16_t _idt_limit = sizeof(_idt) - 1;
29 static inline must_inline void
30 install_idte(struct x86_sysdesc* idt, int iv, ptr_t isr, int dpl)
32 struct x86_sysdesc* idte = &idt[iv];
36 idte->lo = (isr & 0xffff0000UL) | IDT_ATTR(dpl, IDT_INTERRUPT);
39 idte->lo |= (KCODE_SEG << 16) | (isr & 0x0000ffffUL);
42 struct x86_sysdesc _idt[IDT_ENTRY];
43 u16_t _idt_limit = sizeof(_idt) - 1;
51 exception_install_handler()
53 ptr_t start = (ptr_t)_asm_isr0;
55 for (int i = 0; i < 256; i++) {
56 install_idte(_idt, i, start, 0);
60 install_idte(_idt, 33, (ptr_t)_asm_isr33, 3);
62 #ifdef CONFIG_ARCH_X86_64
63 // TODO set different IST to some exception so it can get a
64 // better and safe stack to work with