diff options
Diffstat (limited to 'src/zenmonitor.c')
-rw-r--r-- | src/zenmonitor.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/zenmonitor.c b/src/zenmonitor.c index ee2be39..30e5370 100644 --- a/src/zenmonitor.c +++ b/src/zenmonitor.c @@ -3,6 +3,7 @@ #include "zenmonitor.h" #include "zenpower.h" #include "msr.h" +#include "os.h" #include "gui.h" #include "string.h" @@ -63,6 +64,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", @@ -75,6 +94,11 @@ static SensorSource sensor_sources[] = { FALSE, NULL }, { + "os", + os_init, os_get_sensors, os_update, os_clear_minmax, + FALSE, NULL + }, + { NULL } }; |