From b7b035ad9f5b45887ddeaf4ff1abcd6304531cbb Mon Sep 17 00:00:00 2001 From: "Leandro A. F. Pereira" Date: Mon, 30 Jun 2008 13:48:05 -0300 Subject: Add device resources (I/O ports, memory, DMA). --- hardinfo2/arch/linux/alpha/resources.h | 1 + hardinfo2/arch/linux/armv4l/resources.h | 1 + hardinfo2/arch/linux/common/resources.h | 78 +++++++++++++++++++++++++++++++++ hardinfo2/arch/linux/ia64/resources.h | 1 + hardinfo2/arch/linux/m68k/resources.h | 1 + hardinfo2/arch/linux/mips/resources.h | 1 + hardinfo2/arch/linux/parisc/resources.h | 1 + hardinfo2/arch/linux/ppc/resources.h | 1 + hardinfo2/arch/linux/s390/resources.h | 1 + hardinfo2/arch/linux/sh/resources.h | 1 + hardinfo2/arch/linux/sparc/resources.h | 1 + hardinfo2/arch/linux/x86/resources.h | 1 + hardinfo2/devices.c | 8 +++- 13 files changed, 95 insertions(+), 2 deletions(-) create mode 120000 hardinfo2/arch/linux/alpha/resources.h create mode 120000 hardinfo2/arch/linux/armv4l/resources.h create mode 100644 hardinfo2/arch/linux/common/resources.h create mode 120000 hardinfo2/arch/linux/ia64/resources.h create mode 120000 hardinfo2/arch/linux/m68k/resources.h create mode 120000 hardinfo2/arch/linux/mips/resources.h create mode 120000 hardinfo2/arch/linux/parisc/resources.h create mode 120000 hardinfo2/arch/linux/ppc/resources.h create mode 120000 hardinfo2/arch/linux/s390/resources.h create mode 120000 hardinfo2/arch/linux/sh/resources.h create mode 120000 hardinfo2/arch/linux/sparc/resources.h create mode 120000 hardinfo2/arch/linux/x86/resources.h diff --git a/hardinfo2/arch/linux/alpha/resources.h b/hardinfo2/arch/linux/alpha/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/alpha/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/armv4l/resources.h b/hardinfo2/arch/linux/armv4l/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/armv4l/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/common/resources.h b/hardinfo2/arch/linux/common/resources.h new file mode 100644 index 00000000..581d7eba --- /dev/null +++ b/hardinfo2/arch/linux/common/resources.h @@ -0,0 +1,78 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2008 Leandro A. F. Pereira + * + * 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 + */ + +gchar *_resources = NULL; +void scan_device_resources(gboolean reload) +{ + SCAN_START(); + FILE *io; + gchar buffer[256]; + + g_free(_resources); + _resources = g_strdup(""); + + if ((io = fopen("/proc/ioports", "r"))) { + _resources = h_strconcat(_resources, "[I/O Ports]\n", NULL); + + while (fgets(buffer, 256, io)) { + gchar **temp = g_strsplit(buffer, ":", 2); + + _resources = h_strdup_cprintf("%s=%s\n", _resources, temp[0], temp[1]); + + g_strfreev(temp); + } + + fclose(io); + } + + if ((io = fopen("/proc/iomem", "r"))) { + _resources = h_strconcat(_resources, "[Memory]\n", NULL); + + while (fgets(buffer, 256, io)) { + gchar **temp = g_strsplit(buffer, ":", 2); + + _resources = h_strdup_cprintf("%s=%s\n", _resources, temp[0], temp[1]); + + g_strfreev(temp); + } + + fclose(io); + } + + if ((io = fopen("/proc/dma", "r"))) { + _resources = h_strconcat(_resources, "[DMA]\n", NULL); + + while (fgets(buffer, 256, io)) { + gchar **temp = g_strsplit(buffer, ":", 2); + + _resources = h_strdup_cprintf("%s=%s\n", _resources, temp[0], temp[1]); + + g_strfreev(temp); + } + + fclose(io); + } + + SCAN_END(); +} + +gchar *callback_device_resources(void) +{ + return _resources; +} + diff --git a/hardinfo2/arch/linux/ia64/resources.h b/hardinfo2/arch/linux/ia64/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/ia64/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/m68k/resources.h b/hardinfo2/arch/linux/m68k/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/m68k/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/mips/resources.h b/hardinfo2/arch/linux/mips/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/mips/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/parisc/resources.h b/hardinfo2/arch/linux/parisc/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/parisc/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/ppc/resources.h b/hardinfo2/arch/linux/ppc/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/ppc/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/s390/resources.h b/hardinfo2/arch/linux/s390/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/s390/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/sh/resources.h b/hardinfo2/arch/linux/sh/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/sh/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/sparc/resources.h b/hardinfo2/arch/linux/sparc/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/sparc/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/arch/linux/x86/resources.h b/hardinfo2/arch/linux/x86/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/hardinfo2/arch/linux/x86/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h \ No newline at end of file diff --git a/hardinfo2/devices.c b/hardinfo2/devices.c index b866ed44..cff60f50 100644 --- a/hardinfo2/devices.c +++ b/hardinfo2/devices.c @@ -40,6 +40,7 @@ gchar *callback_usb(); #if defined(ARCH_i386) || defined(ARCH_x86_64) gchar *callback_dmi(); #endif +gchar *callback_device_resources(); void scan_processors(gboolean reload); void scan_memory(gboolean reload); @@ -53,6 +54,7 @@ void scan_usb(gboolean reload); #if defined(ARCH_i386) || defined(ARCH_x86_64) void scan_dmi(gboolean reload); #endif +void scan_device_resources(gboolean reload); static ModuleEntry entries[] = { {"Processor", "processor.png", callback_processors, scan_processors}, @@ -62,11 +64,12 @@ static ModuleEntry entries[] = { {"Printers", "printer.png", callback_printers, scan_printers,}, {"Battery", "battery.png", callback_battery, scan_battery}, {"Sensors", "therm.png", callback_sensors, scan_sensors}, + {"Input Devices", "inputdevices.png", callback_input, scan_input}, + {"Storage", "hdd.png", callback_storage, scan_storage}, #if defined(ARCH_i386) || defined(ARCH_x86_64) {"DMI", "computer.png", callback_dmi, scan_dmi}, #endif /* x86 or x86_64 */ - {"Input Devices", "inputdevices.png", callback_input, scan_input}, - {"Storage", "hdd.png", callback_storage, scan_storage}, + {"Resources", "module.png", callback_device_resources, scan_device_resources}, {NULL} }; @@ -120,6 +123,7 @@ typedef struct _Processor Processor; #include #include #include +#include #if defined(ARCH_i386) || defined(ARCH_x86_64) #include -- cgit v1.2.3