cleans up idt.h and idt.c

This commit is contained in:
2025-06-13 13:12:05 -04:00
parent 99a842df7e
commit 2ec3e259d8
3 changed files with 68 additions and 49 deletions

View File

@ -3,33 +3,6 @@
#ifndef ARCH_IDT_H
#define ARCH_IDT_H
#define IDT_MAX_DESCRIPTORS 48 // number of entries in the idt table
#define EXCEPT_DIV_ERR 0
#define EXCEPT_DEBUG 1
#define EXCEPT_NMI 2
#define EXCEPT_BREAKPOINT 3
#define EXCEPT_OVERFLOW 4
#define EXCEPT_BOUND_RANGE_EXCEEDED 5
#define EXCEPT_INVALID_OPCODE 6
#define EXCEPT_DEVICE_NOT_AVAILABLE 7
#define EXCEPT_DOUBLE_FAULT 8
#define EXCEPT_INVALID_TSS 10
#define EXCEPT_SEG_NOT_PRESENT 11
#define EXCEPT_STACK_SEG_FAULT 12
#define EXCEPT_GENERAL_PROTECTION 13
#define EXCEPT_PAGE_FAULT 14
#define EXCEPT_FLOATING_POINT_ERR_FPU 16
#define EXCEPT_ALIGNMENT_CHECK 17
#define EXCEPT_MACHINE_CHECK 18
#define EXCEPT_FLOATING_POINT_ERR_SIMD 19
#define EXCEPT_VIRT 20
#define EXCEPT_CTRL_PROT 21
#define EXCEPT_HYPERVISOR_INJECTION 28
#define EXCEPT_VMM_COMMUNICATION 29
#define EXCEPT_SECURITY_EXCEPTION 30
struct cpu_state {
uint32_t eax;
uint32_t ebx;
@ -49,20 +22,6 @@ struct stack_state {
void exception_handler(struct cpu_state cpu, uint32_t interrupt, struct stack_state stack);
typedef struct {
uint16_t isr_low; // The lower 16 bits of the ISR's address
uint16_t kernel_cs; // The GDT segment selector that the CPU will load into CS before calling the ISR
uint8_t reserved; // set to zero
uint8_t attributes; // Type and attributes
uint16_t isr_high; // The higher 16 bits of the ISR's address
} __attribute__((packed)) idt_entry_t;
typedef struct {
uint16_t limit;
uint32_t base;
} __attribute__((packed)) idtr_t;
void idt_set_descriptor(uint8_t vector, void* isr, uint8_t flags);
void idt_init(void);
#endif