mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
Compare commits
1 Commits
284faf84c3
...
bugfix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67a9975aa8 |
@@ -242,7 +242,7 @@ struct cpuInfo* get_cpu_info_linux(struct cpuInfo* cpu) {
|
|||||||
cpu->num_cpus = sockets;
|
cpu->num_cpus = sockets;
|
||||||
cpu->hv = emalloc(sizeof(struct hypervisor));
|
cpu->hv = emalloc(sizeof(struct hypervisor));
|
||||||
cpu->hv->present = false;
|
cpu->hv->present = false;
|
||||||
cpu->soc = get_soc();
|
cpu->soc = get_soc(cpu);
|
||||||
cpu->peak_performance = get_peak_performance(cpu);
|
cpu->peak_performance = get_peak_performance(cpu);
|
||||||
|
|
||||||
return cpu;
|
return cpu;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "uarch.h"
|
||||||
#include "soc.h"
|
#include "soc.h"
|
||||||
#include "socs.h"
|
#include "socs.h"
|
||||||
#include "udev.h"
|
#include "udev.h"
|
||||||
@@ -502,7 +503,18 @@ bool match_allwinner(char* soc_name, struct system_on_chip* soc) {
|
|||||||
SOC_END
|
SOC_END
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match_special(char* soc_name, struct system_on_chip* soc) {
|
bool is_taro_sm8475(struct cpuInfo* cpu) {
|
||||||
|
// Check if X2 core has frequency greater
|
||||||
|
// than 3.0 GHz (plus version should have 3.2 GHz)
|
||||||
|
struct cpuInfo* ptr = cpu;
|
||||||
|
for(int i=0; i < cpu->num_cpus; ptr = ptr->next_cpu, i++) {
|
||||||
|
if(is_cortex_x2(ptr->arch)) return ptr->freq->max > 3100;
|
||||||
|
}
|
||||||
|
printBug("Unable to find Cortex-X2 when differentiating taro SoC");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool match_special(char* soc_name, struct cpuInfo* cpu, struct system_on_chip* soc) {
|
||||||
char* tmp;
|
char* tmp;
|
||||||
|
|
||||||
// Xiaomi hides Redmi Note 8/8T under "Qualcomm Technologies, Inc TRINKET"
|
// Xiaomi hides Redmi Note 8/8T under "Qualcomm Technologies, Inc TRINKET"
|
||||||
@@ -517,19 +529,25 @@ bool match_special(char* soc_name, struct system_on_chip* soc) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Snapdragon 8 Gen 1 reported as "taro"
|
// Snapdragon 8 Gen 1/8+ Gen 1 reported as "taro"
|
||||||
if(strcmp(soc_name, "taro") == 0) {
|
if(strcmp(soc_name, "taro") == 0) {
|
||||||
|
// Is not possible to detect 8/8+ with soc_name only
|
||||||
|
if(is_taro_sm8475(cpu)) {
|
||||||
|
fill_soc(soc, "8+ Gen 1", SOC_SNAPD_SM8475, 4);
|
||||||
|
}
|
||||||
|
else {
|
||||||
fill_soc(soc, "8 Gen 1", SOC_SNAPD_SM8450, 4);
|
fill_soc(soc, "8 Gen 1", SOC_SNAPD_SM8450, 4);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) {
|
struct system_on_chip* parse_soc_from_string(struct cpuInfo* cpu, struct system_on_chip* soc) {
|
||||||
char* raw_name = soc->raw_name;
|
char* raw_name = soc->raw_name;
|
||||||
|
|
||||||
if(match_special(raw_name, soc))
|
if(match_special(raw_name, cpu, soc))
|
||||||
return soc;
|
return soc;
|
||||||
|
|
||||||
if (match_qualcomm(raw_name, soc))
|
if (match_qualcomm(raw_name, soc))
|
||||||
@@ -558,35 +576,35 @@ static inline int android_property_get(const char* key, char* value) {
|
|||||||
return __system_property_get(key, value);
|
return __system_property_get(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void try_parse_soc_from_string(struct system_on_chip* soc, int soc_len, char* soc_str) {
|
void try_parse_soc_from_string(struct cpuInfo* cpu, struct system_on_chip* soc, int soc_len, char* soc_str) {
|
||||||
soc->raw_name = emalloc(sizeof(char) * (soc_len + 1));
|
soc->raw_name = emalloc(sizeof(char) * (soc_len + 1));
|
||||||
strncpy(soc->raw_name, soc_str, soc_len + 1);
|
strncpy(soc->raw_name, soc_str, soc_len + 1);
|
||||||
soc->raw_name[soc_len] = '\0';
|
soc->raw_name[soc_len] = '\0';
|
||||||
soc->soc_vendor = SOC_VENDOR_UNKNOWN;
|
soc->soc_vendor = SOC_VENDOR_UNKNOWN;
|
||||||
parse_soc_from_string(soc);
|
parse_soc_from_string(cpu, soc);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct system_on_chip* guess_soc_from_android(struct system_on_chip* soc) {
|
struct system_on_chip* guess_soc_from_android(struct cpuInfo* cpu, struct system_on_chip* soc) {
|
||||||
char tmp[100];
|
char tmp[100];
|
||||||
int property_len = 0;
|
int property_len = 0;
|
||||||
|
|
||||||
property_len = android_property_get("ro.mediatek.platform", (char *) &tmp);
|
property_len = android_property_get("ro.mediatek.platform", (char *) &tmp);
|
||||||
if(property_len > 0) {
|
if(property_len > 0) {
|
||||||
try_parse_soc_from_string(soc, property_len, tmp);
|
try_parse_soc_from_string(cpu, soc, property_len, tmp);
|
||||||
if(soc->soc_vendor == SOC_VENDOR_UNKNOWN) printWarn("SoC detection failed using Android property ro.mediatek.platform: %s", tmp);
|
if(soc->soc_vendor == SOC_VENDOR_UNKNOWN) printWarn("SoC detection failed using Android property ro.mediatek.platform: %s", tmp);
|
||||||
else return soc;
|
else return soc;
|
||||||
}
|
}
|
||||||
|
|
||||||
property_len = android_property_get("ro.product.board", (char *) &tmp);
|
property_len = android_property_get("ro.product.board", (char *) &tmp);
|
||||||
if(property_len > 0) {
|
if(property_len > 0) {
|
||||||
try_parse_soc_from_string(soc, property_len, tmp);
|
try_parse_soc_from_string(cpu, soc, property_len, tmp);
|
||||||
if(soc->soc_vendor == SOC_VENDOR_UNKNOWN) printWarn("SoC detection failed using Android property ro.product.board: %s", tmp);
|
if(soc->soc_vendor == SOC_VENDOR_UNKNOWN) printWarn("SoC detection failed using Android property ro.product.board: %s", tmp);
|
||||||
else return soc;
|
else return soc;
|
||||||
}
|
}
|
||||||
|
|
||||||
property_len = android_property_get("ro.board.platform", (char *) &tmp);
|
property_len = android_property_get("ro.board.platform", (char *) &tmp);
|
||||||
if(property_len > 0) {
|
if(property_len > 0) {
|
||||||
try_parse_soc_from_string(soc, property_len, tmp);
|
try_parse_soc_from_string(cpu, soc, property_len, tmp);
|
||||||
if(soc->soc_vendor == SOC_VENDOR_UNKNOWN) printWarn("SoC detection failed using Android property ro.board.platform: %s", tmp);
|
if(soc->soc_vendor == SOC_VENDOR_UNKNOWN) printWarn("SoC detection failed using Android property ro.board.platform: %s", tmp);
|
||||||
else return soc;
|
else return soc;
|
||||||
}
|
}
|
||||||
@@ -595,12 +613,12 @@ struct system_on_chip* guess_soc_from_android(struct system_on_chip* soc) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct system_on_chip* guess_soc_from_cpuinfo(struct system_on_chip* soc) {
|
struct system_on_chip* guess_soc_from_cpuinfo(struct cpuInfo* cpu, struct system_on_chip* soc) {
|
||||||
char* tmp = get_hardware_from_cpuinfo();
|
char* tmp = get_hardware_from_cpuinfo();
|
||||||
|
|
||||||
if(tmp != NULL) {
|
if(tmp != NULL) {
|
||||||
soc->raw_name = tmp;
|
soc->raw_name = tmp;
|
||||||
return parse_soc_from_string(soc);
|
return parse_soc_from_string(cpu, soc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return soc;
|
return soc;
|
||||||
@@ -702,7 +720,7 @@ struct system_on_chip* guess_soc_apple(struct system_on_chip* soc) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct system_on_chip* get_soc() {
|
struct system_on_chip* get_soc(struct cpuInfo* cpu) {
|
||||||
struct system_on_chip* soc = emalloc(sizeof(struct system_on_chip));
|
struct system_on_chip* soc = emalloc(sizeof(struct system_on_chip));
|
||||||
soc->raw_name = NULL;
|
soc->raw_name = NULL;
|
||||||
soc->soc_vendor = SOC_VENDOR_UNKNOWN;
|
soc->soc_vendor = SOC_VENDOR_UNKNOWN;
|
||||||
@@ -720,14 +738,14 @@ struct system_on_chip* get_soc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
soc = guess_soc_from_cpuinfo(soc);
|
soc = guess_soc_from_cpuinfo(cpu, soc);
|
||||||
if(soc->soc_vendor == SOC_VENDOR_UNKNOWN) {
|
if(soc->soc_vendor == SOC_VENDOR_UNKNOWN) {
|
||||||
if(soc->raw_name != NULL)
|
if(soc->raw_name != NULL)
|
||||||
printWarn("SoC detection failed using /proc/cpuinfo: Found '%s' string", soc->raw_name);
|
printWarn("SoC detection failed using /proc/cpuinfo: Found '%s' string", soc->raw_name);
|
||||||
else
|
else
|
||||||
printWarn("SoC detection failed using /proc/cpuinfo: No string found");
|
printWarn("SoC detection failed using /proc/cpuinfo: No string found");
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
soc = guess_soc_from_android(soc);
|
soc = guess_soc_from_android(cpu, soc);
|
||||||
if(soc->raw_name == NULL)
|
if(soc->raw_name == NULL)
|
||||||
printWarn("SoC detection failed using Android: No string found");
|
printWarn("SoC detection failed using Android: No string found");
|
||||||
else if(soc->soc_vendor == SOC_VENDOR_UNKNOWN)
|
else if(soc->soc_vendor == SOC_VENDOR_UNKNOWN)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ struct system_on_chip {
|
|||||||
char* raw_name;
|
char* raw_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct system_on_chip* get_soc();
|
struct system_on_chip* get_soc(struct cpuInfo* cpu);
|
||||||
char* get_soc_name(struct system_on_chip* soc);
|
char* get_soc_name(struct system_on_chip* soc);
|
||||||
VENDOR get_soc_vendor(struct system_on_chip* soc);
|
VENDOR get_soc_vendor(struct system_on_chip* soc);
|
||||||
char* get_str_process(struct system_on_chip* soc);
|
char* get_str_process(struct system_on_chip* soc);
|
||||||
|
|||||||
@@ -253,6 +253,7 @@ enum {
|
|||||||
SOC_SNAPD_SM8250_AB,
|
SOC_SNAPD_SM8250_AB,
|
||||||
SOC_SNAPD_SM8350,
|
SOC_SNAPD_SM8350,
|
||||||
SOC_SNAPD_SM8450,
|
SOC_SNAPD_SM8450,
|
||||||
|
SOC_SNAPD_SM8475,
|
||||||
// APPLE
|
// APPLE
|
||||||
SOC_APPLE_M1,
|
SOC_APPLE_M1,
|
||||||
SOC_APPLE_M1_PRO,
|
SOC_APPLE_M1_PRO,
|
||||||
@@ -290,7 +291,7 @@ inline static VENDOR get_soc_vendor_from_soc(SOC soc) {
|
|||||||
else if(soc >= SOC_HISILICON_3620 && soc <= SOC_HISILICON_3690) return SOC_VENDOR_KIRIN;
|
else if(soc >= SOC_HISILICON_3620 && soc <= SOC_HISILICON_3690) return SOC_VENDOR_KIRIN;
|
||||||
else if(soc >= SOC_EXYNOS_3475 && soc <= SOC_EXYNOS_880) return SOC_VENDOR_EXYNOS;
|
else if(soc >= SOC_EXYNOS_3475 && soc <= SOC_EXYNOS_880) return SOC_VENDOR_EXYNOS;
|
||||||
else if(soc >= SOC_MTK_MT6893 && soc <= SOC_MTK_MT8783) return SOC_VENDOR_MEDIATEK;
|
else if(soc >= SOC_MTK_MT6893 && soc <= SOC_MTK_MT8783) return SOC_VENDOR_MEDIATEK;
|
||||||
else if(soc >= SOC_SNAPD_QSD8650 && soc <= SOC_SNAPD_SM8450) return SOC_VENDOR_SNAPDRAGON;
|
else if(soc >= SOC_SNAPD_QSD8650 && soc <= SOC_SNAPD_SM8475) return SOC_VENDOR_SNAPDRAGON;
|
||||||
else if(soc >= SOC_APPLE_M1 && soc <= SOC_APPLE_M2) return SOC_VENDOR_APPLE;
|
else if(soc >= SOC_APPLE_M1 && soc <= SOC_APPLE_M2) return SOC_VENDOR_APPLE;
|
||||||
else if(soc >= SOC_ALLWINNER_A10 && soc <= SOC_ALLWINNER_R328) return SOC_VENDOR_ALLWINNER;
|
else if(soc >= SOC_ALLWINNER_A10 && soc <= SOC_ALLWINNER_R328) return SOC_VENDOR_ALLWINNER;
|
||||||
return SOC_VENDOR_UNKNOWN;
|
return SOC_VENDOR_UNKNOWN;
|
||||||
|
|||||||
@@ -333,3 +333,7 @@ void free_uarch_struct(struct uarch* arch) {
|
|||||||
free(arch->uarch_str);
|
free(arch->uarch_str);
|
||||||
free(arch);
|
free(arch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_cortex_x2(struct uarch* arch) {
|
||||||
|
return arch->uarch == UARCH_CORTEX_X2;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,5 +8,6 @@
|
|||||||
struct uarch* get_uarch_from_midr(uint32_t midr, struct cpuInfo* cpu);
|
struct uarch* get_uarch_from_midr(uint32_t midr, struct cpuInfo* cpu);
|
||||||
char* get_str_uarch(struct cpuInfo* cpu);
|
char* get_str_uarch(struct cpuInfo* cpu);
|
||||||
void free_uarch_struct(struct uarch* arch);
|
void free_uarch_struct(struct uarch* arch);
|
||||||
|
bool is_cortex_x2(struct uarch* arch);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user