LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
idt.h
Go to the documentation of this file.
1
9
10#ifndef KERNEL_ARCH_X86_64_IDT_H
11#define KERNEL_ARCH_X86_64_IDT_H
12
13#include <stdint.h>
14
17 uint64_t r15, r14, r13, r12, r11, r10, r9, r8, rbp, rdi, rsi, rdx, rcx, rbx, rax;
18 uint64_t vector, error_code;
19 uint64_t rip, cs, rflags, rsp, ss; // pushed by the CPU
20};
21
22_Static_assert(sizeof(struct interrupt_frame) == 176, "Interrupt Frame must be 176 bytes");
23
25struct __attribute__((packed)) idt_entry {
26 uint16_t offset_low;
27 uint16_t selector;
28 uint8_t ist;
29 uint8_t type_attr;
30 uint16_t offset_mid;
31 uint32_t offset_high;
32 uint32_t reserved;
33};
34_Static_assert(sizeof(struct idt_entry) == 16, "IDT entry must be 16 bytes");
35
37struct __attribute__((packed)) idtr {
39 uint16_t limit;
41 uint64_t base;
42};
43
44_Static_assert(sizeof(struct idtr) == 10, "IDTR must be 10 bytes");
45
46extern const char *idt_exception_table[];
47extern uint64_t isr_stub_table[48];
48
53void exception_handler(struct interrupt_frame *frame);
54
58void init_idt(void);
59
68void idt_set_gate(int vector, uint64_t handler, uint16_t selector, uint8_t ist, uint8_t type_attr);
69
70#endif
const char * idt_exception_table[]
List of exceptions as strings.
Definition idt.c:24
void init_idt(void)
Initializes the IDT and loads it.
Definition idt.c:172
void exception_handler(struct interrupt_frame *frame)
Prints information about an exception.
Definition idt.c:63
void idt_set_gate(int vector, uint64_t handler, uint16_t selector, uint8_t ist, uint8_t type_attr)
Sets a gate (entry) for the idt.
Definition idt.c:188
The frame holding the registers when an interrupt happens.
Definition idt.h:16