[v0.89][ARM] Add very basic SoC parsing from cpuinfo/android strings. Only detects two SoCs, but allows debugging

This commit is contained in:
Dr-Noob
2020-11-24 11:44:24 +01:00
parent 685e78f2b7
commit 220dd02abd
6 changed files with 74 additions and 11 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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 <sys/system_properties.h>
@@ -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];
}

View File

@@ -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