2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @file idt.h
|
|
|
|
|
* @brief Interrupt Descriptor Table
|
|
|
|
|
* @author Jake "lordtet" Holtham
|
|
|
|
|
* @date 2025
|
|
|
|
|
* IDT related structures, globals and functions
|
|
|
|
|
*/
|
2025-06-16 04:52:05 +00:00
|
|
|
#ifndef IDT_H
|
|
|
|
|
#define IDT_H
|
2025-06-28 06:11:09 +00:00
|
|
|
|
2025-06-16 04:52:05 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief IDT Entry
|
|
|
|
|
*/
|
2025-06-16 04:52:05 +00:00
|
|
|
typedef struct InterruptDescriptor_s {
|
2025-07-17 11:36:45 +00:00
|
|
|
uint16_t offset_lo; /**< Lower 16 bits of ISR ptr */
|
|
|
|
|
uint16_t selector; /**< */
|
|
|
|
|
uint8_t reserved; /**< Nothing */
|
|
|
|
|
uint8_t attributes; /**< */
|
|
|
|
|
uint16_t offset_hi; /**< Upper 16 bits of ISR ptr */
|
2025-06-16 04:52:05 +00:00
|
|
|
} InterruptDescriptor_t;
|
|
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief
|
|
|
|
|
*/
|
2025-06-16 04:52:05 +00:00
|
|
|
typedef struct IDTR_s {
|
2025-07-17 11:36:45 +00:00
|
|
|
uint16_t size; /**< IDT Length */
|
|
|
|
|
InterruptDescriptor_t* IDT; /**< Pointer to the IDT Entry array */
|
2025-06-28 04:14:42 +00:00
|
|
|
} __attribute__((packed)) IDTR_t;
|
2025-06-16 04:52:05 +00:00
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief The IDTR in memory.
|
|
|
|
|
*/
|
2025-06-16 04:52:05 +00:00
|
|
|
extern IDTR_t idtr;
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief First IDT Entry
|
|
|
|
|
*/
|
2025-06-28 04:14:42 +00:00
|
|
|
extern InterruptDescriptor_t idt_start;
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Amount of ISRs implemented
|
|
|
|
|
*/
|
2025-06-28 04:14:42 +00:00
|
|
|
extern unsigned char num_interrupts;
|
2025-06-16 04:52:05 +00:00
|
|
|
|
2025-07-17 11:36:45 +00:00
|
|
|
/**
|
|
|
|
|
* @brief Call setup and write to construct and load the IDT.
|
|
|
|
|
*/
|
2025-06-16 04:52:05 +00:00
|
|
|
void setup_idt();
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Write the IDT and IDTR
|
|
|
|
|
*/
|
2025-06-16 04:52:05 +00:00
|
|
|
void write_descriptors();
|
2025-07-17 11:36:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief LIDT call
|
|
|
|
|
*/
|
2025-06-28 04:14:42 +00:00
|
|
|
extern void load_idt();
|
2025-06-16 04:52:05 +00:00
|
|
|
|
|
|
|
|
#endif
|