9#ifndef MAX_OS_HARDWARECOMMUNICATION_INTERRUPTS_H
10#define MAX_OS_HARDWARECOMMUNICATION_INTERRUPTS_H
22namespace MaxOS::hardwarecommunication {
24 class InterruptManager;
34 explicit InterruptHandler(uint8_t interrupt_number, int64_t redirect = -1, uint64_t redirect_index = 0);
50 typedef struct PACKED
IDTR {
72 } interrupt_descriptor_t;
Defines classes and structures for handling the Advanced Programmable Interrupt Controller (APIC) in ...
Handles both the Local APIC (boot core) and IO APIC.
Handles a certain interrupt number.
~InterruptHandler()
Destroys the interrupt handler and unregisters it from the interrupt manager.
uint8_t m_interrupt_number
The interrupt number this handler handles.
virtual void handle_interrupt()
Handles an interrupt.
Handles all interrupts and passes them to the correct handler.
static InterruptManager * s_active_interrupt_manager
The interrupt manger that is currently handling interrupts and is loaded into the IDTR.
static void HandleInterruptRequest0x06()
Stub (see interrupts.s)
static void HandleException0x15()
Stub (see interrupts.s)
static void HandleInterruptError0x0A()
Stub (see interrupts.s)
static void HandleInterruptRequest0x05()
Stub (see interrupts.s)
static void HandleInterruptRequest0x31()
Stub (see interrupts.s)
static void deactivate()
Deactivates the interrupt manager and stops interrupts.
static void HandleException0x14()
Stub (see interrupts.s)
system::cpu_status_t * handle_interrupt_request(system::cpu_status_t *status)
Handles the interrupt request by passing it to the appropriate handler.
static void HandleInterruptRequest0x0A()
Stub (see interrupts.s)
static void HandleException0x00()
Stub (see interrupts.s)
static void HandleInterruptRequest0x0C()
Stub (see interrupts.s)
static void HandleInterruptRequest0x0F()
Stub (see interrupts.s)
static void HandleInterruptRequest0x07()
Stub (see interrupts.s)
static void HandleException0x07()
Stub (see interrupts.s)
static void HandleInterruptError0x0D()
Stub (see interrupts.s)
static InterruptManager * active_interrupt_manager()
Gets the active interrupt manager.
static void HandleInterruptError0x08()
Stub (see interrupts.s)
static void HandleException0x13()
Stub (see interrupts.s)
static void HandleInterruptError0x0C()
Stub (see interrupts.s)
static void HandleException0x04()
Stub (see interrupts.s)
static void HandleInterruptRequest0x0E()
Stub (see interrupts.s)
static void HandleException0x02()
Stub (see interrupts.s)
static void HandleException0x17()
Stub (see interrupts.s)
static void HandleException0x10()
Stub (see interrupts.s)
static void HandleInterruptRequest0x01()
Stub (see interrupts.s)
static void HandleInterruptRequest0x09()
Stub (see interrupts.s)
void set_apic(AdvancedProgrammableInterruptController *apic)
Sets the APIC.
static void HandleInterruptError0x11()
Stub (see interrupts.s)
static void HandleException0x1E()
Stub (see interrupts.s)
static void HandleInterruptRequest0x60()
Stub (see interrupts.s)
static void HandleInterruptRequest0x0B()
Stub (see interrupts.s)
static void HandleException0x1F()
Stub (see interrupts.s)
void remove_interrupt_handler(uint8_t interrupt)
Removes the interrupt handler for the interrupt.
static void load_current()
Tell the processor to use the current InterruptManager.
static void HandleException0x05()
Stub (see interrupts.s)
static void HandleInterruptError0x0B()
Stub (see interrupts.s)
static void ForceInterruptReturn(system::cpu_status_t *state)
Force the CPU to return from an interrupt (see interrupts.s)
static void HandleException0x19()
Stub (see interrupts.s)
static system::cpu_status_t * HandleInterrupt(system::cpu_status_t *status)
Handles the interrupt request by passing it to the interrupt manager.
~InterruptManager()
Destroys the Interrupt Manager and deactivates interrupts.
static void HandleException0x1A()
Stub (see interrupts.s)
static void HandleException0x01()
Stub (see interrupts.s)
static void HandleException0x18()
Stub (see interrupts.s)
static void HandleException0x1B()
Stub (see interrupts.s)
InterruptManager()
Constructs the Interrupt Manager and sets up the interrupt descriptor table (does not activate interr...
static void set_interrupt_descriptor_table_entry(uint8_t interrupt, void(*handler)(), uint8_t descriptor_privilege_level)
Sets an entry in the Interrupt Descriptor Table.
void activate()
Activates the interrupt manager and starts interrupts (also deactivates the current interrupt manager...
void set_interrupt_handler(uint8_t interrupt, InterruptHandler *handler)
Sets the interrupt handler for the interrupt.
static void HandleInterruptRequest0x80()
Stub (see interrupts.s)
static InterruptDescriptor s_interrupt_descriptor_table[MAX_INTERRUPT_HANDLERS]
The Interrupt Descriptor Table (IDT)
static void HandleException0x12()
Stub (see interrupts.s)
static void HandleInterruptRequest0x00()
Stub (see interrupts.s)
static void HandleInterruptRequest0x08()
Stub (see interrupts.s)
static void HandleException0x09()
Stub (see interrupts.s)
static void HandleException0x16()
Stub (see interrupts.s)
static void HandleInterruptRequest0x0D()
Stub (see interrupts.s)
static void HandleInterruptError0x0E()
Stub (see interrupts.s)
static void HandleException0x06()
Stub (see interrupts.s)
static void HandleException0x03()
Stub (see interrupts.s)
static void HandleException0x0F()
Stub (see interrupts.s)
static void HandleInterruptRequest0x04()
Stub (see interrupts.s)
static void HandleInterruptRequest0x03()
Stub (see interrupts.s)
static void HandleException0x1C()
Stub (see interrupts.s)
static void HandleInterruptRequest0x02()
Stub (see interrupts.s)
AdvancedProgrammableInterruptController * active_apic()
Gets the APIC.
static void HandleException0x1D()
Stub (see interrupts.s)
InterruptHandler * m_interrupt_handlers[MAX_INTERRUPT_HANDLERS]
A map of index-to-interrupt of interrupt handlers to fire when an interrupt occurs.
Defines Central Processing Unit (CPU) structures and functions for managing CPU state and features.
struct PACKED MaxOS::system::CPUStatus cpu_status_t
Alias for CPUStatus struct.
Defines a Global Descriptor Table (GDT) for setting up memory segments in protected mode.
constexpr uint16_t MAX_INTERRUPT_HANDLERS
The maximum number of interrupt handlers.
constexpr uint16_t HARDWARE_INTERRUPT_OFFSET
The offset in the IDT where interrupts from hardware start.
Defines a Map class for storing key-value pairs.
Defines OutputStream and GenericOutputStream classes for writing data to streams.
Defines classes for handling hardware communication ports (8, 16, and 32 bit)
A struct that holds the Interrupt Descriptor Table Register (IDTR)
uint16_t limit
The size of the IDT.
uint64_t base
The start address of the IDT.
An entry in the Interrupt Descriptor Table (IDT)
uint16_t segment_selector
The code segment selector in the GDT to use when this interrupt fires.
uint32_t address_high_bits
The high bits of the handler function address.
uint32_t reserved
Reserved, must be zero.
uint8_t ist
The offset into the Interrupt Stack Table (0 if not used) (see TSS)
uint16_t address_mid_bits
The middle bits of the handler function address.
uint16_t address_low_bits
The low bits of the handler function address.
uint8_t flags
Flags: The type of gate this entry represents (0xE for interrupt gate, 0xF for trap gate),...