libcpuid_dump/
amd_proc_topo_80_1eh.rs

1use crate::CpuidResult;
2
3/// Information available from `CPUID.(EAX=8000_001Eh)`, AMD CPU only
4#[derive(Debug, Clone)]
5pub struct AmdProcTopo {
6    pub ext_apic_id: u32,
7    pub threads_per_core: u8,
8    pub core_id: u8,
9    pub nodes_per_processor: u8,
10    pub node_id: u8,
11}
12
13impl From<&CpuidResult> for AmdProcTopo {
14    fn from(cpuid: &CpuidResult) -> Self {
15        let ext_apic_id = cpuid.eax;
16        let threads_per_core = (((cpuid.ebx >> 8) & 0xFF) as u8).saturating_add(1);
17        let core_id = (cpuid.ebx & 0xFF) as u8;
18        let nodes_per_processor = (cpuid.ecx & 0b111) as u8;
19        let node_id = (cpuid.ecx & 0xFF) as u8;
20
21        Self {
22            ext_apic_id,
23            threads_per_core,
24            core_id,
25            nodes_per_processor,
26            node_id,
27        }
28    }
29}
30
31impl AmdProcTopo {
32    pub fn get() -> Self {
33        Self::from(&cpuid!(0x8000_001E, 0x0))
34    }
35}