![]() |
Max OS 0.3
|
Represents a CPU core in the system. More...
#include <cpu.h>
Public Member Functions | |
| Core (hardwarecommunication::madt_processor_apic_t *madt_item) | |
| Constructs a new Core object from the MADT entry. | |
| void | wake_up (CPU *cpu) |
| Wakes up the core by sending the appropriate IPIs. (see core_loader.s for startup code) | |
| void | init () |
| Initialises the core by setting up the GDT, IDT, TSS, SSE and APIC. | |
Public Attributes | |
| bool | xsave_enabled = false |
| Whether XSAVE is enabled. | |
| bool | avx_enabled = false |
| Whether AVX is enabled. | |
| uint8_t | id |
| The ID of this core. | |
| tss_t | tss = { } |
| The Task State Segment for this core. | |
| bool | active = false |
| Whether this core is active. | |
| hardwarecommunication::LocalAPIC * | local_apic = nullptr |
| The local APIC for this core. | |
| GlobalDescriptorTable * | gdt = nullptr |
| The GDT for this core. | |
| processes::Scheduler * | scheduler = nullptr |
| The scheduler for this core. | |
Protected Member Functions | |
| void | init_tss () |
| Initialises the task state segment for this cor. | |
| void | init_sse () |
| Initialises the SSE instructions. | |
Protected Attributes | |
| hardwarecommunication::madt_processor_apic_t * | m_madt |
| The MADT entry for this core. | |
| bool | m_enabled = false |
| Whether the core is enabled. | |
| bool | m_can_enable = false |
| Whether the core can be enabled. | |
| bool | m_bsp = false |
| Whether this core is the bootstrap processor. | |
| uint8_t | m_apic_id |
| The ID of the apic for this core. | |
| uint64_t | m_stack = 0 |
| The stack pointer for this core. | |
Friends | |
| class | CPU |
|
explicit |
Constructs a new Core object from the MADT entry.
| madt_item | The MADT entry for this core |
Definition at line 36 of file cpu.cpp.
References MaxOS::system::BOOT_STACK_SIZE, MaxOS::Logger::DEBUG(), MaxOS::memory::MemoryManager::kmalloc(), m_apic_id, m_can_enable, m_enabled, m_madt, and m_stack.
| void Core::init | ( | ) |
Initialises the core by setting up the GDT, IDT, TSS, SSE and APIC.
Definition at line 227 of file cpu.cpp.
References active, MaxOS::hardwarecommunication::Clock::active_clock(), gdt, init_sse(), init_tss(), MaxOS::hardwarecommunication::InterruptManager::load_current(), local_apic, and MaxOS::hardwarecommunication::Clock::setup_apic_clock().
|
protected |
Initialises the SSE instructions.
Definition at line 166 of file cpu.cpp.
References avx_enabled, MaxOS::system::CPU::check_cpu_feature(), MaxOS::Logger::DEBUG(), and xsave_enabled.
Referenced by init().
|
protected |
Initialises the task state segment for this cor.
Definition at line 108 of file cpu.cpp.
References MaxOS::system::BOOT_STACK_SIZE, MaxOS::Logger::DEBUG(), gdt, MaxOS::system::IO_BITMAP_SIZE, m_stack, and tss.
Referenced by init().
| void Core::wake_up | ( | CPU * | cpu | ) |
Wakes up the core by sending the appropriate IPIs. (see core_loader.s for startup code)
| cpu |
Definition at line 60 of file cpu.cpp.
References active, MaxOS::hardwarecommunication::Clock::active_clock(), MaxOS::system::CPU::apic, MaxOS::system::BOOT_STACK_SIZE, core_boot_info, MaxOS::Logger::DEBUG(), MaxOS::hardwarecommunication::Clock::delay(), id, MaxOS::hardwarecommunication::AdvancedProgrammableInterruptController::local_apic(), m_apic_id, m_bsp, m_stack, MaxOS::hardwarecommunication::LocalAPIC::send_init(), MaxOS::hardwarecommunication::LocalAPIC::send_startup(), and MaxOS::Logger::WARNING().
| bool MaxOS::system::Core::active = false |
| bool MaxOS::system::Core::avx_enabled = false |
| GlobalDescriptorTable* MaxOS::system::Core::gdt = nullptr |
| uint8_t MaxOS::system::Core::id |
The ID of this core.
Definition at line 243 of file cpu.h.
Referenced by MaxOS::system::CPU::PANIC(), MaxOS::processes::GlobalScheduler::print_running_header(), and wake_up().
| hardwarecommunication::LocalAPIC* MaxOS::system::Core::local_apic = nullptr |
The local APIC for this core.
Definition at line 247 of file cpu.h.
Referenced by MaxOS::hardwarecommunication::InterruptManager::handle_interrupt_request(), init(), and MaxOS::system::CPU::prepare_for_panic().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
The stack pointer for this core.
Definition at line 228 of file cpu.h.
Referenced by Core(), init_tss(), and wake_up().
| processes::Scheduler* MaxOS::system::Core::scheduler = nullptr |
The scheduler for this core.
Definition at line 249 of file cpu.h.
Referenced by MaxOS::processes::GlobalScheduler::add_process(), MaxOS::processes::GlobalScheduler::add_thread(), and MaxOS::processes::GlobalScheduler::core_scheduler().
| tss_t MaxOS::system::Core::tss = { } |
The Task State Segment for this core.
Definition at line 244 of file cpu.h.
Referenced by init_tss().
| bool MaxOS::system::Core::xsave_enabled = false |