diff --git a/xtoskrnl/hl/data.cc b/xtoskrnl/hl/data.cc index f20821d..7fa0b08 100644 --- a/xtoskrnl/hl/data.cc +++ b/xtoskrnl/hl/data.cc @@ -28,7 +28,7 @@ ACPI_SYSTEM_INFO HL::Acpi::SystemInfo; ACPI_TIMER_INFO HL::Acpi::TimerInfo; /* Represents the number of active processors */ -KAFFINITY HL::Cpu::ActiveProcessors; +KAFFINITY_MAP HL::Cpu::ActiveProcessors; /* Metadata detailing the linear frame buffer geometry */ HL_FRAMEBUFFER_DATA HL::FrameBuffer::FrameBufferData; diff --git a/xtoskrnl/hl/x86/cpu.cc b/xtoskrnl/hl/x86/cpu.cc index 10b41f9..f82d7a6 100644 --- a/xtoskrnl/hl/x86/cpu.cc +++ b/xtoskrnl/hl/x86/cpu.cc @@ -24,7 +24,7 @@ VOID HL::Cpu::InitializeProcessor(VOID) { PKPROCESSOR_BLOCK ProcessorBlock; - KAFFINITY Affinity; + ULONG BlockIndex, BitIndex; /* Get current processor block */ ProcessorBlock = KE::Processor::GetCurrentProcessorBlock(); @@ -33,17 +33,18 @@ HL::Cpu::InitializeProcessor(VOID) ProcessorBlock->StallScaleFactor = INITIAL_STALL_FACTOR; ProcessorBlock->Idr = 0xFFFFFFFF; - /* Set processor affinity */ - Affinity = (KAFFINITY) 1 << ProcessorBlock->CpuNumber; + /* Calculate the precise block and bit index for the affinity map */ + BlockIndex = ProcessorBlock->CpuNumber / 64; + BitIndex = ProcessorBlock->CpuNumber % 64; /* Apply affinity to a set of processors */ - ActiveProcessors |= Affinity; + RTL::Atomic::Or64((PLONG_PTR)&ActiveProcessors.Bitmap[BlockIndex], ((KAFFINITY)1 << BitIndex)); /* Initialize APIC for this processor */ HL::Pic::InitializePic(); /* Set the APIC running level */ - HL::RunLevel::SetRunLevel(KE::Processor::GetCurrentProcessorBlock()->RunLevel); + HL::RunLevel::SetRunLevel(ProcessorBlock->RunLevel); } /** diff --git a/xtoskrnl/includes/hl/cpu.hh b/xtoskrnl/includes/hl/cpu.hh index e75d011..bc39fbe 100644 --- a/xtoskrnl/includes/hl/cpu.hh +++ b/xtoskrnl/includes/hl/cpu.hh @@ -18,7 +18,7 @@ namespace HL class Cpu { private: - STATIC KAFFINITY ActiveProcessors; + STATIC KAFFINITY_MAP ActiveProcessors; public: STATIC XTAPI VOID InitializeProcessor(VOID);