__cpuid_count in core::arch::x86 - Rust
Description: Returns the result of the `cpuid` instruction for a given `leaf` (`EAX`) and `sub_leaf` (`ECX`).

Skip to main content

## __cpuid_count

# Function __cpuid_count

1.27.0 · Source

    pub fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult

Available on x86 only.
Expand description

Returns the result of the `cpuid` instruction for a given `leaf` (`EAX`) and `sub_leaf` (`ECX`).

There are two types of information leaves - basic leaves (with `leaf < 0x8000000`) and extended leaves (with `leaf >= 0x80000000`). The highest supported basic and extended leaves can be obtained by calling CPUID with `0` and `0x80000000`, respectively, and reading the value in the `EAX` register. If the leaf supports more than one sub-leaf, then the procedure of obtaining the highest supported sub-leaf, as well as the behavior if a invalid sub-leaf value is passed, depends on the specific leaf.

If the `leaf` value is higher than the maximum supported basic or extended leaf for the processor, this returns the information for the highest supported basic information leaf (with the passed `sub_leaf` value). If the `leaf` value is less than or equal to the highest basic or extended leaf value, but the leaf is not supported on the processor, all zeros are returned.

The CPUID Wikipedia page contains information on how to query which information using the `EAX` and `ECX` registers, and the interpretation of the results returned in `EAX`, `EBX`, `ECX`, and `EDX`.

The references are:

- Intel 64 and IA-32 Architectures Software Developer’s Manual Volume 2: Instruction Set Reference, A-Z.
- AMD64 Architecture Programmer’s Manual, Volume 3: General-Purpose and System Instructions.