aboutsummaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/arm/processor-platform.h8
-rw-r--r--includes/cpu_util.h48
-rw-r--r--includes/ppc/processor-platform.h9
-rw-r--r--includes/x86/processor-platform.h8
4 files changed, 60 insertions, 13 deletions
diff --git a/includes/arm/processor-platform.h b/includes/arm/processor-platform.h
index 9f4296d3..00ebf6b7 100644
--- a/includes/arm/processor-platform.h
+++ b/includes/arm/processor-platform.h
@@ -19,6 +19,8 @@
#ifndef __PROCESSOR_PLATFORM_H__
#define __PROCESSOR_PLATFORM_H__
+#include "cpu_util.h"
+
struct _Processor {
gchar *model_name;
gchar *decoded_name;
@@ -26,11 +28,9 @@ struct _Processor {
gfloat bogomips;
gint id;
- gchar *package_id, *core_id;
gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */
- gint cpukhz_max, cpukhz_min, cpukhz_cur; /* for arm/processor.c */
- gchar *scaling_driver, *scaling_governor;
- gint transition_latency;
+ cpu_topology_data *cputopo;
+ cpufreq_data *cpufreq;
gchar *cpu_implementer;
gchar *cpu_architecture;
diff --git a/includes/cpu_util.h b/includes/cpu_util.h
new file mode 100644
index 00000000..656a402c
--- /dev/null
+++ b/includes/cpu_util.h
@@ -0,0 +1,48 @@
+#ifndef __CPU_UTIL_H__
+#define __CPU_UTIL_H__
+
+#include "hardinfo.h"
+
+#ifndef PROC_CPUINFO
+#define PROC_CPUINFO "/proc/cpuinfo"
+#endif
+
+/* needs a local Processor *processor */
+#define STRIFNULL(f,cs) if (processor->f == NULL) processor->f = g_strdup(cs);
+#define UNKIFNULL(f) STRIFNULL(f, _("(Unknown)") )
+#define EMPIFNULL(f) STRIFNULL(f, "")
+
+gchar *byte_order_str(void);
+
+/* from /sys/devices/system/cpu/cpu%d/%s */
+gchar* get_cpu_str(const gchar* file, gint cpuid);
+gint get_cpu_int(const char* item, int cpuid);
+
+/* space delimted list of flags, finds flag */
+int processor_has_flag(gchar * strflags, gchar * strflag);
+
+typedef struct {
+ gint id;
+ gint cpukhz_max, cpukhz_min, cpukhz_cur;
+ gchar *scaling_driver, *scaling_governor;
+ gint transition_latency;
+} cpufreq_data;
+
+typedef struct {
+ gint id; /* thread */
+ gint socket_id;
+ gint core_id;
+} cpu_topology_data;
+
+cpufreq_data *cpufreq_new(gint id);
+void cpufreq_update(cpufreq_data *cpufd, int cur_only);
+void cpufreq_free(cpufreq_data *cpufd);
+
+gchar *cpufreq_section_str(cpufreq_data *cpufd);
+
+cpu_topology_data *cputopo_new(gint id);
+void cputopo_free(cpu_topology_data *cputd);
+
+gchar *cputopo_section_str(cpu_topology_data *cputd);
+
+#endif
diff --git a/includes/ppc/processor-platform.h b/includes/ppc/processor-platform.h
index 9410f599..d3d1a568 100644
--- a/includes/ppc/processor-platform.h
+++ b/includes/ppc/processor-platform.h
@@ -19,14 +19,13 @@
#ifndef __PROCESSOR_PLATFORM_H__
#define __PROCESSOR_PLATFORM_H__
+#include "cpu_util.h"
+
struct _Processor {
gint id;
- gchar *package_id, *core_id;
-
gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */
- gint cpukhz_max, cpukhz_min, cpukhz_cur; /* for ppc/processor.c */
- gchar *scaling_driver, *scaling_governor;
- gint transition_latency;
+ cpu_topology_data *cputopo;
+ cpufreq_data *cpufreq;
gchar *model_name;
gchar *revision;
diff --git a/includes/x86/processor-platform.h b/includes/x86/processor-platform.h
index 3dc4944f..97d864cb 100644
--- a/includes/x86/processor-platform.h
+++ b/includes/x86/processor-platform.h
@@ -19,6 +19,8 @@
#ifndef __PROCESSOR_PLATFORM_H__
#define __PROCESSOR_PLATFORM_H__
+#include "cpu_util.h"
+
typedef struct _ProcessorCache ProcessorCache;
struct _ProcessorCache {
@@ -40,11 +42,9 @@ struct _Processor {
gfloat bogomips;
gint id;
- gchar *package_id, *core_id;
gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */
- gint cpukhz_max, cpukhz_min, cpukhz_cur; /* for x86/processor.c */
- gchar *scaling_driver, *scaling_governor;
- gint transition_latency;
+ cpu_topology_data *cputopo;
+ cpufreq_data *cpufreq;
gchar *has_fpu;
gchar *bug_fdiv, *bug_hlt, *bug_f00f, *bug_coma;