[PATCH] The following fields will now reported for each CPU:
Darryl L. Pierce
dpierce at redhat.com
Wed Oct 1 08:35:55 PDT 2008
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
doc/spec/hal-spec-properties.xml | 72 ++++++++++++++++++++++++++
hald/linux/acpi.c | 103 +++++++++++++++++++++++++++++++-------
2 files changed, 157 insertions(+), 18 deletions(-)
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index f5faa59..22d4c51 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -7148,6 +7148,78 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
<entry>No</entry>
<entry>The maximum speed of the processor in units of MHz</entry>
</row>
+ <row>
+ <entry>
+ <listeral>processor.core (int)</literal>
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>The core in a multi-core processor, starting from 0.</entry>
+ </row>
+ <row>
+ <entry>
+ <listeral>processor.id (int)</literal>
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>The CPU id for a multi-core processo, starting from 0.</entry>
+ </row>
+ <row>
+ <entry>
+ <listeral>processor.vendor (string)</literal>
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>The name for the CPU manufacturer.</entry>
+ </row>
+ <row>
+ <entry>
+ <listeral>processor.family (int)</literal>
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>The processor family id.</entry>
+ </row>
+ <row>
+ <entry>
+ <listeral>processor.model (int)</literal>
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>The processor model id.</entry>
+ </row>
+ <row>
+ <entry>
+ <listeral>processor.cpuid_level (int)</literal>
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>The CPUID level.</entry>
+ </row>
+ <row>
+ <entry>
+ <listeral>processor.cache (string)</literal>
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>The cache size for the processor.</entry>
+ </row>
+ <row>
+ <entry>
+ <listeral>processor.speed (double)</literal>
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>The reported speed for the processor, in mHz.</entry>
+ </row>
+ <row>
+ <entry>
+ <listeral>processor.flags (string)</literal>
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>The capability flags for the processor.</entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
diff --git a/hald/linux/acpi.c b/hald/linux/acpi.c
index 6f76af6..713a78f 100644
--- a/hald/linux/acpi.c
+++ b/hald/linux/acpi.c
@@ -480,17 +480,19 @@ battery_refresh (HalDevice *d, ACPIDevHandler *handler, gboolean force_full_refr
}
/**
- * get_processor_model_name:
+ * get_processor_attribute_by_name:
* @proc_num: Number of processor
+ * @name: Attribute name
*
- * Returns: Name of the processor model
+ * Returns: Value of the attribute.
*
- * Give the model name of the processor.
+ * Returns the value for the named attribute.
*/
static gchar *
-get_processor_model_name (gint proc_num)
+get_processor_attribute_by_name(gint proc_num, gchar * name)
{
- gchar *model_name;
+ gchar *result = NULL;
+ gchar *attr_value;
gchar *contents = NULL;
GError *error = NULL;
@@ -502,6 +504,9 @@ get_processor_model_name (gint proc_num)
gchar *cursor;
gint i;
+ gchar *attr_label;
+
+ attr_label = g_strdup_printf("%s\t:", name);
if (g_file_get_contents ("/proc/cpuinfo", & contents, NULL, & error)) {
lines = g_strsplit (contents, "\n", 0);
@@ -514,34 +519,33 @@ get_processor_model_name (gint proc_num)
if (proc_num_i == proc_num) {
for (; lines [i]; ++i) {
- if (strstr (lines [i], "model name\t:")) {
+
+ if (g_strv_length(lines[1]) && strstr (lines [i], attr_label)) {
+ printf("FOUND THE RIGHT FIELD!\n");
cursor = strstr (lines [i], ":");
g_strstrip (++ cursor);
- model_name = g_strdup (cursor);
-
- g_strfreev (lines);
- g_free (contents);
+ attr_value = g_strdup (cursor);
- return model_name;
+ result = attr_value;
+ break;
}
}
}
}
}
- if (lines) {
- g_strfreev (lines);
- }
- }
- else {
+ g_strfreev (lines);
+ g_free (contents);
+ g_free (attr_label);
+ } else {
HAL_ERROR (("Couldn't open /proc/cpuinfo: %s", error->message));
g_error_free (error);
}
- return NULL;
+ return result;
}
static gboolean
@@ -551,6 +555,7 @@ processor_refresh (HalDevice *d, ACPIDevHandler *handler, gboolean force_full_re
gchar *model_name;
gint proc_num;
+ gchar *processor_value;
path = hal_device_property_get_string (d, "linux.acpi_path");
if (path == NULL)
@@ -560,7 +565,7 @@ processor_refresh (HalDevice *d, ACPIDevHandler *handler, gboolean force_full_re
path, "info", "processor id", 0, 10, FALSE
);
- if ((model_name = get_processor_model_name (proc_num))) {
+ if ((model_name = get_processor_attribute_by_name (proc_num, "model name"))) {
hal_device_property_set_string (d, "info.product", model_name);
g_free (model_name);
@@ -570,6 +575,68 @@ processor_refresh (HalDevice *d, ACPIDevHandler *handler, gboolean force_full_re
hal_device_property_set_string (d, "info.category", "processor");
hal_device_add_capability (d, "processor");
+
+ if((processor_value = get_processor_attribute_by_name(proc_num, "vendor_id"))) {
+ hal_device_property_set_string (d, "processor.vendor", processor_value);
+
+ g_free (processor_value);
+ }
+
+ hal_device_property_set_int (d, "processor.id", proc_num);
+
+ if((processor_value = get_processor_attribute_by_name(proc_num, "core id\t"))) {
+ gint core = atoi (processor_value);
+
+ hal_device_property_set_int (d, "processor.core", core);
+
+ g_free (processor_value);
+ }
+
+ if((processor_value = get_processor_attribute_by_name(proc_num, "cpu family"))) {
+ gint family = atoi(processor_value);
+
+ hal_device_property_set_int (d, "processor.family", family);
+
+ g_free (processor_value);
+ }
+
+ if((processor_value = get_processor_attribute_by_name(proc_num, "model\t"))) {
+ gint model = atoi(processor_value);
+
+
+ hal_device_property_set_int (d, "processor.model", model);
+
+ g_free (processor_value);
+ }
+
+ if((processor_value = get_processor_attribute_by_name(proc_num, "cpuid level"))) {
+ gint level = atoi(processor_value);
+
+ hal_device_property_set_int (d, "processor.cpuid_level", level);
+
+ g_free (processor_value);
+ }
+
+ if((processor_value = get_processor_attribute_by_name(proc_num, "cpu MHz\t"))) {
+ gdouble speed = g_ascii_strtod(processor_value, NULL);
+
+ hal_device_property_set_double (d, "processor.speed", speed);
+
+ g_free (processor_value);
+ }
+
+ if((processor_value = get_processor_attribute_by_name(proc_num, "cache size"))) {
+ hal_device_property_set_string (d, "processor.cache", processor_value);
+
+ g_free (processor_value);
+ }
+
+ if((processor_value = get_processor_attribute_by_name(proc_num, "flags\t"))) {
+ hal_device_property_set_string (d, "processor.flags", processor_value);
+
+ g_free (processor_value);
+ }
+
hal_util_set_int_elem_from_file (d, "processor.number", path,
"info", "processor id", 0, 10, FALSE);
hal_util_set_bool_elem_from_file (d, "processor.can_throttle", path,
--
1.5.5.1
More information about the hal
mailing list