diff options
| author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2010-05-05 21:20:13 -0300 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2010-05-05 21:20:13 -0300 | 
| commit | 932e4f38e438961854d56f0863e82013f9ec9592 (patch) | |
| tree | c5d02319aba70d4c668796eb6e3c184ec3e30ca8 /modules | |
| parent | 5186e50a8c952fb3bd9ab415958b237e16575ec7 (diff) | |
Add processor.c implementation for other supported architectures
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/devices/alpha/processor.c | 78 | ||||
| -rw-r--r-- | modules/devices/arm/processor.c | 78 | ||||
| -rw-r--r-- | modules/devices/ia64/processor.c | 78 | ||||
| -rw-r--r-- | modules/devices/m68k/processor.c | 79 | ||||
| -rw-r--r-- | modules/devices/mips/processor.c | 75 | ||||
| -rw-r--r-- | modules/devices/parisc/processor.c | 87 | ||||
| -rw-r--r-- | modules/devices/ppc/processor.c | 85 | ||||
| -rw-r--r-- | modules/devices/processor.c | 81 | ||||
| -rw-r--r-- | modules/devices/s390/processor.c | 78 | ||||
| -rw-r--r-- | modules/devices/sh/processor.c | 75 | ||||
| -rw-r--r-- | modules/devices/sparc/processor.c | 64 | 
11 files changed, 858 insertions, 0 deletions
| diff --git a/modules/devices/alpha/processor.c b/modules/devices/alpha/processor.c new file mode 100644 index 00000000..f55526f7 --- /dev/null +++ b/modules/devices/alpha/processor.c @@ -0,0 +1,78 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processor_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("cpu model", processor->model_name); +	    get_float("BogoMIPS", processor->bogomips); +	    get_str("platform string", processor->strmodel); + +	} +	g_strfreev(tmp); +    } +     +    gchar *tmp = g_strconcat("Alpha ", processor->model_name, NULL); +    g_free(processor->model_name); +    processor->model_name = tmp; +    processor->cpu_mhz = 0.0f; + +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; + +	return g_strdup_printf("[Processor]\n" +                               "Model=%s\n" +	                       "Platform String=%s\n" +	                       "BogoMIPS=%.2f" +	                       "Byte Order=%s\n", +			       processor->model_name, +			       processor->strmodel, +			       processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian" +#else +                               "Big Endian" +#endif +                              ); +} diff --git a/modules/devices/arm/processor.c b/modules/devices/arm/processor.c new file mode 100644 index 00000000..c37aadca --- /dev/null +++ b/modules/devices/arm/processor.c @@ -0,0 +1,78 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processor_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("Processor", processor->model_name); +	    get_str("Features", processor->flags); +	    get_float("BogoMIPS", processor->bogomips); + +	    get_str("Hardware", processor->has_fpu); +	} +	g_strfreev(tmp); +    } + +    processor->cpu_mhz = 0.0f; + +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return g_strdup_printf("[Processor]\n" +	                       "Name=%s\n" +	                       "Features=%s\n" +			       "BogoMips=%.2f\n" +			       "Endianesss=" +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian", +#else +                               "Big Endian", +#endif +                               "\n" +			       "Hardware=%s\n", +			       processor->model_name, +			       processor->flags, +			       processor->bogomips, +			       processor->has_fpu); +} diff --git a/modules/devices/ia64/processor.c b/modules/devices/ia64/processor.c new file mode 100644 index 00000000..55e5e3a8 --- /dev/null +++ b/modules/devices/ia64/processor.c @@ -0,0 +1,78 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processor_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("vendor", processor->model_name); +	    get_str("arch", processor->vendor_id); +	    get_str("family", processor->strmodel); +	    get_float("BogoMIPS", processor->bogomips); + +	} +	g_strfreev(tmp); +    } + +    processor->cpu_mhz = 0.0f; +     +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return g_strdup_printf("[Processor]\n" +                               "Model=%s\n" +	                       "Architecture=%s\n" +	                       "Family=%sMHz\n" +			       "BogoMIPS=%s\n" +	                       "Byte Order=%s\n", +			       processor->model_name, +			       processor->vendor_id, +			       processor->strmodel, +			       processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian" +#else +                               "Big Endian" +#endif +                              ); +} diff --git a/modules/devices/m68k/processor.c b/modules/devices/m68k/processor.c new file mode 100644 index 00000000..d9902428 --- /dev/null +++ b/modules/devices/m68k/processor.c @@ -0,0 +1,79 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processor_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("CPU", processor->model_name); +	    get_float("Clocking", processor->cpu_mhz); +	    get_float("bogomips", processor->bogomips); + +	    get_str("FPU", processor->has_fpu); +	} +	g_strfreev(tmp); +    } +     +    gchar *tmp; +    tmp = g_strconcat("Motorola ", processor->model_name, NULL); +    g_free(processor->model_name); +    processor->model_name = tmp; +     +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return g_strdup_printf("[Processor]\n" +	                       "Name=%s\n" +			       "Frequency=%.2fMHz\n" +			       "BogoMips=%.2f\n" +			       "Byte Order=%s\n", +			       processor->model_name, +			       processor->cpu_mhz, +			       processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian" +#else +                               "Big Endian" +#endif +                               ); +} diff --git a/modules/devices/mips/processor.c b/modules/devices/mips/processor.c new file mode 100644 index 00000000..86c9b958 --- /dev/null +++ b/modules/devices/mips/processor.c @@ -0,0 +1,75 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processor_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("system type", processor->model_name); +	    get_str("cpu model", processor->vendor_id); +	    get_float("cpu MHz", processor->cpu_mhz); +	    get_float("BogoMIPS", processor->bogomips); +	} +	g_strfreev(tmp); +    } + +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return g_strdup_printf("[Processor]\n" +	                       "System Type=%s\n" +	                       "CPU Model=%s\n" +                               "Frequency=%.2fMHz\n" +			       "BogoMIPS=%.2f\n" +			       "Byte Order=%s\n", +			       processor->model_name, +			       processor->vendor_id, +			       processor->cpu_mhz, +			       processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian" +#else +                               "Big Endian" +#endif +			       ); +} diff --git a/modules/devices/parisc/processor.c b/modules/devices/parisc/processor.c new file mode 100644 index 00000000..83672126 --- /dev/null +++ b/modules/devices/parisc/processor.c @@ -0,0 +1,87 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processors_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("cpu family", processor->model_name); +	    get_str("cpu", processor->vendor_id); +	    get_float("cpu MHz", processor->cpu_mhz); +	    get_float("bogomips", processor->bogomips); +	     +	    get_str("model name", processor->strmodel); +	     +	    get_int("I-cache", processor->has_fpu); +	    get_int("D-cache", processor->flags); + +	} +	g_strfreev(tmp); +    } + +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return  g_strdup_printf("[Processor]\n" +	                       "CPU Family=%s\n" +	                       "CPU=%s\n" +                               "Frequency=%.2fMHz\n" +			       "Bogomips=%.2f\n" +			       "Model Name=%s\n" +			       "Byte Order=%s\n" +			       "[Cache]\n" +			       "I-Cache=%s\n" +			       "D-Cache=%s\n", +			       processor->model_name, +			       processor->vendor_id, +			       processor->cpu_mhz, +			       processor->bogomips, +			       processor->strmodel, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian", +#else +                               "Big Endian", +#endif +			       processor->has_fpu, +			       processor->flags); +} diff --git a/modules/devices/ppc/processor.c b/modules/devices/ppc/processor.c new file mode 100644 index 00000000..a7988f97 --- /dev/null +++ b/modules/devices/ppc/processor.c @@ -0,0 +1,85 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processor_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("cpu", processor->model_name); +	    get_str("machine", processor->vendor_id); +	    get_int("L2 cache", processor->cache_size); +	    get_float("clock", processor->cpu_mhz); +	    get_float("bogomips", processor->bogomips); + +	} +	g_strfreev(tmp); +    } +     +    gchar *tmp = g_strdup_printf("PowerPC %s (%.2fMHz)", +                                 processor->model_name, +                                 processor->cpu_mhz); +    g_free(processor->model_name); +    processor->model_name = tmp; + +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return g_strdup_printf("[Processor]\n" +	                       "Machine=%s\n" +	                       "CPU=%s\n" +	                       "L2 Cache=%dkB\n" +	                       "Frequency=%.2fMHz\n" +	                       "BogoMips=%.2f\n" +	                       "Byte Order=%s\n", +			       processor->vendor_id, +			       processor->model_name, +			       processor->cache_size, +			       processor->cpu_mhz, +			       processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian" +#else +                               "Big Endian" +#endif +                              ); +} diff --git a/modules/devices/processor.c b/modules/devices/processor.c new file mode 100644 index 00000000..1e5b014c --- /dev/null +++ b/modules/devices/processor.c @@ -0,0 +1,81 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +struct _Processor { +    gchar *model_name; +    gfloat bogomips, cpu_mhz; +    gchar *strmodel; +}; + +static GSList * +__scan_processors(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("cpu model", processor->model_name); +	    get_float("BogoMIPS", processor->bogomips); +	    get_str("platform string", processor->strmodel); + +	} +	g_strfreev(tmp); +    } +     +    gchar *tmp = g_strconcat("Alpha ", processor->model_name, NULL); +    g_free(processor->model_name); +    processor->model_name = tmp; +    processor->cpu_mhz = 0.0f; + +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +static gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; + +	return g_strdup_printf("[Processor]\n" +                               "Model=%s\n" +	                       "Platform String=%s\n" +	                       "BogoMIPS=%.2f" +	                       "Byte Order=%s\n", +			       processor->model_name, +			       processor->strmodel, +			       processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian" +#else +                               "Big Endian" +#endif +                              ); +} diff --git a/modules/devices/s390/processor.c b/modules/devices/s390/processor.c new file mode 100644 index 00000000..99f1c8bd --- /dev/null +++ b/modules/devices/s390/processor.c @@ -0,0 +1,78 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processor_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("vendor_id", processor->vendor_id); +	    get_float("# processors", processor->cache_size); +	    get_int("bogomips per cpu", processor->bogomips); + +	} +	g_strfreev(tmp); +    } + +    processor->cpu_mhz = 0.0f; +     +    processor->model_name = g_strconcat("S390 ", processor->vendor_id, NULL); +    g_free(processor->vendor_id); + +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return g_strdup_printf("[Processor]\n" +                               "Model=%s\n" +	                       "Processors=%d\n" +	                       "BogoMips per CPU=%.2f" +	                       "Byte Order=%s\n", +			       processor->model_name, +			       processor->cache_size, +			       processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian" +#else +                               "Big Endian" +#endif +                              ); +} diff --git a/modules/devices/sh/processor.c b/modules/devices/sh/processor.c new file mode 100644 index 00000000..cbd9a60a --- /dev/null +++ b/modules/devices/sh/processor.c @@ -0,0 +1,75 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processor_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("machine", processor->model_name); +	    get_str("cpu type", processor->vendor_id); +	    get_float("bogomips", processor->bogomips); +	    processor->cpu_mhz = processor->bogomips; +	} +	g_strfreev(tmp); +    } + +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return g_strdup_printf("[Processor]\n" +	                       "System Type=%s\n" +	                       "CPU Model=%s\n" +                               "Frequency=%.2fMHz\n" +			       "BogoMIPS=%.2f\n" +			       "Byte Order=%s\n", +			       processor->model_name, +			       processor->vendor_id, +			       processor->cpu_mhz, +			       processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian" +#else +                               "Big Endian" +#endif +			       ); +} diff --git a/modules/devices/sparc/processor.c b/modules/devices/sparc/processor.c new file mode 100644 index 00000000..594117a7 --- /dev/null +++ b/modules/devices/sparc/processor.c @@ -0,0 +1,64 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    This program is free software; you can redistribute it and/or modify + *    it under the terms of the GNU General Public License as published by + *    the Free Software Foundation, version 2. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include "hardinfo.h" +#include "devices.h" + +GSList * +processor_scan(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("cpu", processor->model_name); +	    get_str("fpu", processor->has_fpu); +	} +	g_strfreev(tmp); +    } + +    fclose(cpuinfo); + +    processor->cpu_mhz = 0.0f; + +    return g_slist_append(NULL, processor); +} + +gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return g_strdup_printf("[Processor]\n" +	                       "CPU=%s\n" +	                       "FPU=%s\n", +			       processor->model_name, +			       processor->has_fpu); +} | 
