diff options
author | Ondrej Čerman | 2019-06-18 21:56:29 +0200 |
---|---|---|
committer | Ondrej Čerman | 2019-06-18 22:05:42 +0200 |
commit | d585178609b19406fd78ae11ddb4209a9a66f365 (patch) | |
tree | b6ea0ef17fd5d9e689b766b6625fa332d94cefc0 /src/zenmonitor.c | |
parent | 8bc8727f6bce1f9d9477fd832cb382e965ead64f (diff) |
Added CPU model
Diffstat (limited to 'src/zenmonitor.c')
-rw-r--r-- | src/zenmonitor.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/zenmonitor.c b/src/zenmonitor.c index 5fe042a..b9fee07 100644 --- a/src/zenmonitor.c +++ b/src/zenmonitor.c @@ -8,8 +8,10 @@ #define AMD_STRING "AuthenticAMD" #define ZEN_FAMILY 0x17 +// AMD PPR = https://www.amd.com/system/files/TechDocs/54945_PPR_Family_17h_Models_00h-0Fh.pdf + gboolean check_zen() { - unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0, ext_family; + guint32 eax = 0, ebx = 0, ecx = 0, edx = 0, ext_family; char vendor[13]; __get_cpuid(0, &eax, &ebx, &ecx, &edx); @@ -33,6 +35,33 @@ gboolean check_zen() { return TRUE; } +gchar *cpu_model() { + guint32 eax = 0, ebx = 0, ecx = 0, edx = 0; + char model[48]; + + // AMD PPR: page 65-68 - CPUID_Fn80000002_EAX-CPUID_Fn80000004_EDX + __get_cpuid(0x80000002, &eax, &ebx, &ecx, &edx); + memcpy(model, &eax, 4); + memcpy(model+4, &ebx, 4); + memcpy(model+8, &ecx, 4); + memcpy(model+12, &edx, 4); + + __get_cpuid(0x80000003, &eax, &ebx, &ecx, &edx); + memcpy(model+16, &eax, 4); + memcpy(model+20, &ebx, 4); + memcpy(model+24, &ecx, 4); + memcpy(model+28, &edx, 4); + + __get_cpuid(0x80000004, &eax, &ebx, &ecx, &edx); + memcpy(model+32, &eax, 4); + memcpy(model+36, &ebx, 4); + memcpy(model+40, &ecx, 4); + memcpy(model+44, &edx, 4); + + model[48] = 0; + return g_strdup(model); +} + static SensorSource sensor_sources[] = { { "zenpower", zenpower_init, zenpower_get_sensors, zenpower_update, FALSE, NULL }, { "msr", msr_init, msr_get_sensors, msr_update, FALSE, NULL }, |