Files
RedBear-OS/src/arch/x86_shared/cpuid.rs
T
bjorn3 f92b4c9608 Unify cpuid between x86 and x86_64 and don't return an Option
Systems without cpuid support aren't supported anyway.
2024-02-25 15:07:31 +01:00

18 lines
568 B
Rust

use raw_cpuid::{CpuId, CpuIdResult};
pub fn cpuid() -> CpuId {
// FIXME check for cpuid availability during early boot and error out if it doesn't exist.
CpuId::with_cpuid_fn(|a, c| {
#[cfg(target_arch = "x86")]
let result = unsafe { core::arch::x86::__cpuid_count(a, c) };
#[cfg(target_arch = "x86_64")]
let result = unsafe { core::arch::x86_64::__cpuid_count(a, c) };
CpuIdResult {
eax: result.eax,
ebx: result.ebx,
ecx: result.ecx,
edx: result.edx,
}
})
}