#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.

39 releases (stable)

10.2.0 Jul 31, 2021
9.1.1 Jul 6, 2021
9.0.0 Jan 21, 2021
8.1.2 Oct 22, 2020
0.0.2 Mar 24, 2015

#7 in Hardware support

Download history 19763/week @ 2021-06-01 23497/week @ 2021-06-08 22279/week @ 2021-06-15 25029/week @ 2021-06-22 19550/week @ 2021-06-29 19363/week @ 2021-07-06 20754/week @ 2021-07-13 20445/week @ 2021-07-20 23162/week @ 2021-07-27 23297/week @ 2021-08-03 23769/week @ 2021-08-10 22030/week @ 2021-08-17 25817/week @ 2021-08-24 23344/week @ 2021-08-31 24856/week @ 2021-09-07 27266/week @ 2021-09-14

92,743 downloads per month
Used in 169 crates (25 directly)

MIT license

415KB
8K 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–1.2MB
~23K SLoC