Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::hardwarecommunication::InterruptHandler Class Reference

Handles a certain interrupt number. More...

#include <interrupts.h>

Inheritance diagram for MaxOS::hardwarecommunication::InterruptHandler:
MaxOS::drivers::clock::Clock MaxOS::drivers::clock::PIT MaxOS::drivers::ethernet::AMD_AM79C973 MaxOS::drivers::ethernet::IntelI217 MaxOS::drivers::peripherals::KeyboardDriver MaxOS::drivers::peripherals::MouseDriver MaxOS::processes::GlobalScheduler MaxOS::system::SyscallManager

Public Member Functions

virtual void handle_interrupt ()
 Handles an interrupt.
 
virtual system::cpu_status_thandle_interrupt (system::cpu_status_t *status)
 Handles an interrupt and returns the status.
 

Protected Member Functions

 InterruptHandler (uint8_t interrupt_number, int64_t redirect=-1, uint64_t redirect_index=0)
 Creates a new interrupt handler and registers it with the interrupt manager.
 
 ~InterruptHandler ()
 Destroys the interrupt handler and unregisters it from the interrupt manager.
 

Protected Attributes

uint8_t m_interrupt_number
 The interrupt number this handler handles.
 

Detailed Description

Handles a certain interrupt number.

Definition at line 30 of file interrupts.h.

Constructor & Destructor Documentation

◆ InterruptHandler()

InterruptHandler::InterruptHandler ( uint8_t  interrupt_number,
int64_t  redirect = -1,
uint64_t  redirect_index = 0 
)
explicitprotected

Creates a new interrupt handler and registers it with the interrupt manager.

Parameters
interrupt_numberThe interrupt number to handle
redirectWhat legacy interrupt to redirect from (-1 for no redirection)
redirect_indexWhich index of the legacy interrupt to redirect from

Definition at line 24 of file interrupts.cpp.

25: m_interrupt_number(interrupt_number)
26{
27
28 // Get the interrupt manager
30 ASSERT(interrupt_manager != nullptr, "No active interrupt manager");
31
32 // Register the handler
33 interrupt_manager->set_interrupt_handler(m_interrupt_number, this);
34
35 // Not all interrupts need redirecting
36 if (redirect == -1)
37 return;
38
39 // Redirect a legacy interrupt to an interrupt the kernel expects
40 IOAPIC* io_apic = interrupt_manager->active_apic()->io_apic();
42 .type = (uint8_t) redirect,
43 .index = (uint8_t) redirect_index,
44 .interrupt = m_interrupt_number,
45 .destination = 0x00,
46 .flags = 0x00,
47 .mask = false,
48 };
49 io_apic->set_redirect(&temp);
50}
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
Handles the IO APIC in the system (one per system)
Definition apic.h:193
void set_redirect(interrupt_redirect_t *redirect)
Redirect a system interrupt to a different IRQ.
Definition apic.cpp:365
uint8_t m_interrupt_number
The interrupt number this handler handles.
Definition interrupts.h:32
Handles all interrupts and passes them to the correct handler.
Definition interrupts.h:84
static InterruptManager * s_active_interrupt_manager
The interrupt manger that is currently handling interrupts and is loaded into the IDTR.
Definition interrupts.h:95
#define ASSERT(condition, format,...)
If the specified condition is not met then the kernel will crash with the specified message.
Definition logger.h:100
Defines how an interrupt input is redirected to a specific processor via the I/O APIC.
Definition apic.h:162

References ASSERT, m_interrupt_number, MaxOS::hardwarecommunication::InterruptManager::s_active_interrupt_manager, and MaxOS::hardwarecommunication::IOAPIC::set_redirect().

◆ ~InterruptHandler()

InterruptHandler::~InterruptHandler ( )
protected

Destroys the interrupt handler and unregisters it from the interrupt manager.

Definition at line 55 of file interrupts.cpp.

55 {
56
57 // Get the interrupt manager
59 if (interrupt_manager == nullptr) return;
60
61 // Remove the handler
62 interrupt_manager->set_interrupt_handler(m_interrupt_number, nullptr);
63}

References m_interrupt_number, and MaxOS::hardwarecommunication::InterruptManager::s_active_interrupt_manager.

Member Function Documentation

◆ handle_interrupt() [1/2]

void InterruptHandler::handle_interrupt ( )
virtual

◆ handle_interrupt() [2/2]

system::cpu_status_t * InterruptHandler::handle_interrupt ( system::cpu_status_t status)
virtual

Handles an interrupt and returns the status.

Parameters
statusThe status of the CPU
Returns
The status of the CPU

Reimplemented in MaxOS::system::SyscallManager, and MaxOS::processes::GlobalScheduler.

Definition at line 78 of file interrupts.cpp.

78 {
79
80 // For handlers that don't care about the status
82
83 // Return the default status
84 return status;
85}
virtual void handle_interrupt()
Handles an interrupt.

References handle_interrupt().

Member Data Documentation

◆ m_interrupt_number

uint8_t MaxOS::hardwarecommunication::InterruptHandler::m_interrupt_number
protected

The interrupt number this handler handles.

Definition at line 32 of file interrupts.h.

Referenced by InterruptHandler(), and ~InterruptHandler().


The documentation for this class was generated from the following files: