#ifndef IDT_H
#define IDT_H

#include <stdint.h>

struct idt_entry_t {
    uint16_t offset_low;  // Lower 16 bits of ISR address
    uint16_t selector;    // Kernel segment selector
    uint8_t  ist;         // Interrupt Stack Table (for 64-bit)
    uint8_t  type_attr;   // Type and attributes (P, DPL, S, Type)
    uint16_t offset_mid;  // Middle 16 bits of ISR address
    uint32_t offset_high; // Upper 32 bits of ISR address (for 64-bit)
    uint32_t zero;        // Reserved
} __attribute__((packed));

struct idt_ptr_t {
    uint16_t limit;  // Size of the IDT (bytes - 1)
    uint64_t base;   // Base address of the IDT
} __attribute__((packed));



#define ERROR_DIVIDE_BY_ZERO        0
#define ERROR_DEBUG                 1
#define ERROR_NMI                   2
#define ERROR_BREAKPOINT            3
#define ERROR_OVERFLOW              4
#define ERROR_BOUND                 5
#define ERROR_INVALID_OP            6
#define ERROR_DEVICE_NOT_AVAIL      7
#define ERROR_DOUBLE_FAULT          8
#define ERROR_COPROCESSOR_OVERRUN   9
#define ERROR_INVALID_TSS           10
#define ERROR_SEGMENT_NOT_PRESENT   11
#define ERROR_STACK_SEGMENT         12
#define ERROR_GENERAL_PROTECTION    13
#define ERROR_PAGE_FAULT            14
#define FILESYSTEM_ERROR            15  // Assuming this relates to your filesystem


#define ERROR_RESERVED 16 // Not implemented error
// Function prototypes
void setup_idt_entry(int index, void (*handler)(), uint16_t selector, uint8_t type_attr);
void init_idt();

#endif
