25 #define ISR_INIT(nr) extern void isr_intr_##nr(); \ 26 idt_init_entry_isr((nr), &isr_intr_##nr, 0) 32 } __attribute__((packed))
idtr_t;
36 TASK_32 = 0x5, INTR_16, TRAP_16, INTR_32 = 0xE, TRAP_32
44 idt_entry_type_t type : 4;
70 idt_entry_type_t type, uint8_t st, uint8_t dpl, uint8_t pr) {
95 asm volatile(
"lidt %0" : :
"m" (idtr));
100 print(
"IDT init ... ");
115 extern void isr_intr_0x30();
idt_entry_type_t type
gate type
static void idt_init_entry_isr(size_t entry, void(*func)(), uint8_t dpl)
Shorthand for initializing an ISR.
idt_entry_type_t
Different types of interrupt vectors.
uint16_t func16_31
pointer to ISR (byte 3-4)
uint32_t base
where the IDT is located
uint16_t func0_15
pointer to ISR (byte 1-2)
uint16_t limit
number of entries in the IDT
the IDTR register pointing to the IDT
uint16_t gdt_get_selector(size_t entry)
Returns a selector ready to be loaded in a segment register.
#define IDT_ENTRIES
Number of entries in the IDT.
uint16_t selector
RING0 code segment selector in GDT.
uint8_t dpl
privilege (ring level)
void idt_init()
Initializes the IDT.
#define ISR_INIT(nr)
shorthand for initializing an ISR
static idt_entry_t idt[IDT_ENTRIES]
The IDT itself.
uint8_t st
storage segment flag
static void idt_init_entry(size_t entry, uintptr_t func, uint32_t selector, idt_entry_type_t type, uint8_t st, uint8_t dpl, uint8_t pr)
Initializes an IDT entry.
static void idt_load()
Loads the IDT into the IDTR register.
#define GDT_RING0_CODE_SEG
kernel code segment index