diff --git a/src/arm/midr.c b/src/arm/midr.c index b9d2289..5436188 100644 --- a/src/arm/midr.c +++ b/src/arm/midr.c @@ -213,10 +213,6 @@ char* get_str_peak_performance(struct cpuInfo* cpu) { return string; } -char* get_soc_name(struct cpuInfo* cpu) { - return cpu->soc->raw_name; -} - void print_debug(struct cpuInfo* cpu) { int ncores = get_ncores_from_cpuinfo(); bool success = false; diff --git a/src/arm/midr.h b/src/arm/midr.h index e64eb31..75af86a 100644 --- a/src/arm/midr.h +++ b/src/arm/midr.h @@ -9,7 +9,6 @@ struct frequency* get_frequency_info(uint32_t core); struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach); uint32_t get_nsockets(struct topology* topo); -char* get_soc_name(struct cpuInfo* cpu); char* get_str_topology(struct cpuInfo* cpu, struct topology* topo, bool dual_socket); char* get_str_peak_performance(struct cpuInfo* cpu); diff --git a/src/arm/soc.c b/src/arm/soc.c index 48d4b4b..cfc00ce 100644 --- a/src/arm/soc.c +++ b/src/arm/soc.c @@ -8,6 +8,58 @@ #define STRING_UNKNOWN "Unknown" +enum { + SOC_UNKNOWN, + SOC_MSM8953, + SOC_MSM8974, +}; + +static int socs_array[] = { + SOC_UNKNOWN, + SOC_MSM8953, + SOC_MSM8974, +}; + +static char* socs_string[] = { + "Unknown", + "Snapdragon 625", + "Snapdragon 801", +}; + +static char* socs_raw_string[] = { + "", + "MSM8953", + "MSM8974", +}; + +bool match_msm(char* soc_name, struct system_on_chip* soc) { + char* tmp = strstr(soc_name, "MSM"); + if(tmp == NULL) return false; + + char soc_raw_string[8]; + strncpy(soc_raw_string, tmp, 7); + int len = sizeof(socs_raw_string) / sizeof(socs_raw_string[0]); + int i=1; + + while(i < len && strcmp(soc_raw_string, socs_raw_string[i]) != 0) i++; + + if(i != len) { + soc->soc = socs_array[i]; + return true; + } + + return false; +} + +struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) { + char* raw_name = soc->raw_name; + + if (match_msm(raw_name, soc)) + return soc; + + return soc; +} + #ifdef __ANDROID__ #include @@ -26,7 +78,8 @@ struct system_on_chip* guess_soc_from_android() { soc->raw_name = malloc(sizeof(char) * (property_len + 1)); strncpy(soc->raw_name, tmp, property_len + 1); soc->raw_name[property_len] = '\0'; - return soc; + soc->soc = SOC_UNKNOWN; + return parse_soc_from_string(soc); } property_len = android_property_get("ro.product.board", (char *) &tmp); @@ -35,7 +88,8 @@ struct system_on_chip* guess_soc_from_android() { soc->raw_name = malloc(sizeof(char) * (property_len + 1)); strncpy(soc->raw_name, tmp, property_len + 1); soc->raw_name[property_len] = '\0'; - return soc; + soc->soc = SOC_UNKNOWN; + return parse_soc_from_string(soc); } return soc; @@ -49,13 +103,15 @@ struct system_on_chip* guess_soc_from_cpuinfo() { if(tmp != NULL) { soc = malloc(sizeof(struct system_on_chip)); soc->raw_name = tmp; + soc->soc = SOC_UNKNOWN; + return parse_soc_from_string(soc); } - return soc; + return NULL; } struct system_on_chip* get_soc() { - struct system_on_chip* soc = NULL; + struct system_on_chip* soc = NULL; soc = guess_soc_from_cpuinfo(); if(soc == NULL) { @@ -76,3 +132,10 @@ struct system_on_chip* get_soc() { return soc; } + +char* get_soc_name(struct system_on_chip* soc) { + if(soc->soc == SOC_UNKNOWN) + return soc->raw_name; + return socs_string[soc->soc]; +} + diff --git a/src/arm/soc.h b/src/arm/soc.h index caa1620..b00b50d 100644 --- a/src/arm/soc.h +++ b/src/arm/soc.h @@ -1,10 +1,14 @@ #ifndef __SOC__ #define __SOC__ +typedef int SOC; + struct system_on_chip { + SOC soc; char* raw_name; }; struct system_on_chip* get_soc(); +char* get_soc_name(struct system_on_chip* soc); #endif diff --git a/src/common/main.c b/src/common/main.c index 81de6d8..82617ff 100644 --- a/src/common/main.c +++ b/src/common/main.c @@ -13,7 +13,7 @@ #include "../arm/midr.h" #endif -static const char* VERSION = "0.88"; +static const char* VERSION = "0.89"; void print_help(char *argv[]) { printf("Usage: %s [--version] [--help] [--debug] [--style \"fancy\"|\"retro\"|\"legacy\"] [--color \"intel\"|\"amd\"|'R,G,B:R,G,B:R,G,B:R,G,B']\n\n", argv[0]); diff --git a/src/common/printer.c b/src/common/printer.c index dc093a3..068e8ff 100644 --- a/src/common/printer.c +++ b/src/common/printer.c @@ -14,6 +14,7 @@ #else #include "../arm/uarch.h" #include "../arm/midr.h" + #include "../arm/soc.h" #endif #ifdef _WIN32 @@ -542,7 +543,7 @@ void print_ascii(struct ascii* art) { bool print_cpufetch_arm(struct ascii* art, struct cpuInfo* cpu, struct colors* cs) { char* manufacturing_process = get_str_process(cpu); - char* soc_name = get_soc_name(cpu); + char* soc_name = get_soc_name(cpu->soc); setAttribute(art,ATTRIBUTE_SOC,soc_name); setAttribute(art,ATTRIBUTE_TECHNOLOGY,manufacturing_process);