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

Handles both the Local APIC (boot core) and IO APIC. More...

#include <apic.h>

Public Member Functions

 AdvancedProgrammableInterruptController (AdvancedConfigurationAndPowerInterface *acpi)
 Construct a new Advanced Programmable Interrupt Controller object and initialises the Local APIC and IO APIC, disabling the legacy PIC.
 
 ~AdvancedProgrammableInterruptController ()
 Destroy the Advanced Programmable Interrupt Controller object and frees the Local APIC and IO APIC.
 
LocalAPIC * local_apic () const
 Get the local apic.
 
IOAPIC * io_apic () const
 Get the io apic.
 

Detailed Description

Handles both the Local APIC (boot core) and IO APIC.

Todo:
Should either handle all Local APICs or none (only boot core right now, others accessed per core directly which is inconsistent)

Definition at line 240 of file apic.h.

Constructor & Destructor Documentation

◆ AdvancedProgrammableInterruptController()

AdvancedProgrammableInterruptController::AdvancedProgrammableInterruptController ( AdvancedConfigurationAndPowerInterface *  acpi)
explicit

Construct a new Advanced Programmable Interrupt Controller object and initialises the Local APIC and IO APIC, disabling the legacy PIC.

Parameters
acpiThe ACPI interface to get the MADT from

Definition at line 462 of file apic.cpp.

463: m_pic_master_command_port(0x20),
464 m_pic_master_data_port(0x21),
465 m_pic_slave_command_port(0xA0),
466 m_pic_slave_data_port(0xA1)
467{
468
469 // Register this APIC
470 Logger::INFO() << "Setting up APIC\n";
472
473 // Init the Local APIC
474 Logger::DEBUG() << "Initialising Local APIC\n";
475 m_local_apic = new LocalAPIC();
476
477 // Disable the legacy mode PIC
478 Logger::DEBUG() << "Disabling PIC\n";
479 disable_pic();
480
481 // Init the IO APIC
482 Logger::DEBUG() << "Initialising IO APIC\n";
483 m_io_apic = new IOAPIC(acpi);
484}
static LogRecord DEBUG()
Gets the active logger for debug logs.
Definition logger.cpp:204
static LogRecord INFO()
Gets the active logger for info logs.
Definition logger.cpp:195
Handles the IO APIC in the system (one per system)
Definition apic.h:205
static InterruptManager * active_interrupt_manager()
Gets the active interrupt manager.
void set_apic(AdvancedProgrammableInterruptController *apic)
Sets the APIC.
Handles the local APIC for the current core.
Definition apic.h:34

References MaxOS::hardwarecommunication::InterruptManager::active_interrupt_manager(), MaxOS::Logger::DEBUG(), MaxOS::Logger::INFO(), and MaxOS::hardwarecommunication::InterruptManager::set_apic().

◆ ~AdvancedProgrammableInterruptController()

AdvancedProgrammableInterruptController::~AdvancedProgrammableInterruptController ( )

Destroy the Advanced Programmable Interrupt Controller object and frees the Local APIC and IO APIC.

Definition at line 489 of file apic.cpp.

489 {
490
491 // Free the memory
492 delete m_local_apic;
493 delete m_io_apic;
494}

Member Function Documentation

◆ io_apic()

IOAPIC * AdvancedProgrammableInterruptController::io_apic ( ) const

Get the io apic.

Returns
The io apic

Definition at line 537 of file apic.cpp.

537 {
538
539 return m_io_apic;
540}

Referenced by MaxOS::system::CPU::find_cores(), and MaxOS::hardwarecommunication::InterruptHandler::InterruptHandler().

◆ local_apic()

LocalAPIC * AdvancedProgrammableInterruptController::local_apic ( ) const

Get the local apic.

Returns
The local apic

Definition at line 527 of file apic.cpp.

527 {
528
529 return m_local_apic;
530}

Referenced by MaxOS::hardwarecommunication::Clock::calibrate(), MaxOS::system::CPU::CPU(), and MaxOS::system::Core::wake_up().


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