aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/devices/arm/arm_data.c43
-rw-r--r--modules/devices/arm/arm_data.h2
-rw-r--r--modules/devices/arm/processor.c42
-rw-r--r--modules/devices/x86/processor.c2
4 files changed, 57 insertions, 32 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..ad7adf7f 100644
--- a/modules/devices/arm/processor.c
+++ b/modules/devices/arm/processor.c
@@ -34,24 +34,6 @@ static const gchar *arm_mode_str[] = {
"A32 on A64",
};
-GHashTable *cpu_flags = NULL; /* FIXME: when is it freed? */
-
-static void
-populate_cpu_flags_list_internal()
-{
- int i;
- gchar **afl, *fm;
-
- cpu_flags = g_hash_table_new(g_str_hash, g_str_equal);
- afl = g_strsplit(arm_flag_list(), " ", 0);
- while(afl[i] != NULL) {
- fm = (char *)arm_flag_meaning(afl[i]);
- if (g_strcmp0(afl[i], "") != 0)
- g_hash_table_insert(cpu_flags, afl[i], (fm) ? fm : "");
- i++;
- }
-}
-
static gint get_cpu_int(const gchar* file, gint cpuid) {
gchar *tmp0 = NULL;
gchar *tmp1 = NULL;
@@ -184,9 +166,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 +181,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);
@@ -229,14 +213,11 @@ gchar *processor_get_capabilities_from_flags(gchar * strflags)
gchar *tmp = NULL;
gint j = 0;
- if (!cpu_flags)
- populate_cpu_flags_list_internal();
-
flags = g_strsplit(strflags, " ", 0);
old = flags;
while (flags[j]) {
- gchar *meaning = g_hash_table_lookup(cpu_flags, flags[j]);
+ const gchar *meaning = arm_flag_meaning( flags[j] );
if (meaning) {
tmp = h_strdup_cprintf("%s=%s\n", tmp, flags[j], meaning);
@@ -255,10 +236,12 @@ gchar *processor_get_capabilities_from_flags(gchar * strflags)
gchar *
processor_get_detailed_info(Processor *processor)
{
- gchar *tmp_flags, *tmp_imp, *tmp_part, *ret;
+ gchar *tmp_flags, *tmp_imp, *tmp_part, *tmp_arch, *ret;
tmp_flags = processor_get_capabilities_from_flags(processor->flags);
tmp_imp = (char*)arm_implementer(processor->cpu_implementer);
- tmp_part = (char *)arm_part(processor->cpu_implementer, processor->cpu_part);
+ tmp_part = (char*)arm_part(processor->cpu_implementer, processor->cpu_part);
+ tmp_arch = (char*)arm_arch_more(processor->cpu_architecture);
+
ret = g_strdup_printf("[Processor]\n"
"Linux Name=%s\n"
"Decoded Name=%s\n"
@@ -278,7 +261,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,12 +276,13 @@ 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, (tmp_arch) ? tmp_arch : "",
processor->cpu_variant,
processor->cpu_revision,
tmp_flags,
"");
g_free(tmp_flags);
+
return ret;
}
diff --git a/modules/devices/x86/processor.c b/modules/devices/x86/processor.c
index 7935a83d..25dc6c4a 100644
--- a/modules/devices/x86/processor.c
+++ b/modules/devices/x86/processor.c
@@ -369,7 +369,7 @@ static struct {
{ "tsc", "Time Stamp Counter and RDTSC instruction" },
{ "msr", "Model Specific Registers" },
{ "pae", "Physical Address Extensions" },
- { "mce", "Machine Check Architeture" },
+ { "mce", "Machine Check Architecture" },
{ "cx8", "CMPXCHG8 instruction" },
{ "apic", "Advanced Programmable Interrupt Controller" },
{ "sep", "Fast System Call (SYSENTER/SYSEXIT)" },