#cpuid #x86 #amd64 #os #libcore

bin+lib raw-cpuid

A library to parse the x86 CPUID instruction, written in rust with no external dependencies. The implementation closely resembles the Intel CPUID manual description. The library does only depend on libcore.

43 releases (stable)

10.6.0 Sep 12, 2022
10.3.0 Mar 19, 2022
10.2.0 Jul 31, 2021
9.1.1 Jul 6, 2021
0.0.2 Mar 24, 2015

#11 in Hardware support

Download history 66047/week @ 2022-08-08 74730/week @ 2022-08-15 70153/week @ 2022-08-22 73546/week @ 2022-08-29 70986/week @ 2022-09-05 76533/week @ 2022-09-12 80865/week @ 2022-09-19 77636/week @ 2022-09-26 66717/week @ 2022-10-03 77246/week @ 2022-10-10 75907/week @ 2022-10-17 74464/week @ 2022-10-24 76286/week @ 2022-10-31 74026/week @ 2022-11-07 72918/week @ 2022-11-14 59892/week @ 2022-11-21

286,006 downloads per month
Used in 289 crates (33 directly)

MIT license

510KB
9K SLoC

cpuid Crates.io Standard checks

A library to parse the x86 CPUID instruction, written in rust with no external dependencies. The implementation closely resembles the Intel CPUID manual description. The library does only depend on libcore.

  • For Intel platforms: The code should be in sync with the March 2018 revision of the Intel Architectures SDM.
  • For AMD platforms it should be in sync with the AMD64 systems manual no. 24594, Revision 3.32 (March 2021).

Library usage

use raw_cpuid::CpuId;
let cpuid = CpuId::new();

if let Some(vf) = cpuid.get_vendor_info() {
    assert!(vf.as_str() == "GenuineIntel" || vf.as_str() == "AuthenticAMD");
}

let has_sse = cpuid.get_feature_info().map_or(false, |finfo| finfo.has_sse());
if has_sse {
    println!("CPU supports SSE!");
}

if let Some(cparams) = cpuid.get_cache_parameters() {
    for cache in cparams {
        let size = cache.associativity() * cache.physical_line_partitions() * cache.coherency_line_size() * cache.sets();
        println!("L{}-Cache size is {}", cache.level(), size);
    }
} else {
    println!("No cache parameter information available")
}

cpuid binary

raw-cpuid ships with a cpuid binary that can be installed to inspect the output of the CPUID instruction on a host system.

To install, use:

cargo install raw-cpuid --features cli

The cli feature is currently required to build the binary version due to cargo limitations.

Documentation

Dependencies

~0–5.5MB
~89K SLoC