aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Čerman2019-06-18 21:56:29 +0200
committerOndrej Čerman2019-06-18 22:05:42 +0200
commitd585178609b19406fd78ae11ddb4209a9a66f365 (patch)
treeb6ea0ef17fd5d9e689b766b6625fa332d94cefc0
parent8bc8727f6bce1f9d9477fd832cb382e965ead64f (diff)
Added CPU model
-rw-r--r--src/gui.c5
-rw-r--r--src/include/zenmonitor.h1
-rw-r--r--src/zenmonitor.c31
3 files changed, 34 insertions, 3 deletions
diff --git a/src/gui.c b/src/gui.c
index 7f1ce16..6d289a8 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -144,12 +144,13 @@ int start_gui (SensorSource *ss) {
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
- gtk_window_set_default_size(GTK_WINDOW(window), 330, 300);
+ gtk_window_set_default_size(GTK_WINDOW(window), 400, 350);
header = gtk_header_bar_new();
gtk_header_bar_set_show_close_button(GTK_HEADER_BAR (header), TRUE);
gtk_header_bar_set_title(GTK_HEADER_BAR (header), "Zen monitor");
- gtk_header_bar_set_has_subtitle(GTK_HEADER_BAR (header), FALSE);
+ gtk_header_bar_set_has_subtitle(GTK_HEADER_BAR (header), TRUE);
+ gtk_header_bar_set_subtitle(GTK_HEADER_BAR (header), cpu_model());
gtk_window_set_titlebar (GTK_WINDOW (window), header);
button = gtk_button_new();
diff --git a/src/include/zenmonitor.h b/src/include/zenmonitor.h
index 3a753c7..a1caa8d 100644
--- a/src/include/zenmonitor.h
+++ b/src/include/zenmonitor.h
@@ -21,3 +21,4 @@ typedef struct {
SensorInit* sensor_init_new(void);
void sensor_init_free(SensorInit *s);
gboolean check_zen();
+gchar *cpu_model();
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 },