diff options
| author | Burt P <pburt0@gmail.com> | 2017-06-20 03:40:30 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-06-21 10:34:54 -0700 | 
| commit | 51e51766673eb4043c1d75c6167ed8a910d0e539 (patch) | |
| tree | 9ea7e79515bdb55f8ef5cc270e858d0f5d0637c4 /modules | |
| parent | 5ee9893c5a9cc9eb7b2986972b14cd1dd16471c4 (diff) | |
ARM arch tweaks
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/devices/arm/arm_data.c | 43 | ||||
| -rw-r--r-- | modules/devices/arm/arm_data.h | 2 | ||||
| -rw-r--r-- | modules/devices/arm/processor.c | 12 | 
3 files changed, 50 insertions, 7 deletions
| diff --git a/modules/devices/arm/arm_data.c b/modules/devices/arm/arm_data.c index 246cb643..2e2cbe60 100644 --- a/modules/devices/arm/arm_data.c +++ b/modules/devices/arm/arm_data.c @@ -114,6 +114,16 @@ static struct {             { 0, NULL},  }; +static struct { +    char *code; char *name; char *more; +} tab_arm_arch[] = { +    { "7",	"AArch32",	"AArch32 (ARMv7)" }, +    { "8",	"AArch64",	"AArch64 (ARMv8)" }, +    { "AArch32",	"AArch32",	"AArch32 (ARMv7)" }, +    { "AArch64",	"AArch64",	"AArch64 (ARMv8)" }, +    { NULL, NULL, NULL }, +}; +  static char all_flags[1024] = "";  #define APPEND_FLAG(f) strcat(all_flags, f); strcat(all_flags, " "); @@ -173,9 +183,31 @@ const char *arm_part(const char *imp_code, const char *part_code) {      return NULL;  } +const char *arm_arch(const char *cpuinfo_arch_str) { +    int i = 0; +    if (cpuinfo_arch_str) +    while(tab_arm_arch[i].code) { +        if (strcmp(tab_arm_arch[i].code, cpuinfo_arch_str) == 0) +            return tab_arm_arch[i].name; +        i++; +    } +    return cpuinfo_arch_str; +} + +const char *arm_arch_more(const char *cpuinfo_arch_str) { +    int i = 0; +    if (cpuinfo_arch_str) +    while(tab_arm_arch[i].code) { +        if (strcmp(tab_arm_arch[i].code, cpuinfo_arch_str) == 0) +            return tab_arm_arch[i].more; +        i++; +    } +    return cpuinfo_arch_str; +} +  char *arm_decoded_name(const char *imp, const char *part, const char *var, const char *rev, const char *arch, const char *model_name) {      char *dnbuff; -    char *imp_name = NULL, *part_desc = NULL; +    char *imp_name = NULL, *part_desc = NULL, *arch_name = NULL;      int r = 0, p = 0;      dnbuff = malloc(256);      if (dnbuff) { @@ -188,8 +220,15 @@ char *arm_decoded_name(const char *imp, const char *part, const char *var, const              p = strtol(rev, NULL, 0);              imp_name = (char*) arm_implementer(imp);              part_desc = (char*) arm_part(imp, part); +            arch_name = (char *) arm_arch(arch);              if (imp_name || part_desc) { -                sprintf(dnbuff, "%s %s r%dp%d (arch:%s)", +                if (arch_name != arch) +                    sprintf(dnbuff, "%s %s r%dp%d (%s)", +                        (imp_name) ? imp_name : imp, +                        (part_desc) ? part_desc : part, +                        r, p, arch_name); +                else +                    sprintf(dnbuff, "%s %s r%dp%d (arch:%s)",                          (imp_name) ? imp_name : imp,                          (part_desc) ? part_desc : part,                          r, p, arch); diff --git a/modules/devices/arm/arm_data.h b/modules/devices/arm/arm_data.h index 4d1d4cf9..63b3c906 100644 --- a/modules/devices/arm/arm_data.h +++ b/modules/devices/arm/arm_data.h @@ -24,6 +24,8 @@  /* table lookups */  const char *arm_implementer(const char *code);  const char *arm_part(const char *imp_code, const char *part_code); +const char *arm_arch(const char *cpuinfo_arch_str); +const char *arm_arch_more(const char *cpuinfo_arch_str);  /* cpu_implementer, cpu_part, cpu_variant, cpu_revision, cpu_architecture from /proc/cpuinfo   * model_name is returned as a fallback if not enough data is known */ diff --git a/modules/devices/arm/processor.c b/modules/devices/arm/processor.c index c94f41e5..90a17853 100644 --- a/modules/devices/arm/processor.c +++ b/modules/devices/arm/processor.c @@ -184,9 +184,10 @@ processor_scan(void)          processor = (Processor *) pi->data;          /* strings can't be null or segfault later */ -#define UNKIFNULL(f) if (processor->f == NULL) processor->f = g_strdup("(Unknown)"); -#define EMPIFNULL(f) if (processor->f == NULL) processor->f = g_strdup(""); -        UNKIFNULL(model_name); +#define STRIFNULL(f,cs) if (processor->f == NULL) processor->f = g_strdup(cs); +#define UNKIFNULL(f) STRIFNULL(f, "(Unknown)") +#define EMPIFNULL(f) STRIFNULL(f, "") +        STRIFNULL(model_name, "ARM Processor");          EMPIFNULL(flags);          UNKIFNULL(cpu_implementer);          UNKIFNULL(cpu_architecture); @@ -198,6 +199,7 @@ processor_scan(void)              processor->cpu_implementer, processor->cpu_part,              processor->cpu_variant, processor->cpu_revision,              processor->cpu_architecture, processor->model_name); +        UNKIFNULL(decoded_name);          /* freq */          processor->cpukhz_cur = get_cpu_int("cpufreq/scaling_cur_freq", processor->id); @@ -278,7 +280,7 @@ processor_get_detailed_info(Processor *processor)                         "[ARM]\n"                         "Implementer=[%s] %s\n"                         "Part=[%s] %s\n" -                       "Architecture=%s\n" +                       "Architecture=[%s] %s\n"                         "Variant=%s\n"                         "Revision=%s\n"                         "[Capabilities]\n" @@ -293,7 +295,7 @@ processor_get_detailed_info(Processor *processor)                     processor->cpukhz_cur,                     processor->cpu_implementer, (tmp_imp) ? tmp_imp : "",                     processor->cpu_part, (tmp_part) ? tmp_part : "", -                   processor->cpu_architecture, +                   processor->cpu_architecture, arm_arch_more(processor->cpu_architecture),                     processor->cpu_variant,                     processor->cpu_revision,                     tmp_flags, | 
