aboutsummaryrefslogtreecommitdiff
path: root/modules/devices/devicetree
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-07-23 00:23:52 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2017-07-24 18:07:58 -0700
commit5922e1335dae6966fb6d0651090864e12ee87a1f (patch)
tree6669008f82e820319e911f5e9a408975ea7c79a8 /modules/devices/devicetree
parentf3574dd0ce47235121fe5da8cfdc20a6e451f361 (diff)
device tree: add power mac data
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/devices/devicetree')
-rw-r--r--modules/devices/devicetree/pmac_data.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/modules/devices/devicetree/pmac_data.c b/modules/devices/devicetree/pmac_data.c
new file mode 100644
index 00000000..41d3a105
--- /dev/null
+++ b/modules/devices/devicetree/pmac_data.c
@@ -0,0 +1,95 @@
+/*
+ * HardInfo - Displays System Information
+ * Copyright (C) 2003-2007 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 "cpu_util.h" /* for PROC_CPUINFO */
+
+static gchar *ppc_mac_details(void) {
+ int i = 0;
+ gchar *ret = NULL;
+ gchar *platform = NULL;
+ gchar *model = NULL;
+ gchar *machine = NULL;
+ gchar *motherboard = NULL;
+ gchar *detected_as = NULL;
+ gchar *pmac_flags = NULL;
+ gchar *l2_cache = NULL;
+ gchar *pmac_gen = NULL;
+
+ FILE *cpuinfo;
+ gchar buffer[128];
+
+ cpuinfo = fopen(PROC_CPUINFO, "r");
+ if (!cpuinfo)
+ return NULL;
+ while (fgets(buffer, 128, cpuinfo)) {
+ gchar **tmp = g_strsplit(buffer, ":", 2);
+ tmp[0] = g_strstrip(tmp[0]);
+ tmp[1] = g_strstrip(tmp[1]);
+ get_str("platform", platform);
+ get_str("model", model);
+ get_str("machine", machine);
+ get_str("motherboard", motherboard);
+ get_str("detected as", detected_as);
+ get_str("pmac flags", pmac_flags);
+ get_str("L2 cache", l2_cache);
+ get_str("pmac-generation", pmac_gen);
+ }
+ fclose(cpuinfo);
+
+ if (machine == NULL)
+ goto pmd_exit;
+
+#define _UNKIFNULL(STR) if (STR == NULL) { STR = strdup(_("(Unknown)")); }
+ _UNKIFNULL(platform);
+ _UNKIFNULL(model);
+ _UNKIFNULL(motherboard);
+ _UNKIFNULL(detected_as);
+ _UNKIFNULL(pmac_flags);
+ _UNKIFNULL(l2_cache);
+ _UNKIFNULL(pmac_gen);
+
+ ret = g_strdup_printf("[%s]\n"
+ "%s=%s\n"
+ "%s=%s\n"
+ "%s=%s\n"
+ "%s=%s\n"
+ "%s=%s\n"
+ "%s=%s\n"
+ "%s=%s\n"
+ "%s=%s\n",
+ _("Apple Power Macintosh"),
+ _("Platform"), platform,
+ _("Model"), model,
+ _("Machine"), machine,
+ _("Motherboard"), motherboard,
+ _("Detected as"), detected_as,
+ _("PMAC Flags"), pmac_flags,
+ _("L2 Cache"), l2_cache,
+ _("PMAC Generation"), pmac_gen );
+
+pmd_exit:
+ g_free(platform);
+ g_free(model);
+ g_free(machine);
+ g_free(motherboard);
+ g_free(detected_as);
+ g_free(pmac_flags);
+ g_free(l2_cache);
+ g_free(pmac_gen);
+ return ret;
+}