diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/devices/devicetree.c | 22 | ||||
| -rw-r--r-- | modules/devices/devicetree/pmac_data.c | 95 | 
2 files changed, 115 insertions, 2 deletions
| diff --git a/modules/devices/devicetree.c b/modules/devices/devicetree.c index c6207972..73f8827b 100644 --- a/modules/devices/devicetree.c +++ b/modules/devices/devicetree.c @@ -84,6 +84,7 @@ gchar *hardinfo_clean_value(const gchar *v, int replacing) {  }  #include "devicetree/rpi_data.c" +#include "devicetree/pmac_data.c"  dtr *dt;  gchar *dtree_info = NULL; @@ -174,7 +175,7 @@ gchar *get_summary() {       * machine identifiers in /proc/cpuinfo. */      if ( strstr(model, "Raspberry Pi") != NULL          || strstr(compat, "raspberrypi") != NULL ) { -        tmp[0] = get_dt_string("/serial-number", 0); +        tmp[0] = get_dt_string("/serial-number", 1);          tmp[1] = get_dt_string("/soc/gpu/compatible", 1);          tmp[9] = rpi_board_details();          tmp[8] = g_strdup_printf( @@ -197,8 +198,25 @@ gchar *get_summary() {          free(tmp[9]); free(tmp[8]);      } +    /* Power Macintosh */ +    if ( 1 || strstr(compat, "PowerBook") != NULL +         || strstr(compat, "MacRISC") != NULL +         || strstr(compat, "Power Macintosh") != NULL) { +        tmp[9] =  ppc_mac_details(); +        if (tmp[9] != NULL) { +            tmp[0] = get_dt_string("/serial-number", 1); +            ret = g_strdup_printf( +                "%s[%s]\n" "%s=%s\n", tmp[9], +                _("More"), +                _("Serial Number"), tmp[0] ); +            free(tmp[0]); +        } +        free(tmp[9]); +    } + +    /* fallback */      if (ret == NULL) { -        tmp[0] = get_dt_string("/serial-number", 0); +        tmp[0] = get_dt_string("/serial-number", 1);          ret = g_strdup_printf(                  "[%s]\n"                  "%s=%s\n" 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; +} | 
