mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
[v0.89][ARM] Add very basic SoC parsing from cpuinfo/android strings. Only detects two SoCs, but allows debugging
This commit is contained in:
@@ -213,10 +213,6 @@ char* get_str_peak_performance(struct cpuInfo* cpu) {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* get_soc_name(struct cpuInfo* cpu) {
|
|
||||||
return cpu->soc->raw_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_debug(struct cpuInfo* cpu) {
|
void print_debug(struct cpuInfo* cpu) {
|
||||||
int ncores = get_ncores_from_cpuinfo();
|
int ncores = get_ncores_from_cpuinfo();
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ struct frequency* get_frequency_info(uint32_t core);
|
|||||||
struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach);
|
struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach);
|
||||||
|
|
||||||
uint32_t get_nsockets(struct topology* topo);
|
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_topology(struct cpuInfo* cpu, struct topology* topo, bool dual_socket);
|
||||||
char* get_str_peak_performance(struct cpuInfo* cpu);
|
char* get_str_peak_performance(struct cpuInfo* cpu);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,58 @@
|
|||||||
|
|
||||||
#define STRING_UNKNOWN "Unknown"
|
#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__
|
#ifdef __ANDROID__
|
||||||
#include <sys/system_properties.h>
|
#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));
|
soc->raw_name = malloc(sizeof(char) * (property_len + 1));
|
||||||
strncpy(soc->raw_name, tmp, property_len + 1);
|
strncpy(soc->raw_name, tmp, property_len + 1);
|
||||||
soc->raw_name[property_len] = '\0';
|
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);
|
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));
|
soc->raw_name = malloc(sizeof(char) * (property_len + 1));
|
||||||
strncpy(soc->raw_name, tmp, property_len + 1);
|
strncpy(soc->raw_name, tmp, property_len + 1);
|
||||||
soc->raw_name[property_len] = '\0';
|
soc->raw_name[property_len] = '\0';
|
||||||
return soc;
|
soc->soc = SOC_UNKNOWN;
|
||||||
|
return parse_soc_from_string(soc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return soc;
|
return soc;
|
||||||
@@ -49,9 +103,11 @@ struct system_on_chip* guess_soc_from_cpuinfo() {
|
|||||||
if(tmp != NULL) {
|
if(tmp != NULL) {
|
||||||
soc = malloc(sizeof(struct system_on_chip));
|
soc = malloc(sizeof(struct system_on_chip));
|
||||||
soc->raw_name = tmp;
|
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* get_soc() {
|
||||||
@@ -76,3 +132,10 @@ struct system_on_chip* get_soc() {
|
|||||||
|
|
||||||
return 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];
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
#ifndef __SOC__
|
#ifndef __SOC__
|
||||||
#define __SOC__
|
#define __SOC__
|
||||||
|
|
||||||
|
typedef int SOC;
|
||||||
|
|
||||||
struct system_on_chip {
|
struct system_on_chip {
|
||||||
|
SOC soc;
|
||||||
char* raw_name;
|
char* raw_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct system_on_chip* get_soc();
|
struct system_on_chip* get_soc();
|
||||||
|
char* get_soc_name(struct system_on_chip* soc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "../arm/midr.h"
|
#include "../arm/midr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char* VERSION = "0.88";
|
static const char* VERSION = "0.89";
|
||||||
|
|
||||||
void print_help(char *argv[]) {
|
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]);
|
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]);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#else
|
#else
|
||||||
#include "../arm/uarch.h"
|
#include "../arm/uarch.h"
|
||||||
#include "../arm/midr.h"
|
#include "../arm/midr.h"
|
||||||
|
#include "../arm/soc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#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) {
|
bool print_cpufetch_arm(struct ascii* art, struct cpuInfo* cpu, struct colors* cs) {
|
||||||
char* manufacturing_process = get_str_process(cpu);
|
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_SOC,soc_name);
|
||||||
setAttribute(art,ATTRIBUTE_TECHNOLOGY,manufacturing_process);
|
setAttribute(art,ATTRIBUTE_TECHNOLOGY,manufacturing_process);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user