HhhOS/include/drivers/idt/idt.h
2021-08-17 12:45:35 +03:00

34 lines
945 B
C

#pragma once
#include <types.h>
#include <std/util.h>
#define KERNEL_CODE_SEGMENT_OFFSET 40
#define INTERRUPT_GATE 0x8e
typedef struct {
u16 isr_low; // The lower 16 bits of the ISR's address
u16 kernel_cs; // The GDT segment selector that the CPU will load into CS before calling the ISR
u8 ist; // The IST in the TSS that the CPU will load into RSP; set to zero for now
u8 attributes; // Type and attributes; see the IDT page
u16 isr_mid; // The higher 16 bits of the lower 32 bits of the ISR's address
u32 isr_high; // The higher 32 bits of the ISR's address
u32 reserved; // Set to zero
} __attribute__((packed)) idt_entry_t;
typedef struct {
u16 limit;
u64 base;
} __attribute__((packed)) idtr_t;
typedef struct {
uintptr_t ip;
uintptr_t cs;
uintptr_t flags;
uintptr_t sp;
uintptr_t ss;
} interrupt_frame_t;
void idt_init();
void idt_set_entry(u8 vector, void* isr, u8 flags);