]> git.dujemihanovic.xyz Git - nameless-os.git/blob - kernel/include/arch/x86/irq/idt.h
Use interrupt frame and new double fault handler
[nameless-os.git] / kernel / include / arch / x86 / irq / idt.h
1 #ifndef X86_IDT_H
2 #define X86_IDT_H
3
4 #include <stdint.h>
5 #include <irq/interrupt.h>
6
7 #define IDT_VECTOR_COUNT 256 /* our IDT will have 256 vectors */
8 #define IDT_DESCRIPTOR_SIZE 8 /* each IDT descriptor is 8 bytes long */
9
10 #define IDT_TRAP_GATE 0xF
11 #define IDT_INTERRUPT_GATE 0xE
12
13 struct idt_descriptor {
14 uint16_t offset_1; /* bits 0-15 of offset */
15 uint16_t segsel; /* segment selector */
16 unsigned unused : 8, type : 5, dpl : 2, present : 1;
17 uint16_t offset_2; /* bits 16-31 of offset */
18 } __attribute__((packed));
19
20 struct idtr {
21 uint16_t limit; /* size of IDT minus 1 */
22 uint32_t base; /* starting address of IDT */
23 } __attribute__((packed));
24
25 extern void idt_set_descriptor(struct idt_descriptor *idt, uint8_t vector, uint16_t segment, void (*offset)(void), uint8_t type, uint8_t dpl);
26 extern inline void load_idt(struct idtr idtr);
27 extern inline void populate_idtr(struct idtr *idtr, struct idt_descriptor *idt);
28
29 #endif