From efff262fb502e33cfc0d41901b0640c14baadb55 Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Fri, 15 May 2026 09:13:56 +0200 Subject: [PATCH] Replace CPUID queries with cached PRCB feature bits --- xtoskrnl/hl/x86/pic.cc | 50 +++++++++--------------------------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/xtoskrnl/hl/x86/pic.cc b/xtoskrnl/hl/x86/pic.cc index 7d546f6..0132078 100644 --- a/xtoskrnl/hl/x86/pic.cc +++ b/xtoskrnl/hl/x86/pic.cc @@ -78,28 +78,13 @@ XTAPI BOOLEAN HL::Pic::CheckApicSupport(VOID) { - CPUID_REGISTERS CpuRegisters; + PKPROCESSOR_CONTROL_BLOCK Prcb; - /* Prepare CPUID registers */ - CpuRegisters.Leaf = CPUID_GET_STANDARD1_FEATURES; - CpuRegisters.SubLeaf = 0; - CpuRegisters.Eax = 0; - CpuRegisters.Ebx = 0; - CpuRegisters.Ecx = 0; - CpuRegisters.Edx = 0; + /* Get current processor control block */ + Prcb = KE::Processor::GetCurrentProcessorControlBlock(); - /* Get CPUID */ - AR::CpuFunc::CpuId(&CpuRegisters); - - /* Check APIC status from the CPUID results */ - if(!(CpuRegisters.Edx & CPUID_FEATURES_EDX_APIC)) - { - /* APIC is not supported */ - return FALSE; - } - - /* APIC is supported */ - return TRUE; + /* Return APIC status */ + return (Prcb->CpuId.FeatureBits & KCF_APIC) ? TRUE : FALSE; } /** @@ -116,28 +101,13 @@ XTAPI BOOLEAN HL::Pic::CheckX2ApicSupport(VOID) { - CPUID_REGISTERS CpuRegisters; + PKPROCESSOR_CONTROL_BLOCK Prcb; - /* Prepare CPUID registers */ - CpuRegisters.Leaf = CPUID_GET_STANDARD1_FEATURES; - CpuRegisters.SubLeaf = 0; - CpuRegisters.Eax = 0; - CpuRegisters.Ebx = 0; - CpuRegisters.Ecx = 0; - CpuRegisters.Edx = 0; + /* Get current processor control block */ + Prcb = KE::Processor::GetCurrentProcessorControlBlock(); - /* Get CPUID */ - AR::CpuFunc::CpuId(&CpuRegisters); - - /* Check x2APIC status from the CPUID results */ - if(!(CpuRegisters.Ecx & CPUID_FEATURES_ECX_X2APIC)) - { - /* x2APIC is not supported */ - return FALSE; - } - - /* x2APIC is supported */ - return TRUE; + /* Return x2APIC status */ + return (Prcb->CpuId.FeatureBits & KCF_X2APIC) ? TRUE : FALSE; } /**