diff options
author | Ondrej Čerman | 2019-10-12 19:24:19 +0200 |
---|---|---|
committer | Ondrej Čerman | 2019-10-12 19:44:54 +0200 |
commit | e1beb5791ef4608d20ad8992578a75ecae401eeb (patch) | |
tree | ce4c2be4efd1a6372a45838e5f6dedef4e447beb /src/zenmonitor.c | |
parent | ec849b74627cd6ad890714a0c3215fcf3c9c0dad (diff) |
FIX: Core ID to cpu device id mapping.
Diffstat (limited to 'src/zenmonitor.c')
-rw-r--r-- | src/zenmonitor.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/zenmonitor.c b/src/zenmonitor.c index 4ce4bb9..e001804 100644 --- a/src/zenmonitor.c +++ b/src/zenmonitor.c @@ -62,6 +62,24 @@ gchar *cpu_model() { return g_strdup(g_strchomp(model)); } +guint get_core_count() { + guint eax = 0, ebx = 0, ecx = 0, edx = 0; + guint logical_cpus, threads_per_code; + + // AMD PPR: page 57 - CPUID_Fn00000001_EBX + __get_cpuid(1, &eax, &ebx, &ecx, &edx); + logical_cpus = (ebx >> 16) & 0xFF; + + // AMD PPR: page 82 - CPUID_Fn8000001E_EBX + __get_cpuid(0x8000001E, &eax, &ebx, &ecx, &edx); + threads_per_code = ((ebx >> 8) & 0xF) + 1; + + if (threads_per_code == 0) + return logical_cpus; + + return logical_cpus / threads_per_code; +} + static SensorSource sensor_sources[] = { { "zenpower", |