idt.h (1751B)
1 #ifndef _KERNEL_IDT_H_ 2 #define _KERNEL_IDT_H_ 3 4 /* IA-32 */ 5 struct idt_gate { 6 uint16_t off_lo; 7 uint16_t sel; 8 uint8_t zero; 9 uint8_t flags; 10 uint16_t off_hi; 11 } __attribute__((packed)); 12 13 /* This will be populated by `int_common_stub` in `int.asm`. */ 14 struct reg { 15 /* Will be popped last. */ 16 uint32_t gs; 17 uint32_t fs; 18 uint32_t es; 19 uint32_t ds; 20 /* Pushed by `pusha`. */ 21 uint32_t edi; 22 uint32_t esi; 23 uint32_t ebp; 24 uint32_t esp; 25 uint32_t ebx; 26 uint32_t edx; 27 uint32_t ecx; 28 uint32_t eax; 29 /* Interrupt info. Pushed by `push byte`. */ 30 uint32_t intno; 31 uint32_t err; 32 /* Pushed by the CPU. */ 33 uint32_t eip; 34 uint32_t cs; 35 uint32_t eflags; 36 uint32_t uesp; 37 uint32_t ss; 38 }; 39 40 /* Called by `kmain`. */ 41 void idt_init(void); 42 43 /* Called by drivers. */ 44 void int_handler(struct reg *); 45 void int_add_handler(uint8_t, void (*)(struct reg *)); 46 47 /* The first 32 interrupts are reserved for exceptions. */ 48 void ex0(void); 49 void ex1(void); 50 void ex2(void); 51 void ex3(void); 52 void ex4(void); 53 void ex5(void); 54 void ex6(void); 55 void ex7(void); 56 void ex8(void); 57 void ex9(void); 58 void ex10(void); 59 void ex11(void); 60 void ex12(void); 61 void ex13(void); 62 void ex14(void); 63 void ex15(void); 64 void ex16(void); 65 void ex17(void); 66 void ex18(void); 67 void ex19(void); 68 void ex20(void); 69 void ex21(void); 70 void ex22(void); 71 void ex23(void); 72 void ex24(void); 73 void ex25(void); 74 void ex26(void); 75 void ex27(void); 76 void ex28(void); 77 void ex29(void); 78 void ex30(void); 79 void ex31(void); 80 81 /* IRQs */ 82 void irq0(void); 83 void irq1(void); 84 void irq2(void); 85 void irq3(void); 86 void irq4(void); 87 void irq5(void); 88 void irq6(void); 89 void irq7(void); 90 void irq8(void); 91 void irq9(void); 92 void irq10(void); 93 void irq11(void); 94 void irq12(void); 95 void irq13(void); 96 void irq14(void); 97 void irq15(void); 98 99 #endif /* _KERNEL_IDT_H_ */