Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions awkernel_lib/src/arch/x86_64/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ impl CPU for super::X86 {
if (cpuid_leaf_1.ecx & (1 << 21)) != 0 {
// Get x2APIC ID from leaf 1FH or leaf 0BH (1FH is preferred)
let max_leaf = unsafe { core::arch::x86_64::__cpuid(0) }.eax;
let edx = if max_leaf >= 0x1F {
unsafe { core::arch::x86_64::__cpuid(0x1F).edx }
} else {
unsafe { core::arch::x86_64::__cpuid(0x0B).edx }
};
edx as usize
if max_leaf >= 0x1F {
let leaf_1f = unsafe { core::arch::x86_64::__cpuid(0x1F) };
// Check if ecx has a valid value
if (leaf_1f.ecx >> 8) != 0 {
return leaf_1f.edx as usize;
}
}

unsafe { core::arch::x86_64::__cpuid(0x0B).edx as usize }
} else {
(cpuid_leaf_1.ebx >> 24 & 0xff) as usize
}
Expand Down
Loading