mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
176f2f553f | ||
|
|
91de8c7a85 | ||
|
|
5ffee22dbf | ||
|
|
2c1b8a2362 | ||
|
|
727c49fdae | ||
|
|
56e8cc7503 | ||
|
|
6ae51f2b52 |
107
src/arm/midr.c
107
src/arm/midr.c
@@ -289,7 +289,7 @@ void fill_cpu_info_avalanche_blizzard(struct cpuInfo* cpu, uint32_t pcores, uint
|
|||||||
bli->feat = get_features_info();
|
bli->feat = get_features_info();
|
||||||
bli->topo = malloc(sizeof(struct topology));
|
bli->topo = malloc(sizeof(struct topology));
|
||||||
bli->topo->cach = bli->cach;
|
bli->topo->cach = bli->cach;
|
||||||
bli->topo->total_cores = ecores;
|
bli->topo->total_cores = pcores;
|
||||||
bli->freq = malloc(sizeof(struct frequency));
|
bli->freq = malloc(sizeof(struct frequency));
|
||||||
bli->freq->base = UNKNOWN_DATA;
|
bli->freq->base = UNKNOWN_DATA;
|
||||||
bli->freq->max = 2800;
|
bli->freq->max = 2800;
|
||||||
@@ -305,7 +305,7 @@ void fill_cpu_info_avalanche_blizzard(struct cpuInfo* cpu, uint32_t pcores, uint
|
|||||||
ava->feat = get_features_info();
|
ava->feat = get_features_info();
|
||||||
ava->topo = malloc(sizeof(struct topology));
|
ava->topo = malloc(sizeof(struct topology));
|
||||||
ava->topo->cach = ava->cach;
|
ava->topo->cach = ava->cach;
|
||||||
ava->topo->total_cores = pcores;
|
ava->topo->total_cores = ecores;
|
||||||
ava->freq = malloc(sizeof(struct frequency));
|
ava->freq = malloc(sizeof(struct frequency));
|
||||||
ava->freq->base = UNKNOWN_DATA;
|
ava->freq->base = UNKNOWN_DATA;
|
||||||
ava->freq->max = 3500;
|
ava->freq->max = 3500;
|
||||||
@@ -324,7 +324,7 @@ void fill_cpu_info_everest_sawtooth(struct cpuInfo* cpu, uint32_t pcores, uint32
|
|||||||
saw->feat = get_features_info();
|
saw->feat = get_features_info();
|
||||||
saw->topo = malloc(sizeof(struct topology));
|
saw->topo = malloc(sizeof(struct topology));
|
||||||
saw->topo->cach = saw->cach;
|
saw->topo->cach = saw->cach;
|
||||||
saw->topo->total_cores = ecores;
|
saw->topo->total_cores = pcores;
|
||||||
saw->freq = malloc(sizeof(struct frequency));
|
saw->freq = malloc(sizeof(struct frequency));
|
||||||
saw->freq->base = UNKNOWN_DATA;
|
saw->freq->base = UNKNOWN_DATA;
|
||||||
saw->freq->max = 2750;
|
saw->freq->max = 2750;
|
||||||
@@ -340,7 +340,7 @@ void fill_cpu_info_everest_sawtooth(struct cpuInfo* cpu, uint32_t pcores, uint32
|
|||||||
eve->feat = get_features_info();
|
eve->feat = get_features_info();
|
||||||
eve->topo = malloc(sizeof(struct topology));
|
eve->topo = malloc(sizeof(struct topology));
|
||||||
eve->topo->cach = eve->cach;
|
eve->topo->cach = eve->cach;
|
||||||
eve->topo->total_cores = pcores;
|
eve->topo->total_cores = ecores;
|
||||||
eve->freq = malloc(sizeof(struct frequency));
|
eve->freq = malloc(sizeof(struct frequency));
|
||||||
eve->freq->base = UNKNOWN_DATA;
|
eve->freq->base = UNKNOWN_DATA;
|
||||||
eve->freq->max = 4050;
|
eve->freq->max = 4050;
|
||||||
@@ -350,42 +350,92 @@ void fill_cpu_info_everest_sawtooth(struct cpuInfo* cpu, uint32_t pcores, uint32
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct cpuInfo* get_cpu_info_mach(struct cpuInfo* cpu) {
|
struct cpuInfo* get_cpu_info_mach(struct cpuInfo* cpu) {
|
||||||
// https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_system_capabilities
|
|
||||||
uint32_t nperflevels = get_sys_info_by_name("hw.nperflevels");
|
|
||||||
|
|
||||||
if((cpu->num_cpus = nperflevels) != 2) {
|
|
||||||
printBug("Expected to find SoC with 2 perf levels, found: %d", cpu->num_cpus);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t pcores = get_sys_info_by_name("hw.perflevel0.physicalcpu");
|
|
||||||
uint32_t ecores = get_sys_info_by_name("hw.perflevel1.physicalcpu");
|
|
||||||
if(ecores <= 0) {
|
|
||||||
printBug("Expected to find a numer of ecores > 0, found: %d", ecores);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if(pcores <= 0) {
|
|
||||||
printBug("Expected to find a numer of pcores > 0, found: %d", pcores);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
|
uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
|
||||||
|
|
||||||
// Manually fill the cpuInfo assuming that
|
// Manually fill the cpuInfo assuming that
|
||||||
// the CPU is an Apple SoC
|
// the CPU is an Apple M1/M2
|
||||||
if(cpu_family == CPUFAMILY_ARM_FIRESTORM_ICESTORM) {
|
if(cpu_family == CPUFAMILY_ARM_FIRESTORM_ICESTORM) {
|
||||||
fill_cpu_info_firestorm_icestorm(cpu, pcores, ecores);
|
cpu->num_cpus = 2;
|
||||||
|
// Now detect the M1 version
|
||||||
|
uint32_t cpu_subfamily = get_sys_info_by_name("hw.cpusubfamily");
|
||||||
|
if(cpu_subfamily == CPUSUBFAMILY_ARM_HG) {
|
||||||
|
// Apple M1
|
||||||
|
fill_cpu_info_firestorm_icestorm(cpu, 4, 4);
|
||||||
|
}
|
||||||
|
else if(cpu_subfamily == CPUSUBFAMILY_ARM_HS || cpu_subfamily == CPUSUBFAMILY_ARM_HC_HD) {
|
||||||
|
// Apple M1 Pro/Max/Ultra. Detect number of cores
|
||||||
|
uint32_t physicalcpu = get_sys_info_by_name("hw.physicalcpu");
|
||||||
|
if(physicalcpu == 20) {
|
||||||
|
// M1 Ultra
|
||||||
|
fill_cpu_info_firestorm_icestorm(cpu, 16, 4);
|
||||||
|
}
|
||||||
|
else if(physicalcpu == 8 || physicalcpu == 10) {
|
||||||
|
// M1 Pro/Max
|
||||||
|
fill_cpu_info_firestorm_icestorm(cpu, physicalcpu-2, 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printBug("Found invalid physical cpu number: %d", physicalcpu);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printBug("Found invalid cpu_subfamily: 0x%.8X", cpu_subfamily);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
cpu->soc = get_soc();
|
cpu->soc = get_soc();
|
||||||
cpu->peak_performance = get_peak_performance(cpu);
|
cpu->peak_performance = get_peak_performance(cpu);
|
||||||
}
|
}
|
||||||
else if(cpu_family == CPUFAMILY_ARM_AVALANCHE_BLIZZARD) {
|
else if(cpu_family == CPUFAMILY_ARM_AVALANCHE_BLIZZARD) {
|
||||||
fill_cpu_info_avalanche_blizzard(cpu, pcores, ecores);
|
cpu->num_cpus = 2;
|
||||||
|
// Now detect the M2 version
|
||||||
|
uint32_t cpu_subfamily = get_sys_info_by_name("hw.cpusubfamily");
|
||||||
|
if(cpu_subfamily == CPUSUBFAMILY_ARM_HG) {
|
||||||
|
// Apple M2
|
||||||
|
fill_cpu_info_avalanche_blizzard(cpu, 4, 4);
|
||||||
|
}
|
||||||
|
else if(cpu_subfamily == CPUSUBFAMILY_ARM_HS) {
|
||||||
|
// Apple M2 Pro/Max/Ultra. Detect number of cores
|
||||||
|
uint32_t physicalcpu = get_sys_info_by_name("hw.physicalcpu");
|
||||||
|
if(physicalcpu == 24) {
|
||||||
|
// M2 Ultra
|
||||||
|
fill_cpu_info_avalanche_blizzard(cpu, 16, 8);
|
||||||
|
}
|
||||||
|
else if(physicalcpu == 10 || physicalcpu == 12) {
|
||||||
|
// M2 Pro/Max
|
||||||
|
fill_cpu_info_avalanche_blizzard(cpu, physicalcpu-4, 4);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printBug("Found invalid physical cpu number: %d", physicalcpu);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printBug("Found invalid cpu_subfamily: 0x%.8X", cpu_subfamily);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
cpu->soc = get_soc();
|
cpu->soc = get_soc();
|
||||||
cpu->peak_performance = get_peak_performance(cpu);
|
cpu->peak_performance = get_peak_performance(cpu);
|
||||||
}
|
}
|
||||||
else if(cpu_family == CPUFAMILY_ARM_EVEREST_SAWTOOTH ||
|
else if(cpu_family == CPUFAMILY_ARM_EVEREST_SAWTOOTH ||
|
||||||
cpu_family == CPUFAMILY_ARM_EVEREST_SAWTOOTH_PRO ||
|
cpu_family == CPUFAMILY_ARM_EVEREST_SAWTOOTH_PRO ||
|
||||||
cpu_family == CPUFAMILY_ARM_EVEREST_SAWTOOTH_MAX) {
|
cpu_family == CPUFAMILY_ARM_EVEREST_SAWTOOTH_MAX) {
|
||||||
fill_cpu_info_everest_sawtooth(cpu, pcores, ecores);
|
cpu->num_cpus = 2;
|
||||||
|
// Now detect the M3 version
|
||||||
|
if(cpu_family == CPUFAMILY_ARM_EVEREST_SAWTOOTH) {
|
||||||
|
fill_cpu_info_everest_sawtooth(cpu, 4, 4);
|
||||||
|
}
|
||||||
|
else if(cpu_family == CPUFAMILY_ARM_EVEREST_SAWTOOTH_PRO) {
|
||||||
|
uint32_t physicalcpu = get_sys_info_by_name("hw.physicalcpu");
|
||||||
|
fill_cpu_info_everest_sawtooth(cpu, physicalcpu-6, 6);
|
||||||
|
}
|
||||||
|
else if(cpu_family == CPUFAMILY_ARM_EVEREST_SAWTOOTH_MAX) {
|
||||||
|
uint32_t physicalcpu = get_sys_info_by_name("hw.physicalcpu");
|
||||||
|
fill_cpu_info_everest_sawtooth(cpu, physicalcpu-4, 4);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printBug("Found invalid cpu_family: 0x%.8X", cpu_family);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
cpu->soc = get_soc();
|
cpu->soc = get_soc();
|
||||||
cpu->peak_performance = get_peak_performance(cpu);
|
cpu->peak_performance = get_peak_performance(cpu);
|
||||||
}
|
}
|
||||||
@@ -479,10 +529,7 @@ void print_debug(struct cpuInfo* cpu) {
|
|||||||
#if defined(__APPLE__) || defined(__MACH__)
|
#if defined(__APPLE__) || defined(__MACH__)
|
||||||
printf("hw.cpufamily: 0x%.8X\n", get_sys_info_by_name("hw.cpufamily"));
|
printf("hw.cpufamily: 0x%.8X\n", get_sys_info_by_name("hw.cpufamily"));
|
||||||
printf("hw.cpusubfamily: 0x%.8X\n", get_sys_info_by_name("hw.cpusubfamily"));
|
printf("hw.cpusubfamily: 0x%.8X\n", get_sys_info_by_name("hw.cpusubfamily"));
|
||||||
printf("hw.nperflevels: %d\n", get_sys_info_by_name("hw.nperflevels"));
|
|
||||||
printf("hw.physicalcpu: %d\n", get_sys_info_by_name("hw.physicalcpu"));
|
printf("hw.physicalcpu: %d\n", get_sys_info_by_name("hw.physicalcpu"));
|
||||||
printf("hw.perflevel0.physicalcpu: %d\n", get_sys_info_by_name("hw.perflevel0.physicalcpu"));
|
|
||||||
printf("hw.perflevel1.physicalcpu: %d\n", get_sys_info_by_name("hw.perflevel1.physicalcpu"));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -734,7 +734,6 @@ bool get_rk_soc_from_efuse(struct system_on_chip* soc, char* efuse) {
|
|||||||
rkToSoC socFromRK[] = {
|
rkToSoC socFromRK[] = {
|
||||||
// TODO: Add RK2XXX
|
// TODO: Add RK2XXX
|
||||||
// RK3XXX
|
// RK3XXX
|
||||||
// Reverse order
|
|
||||||
{0x2388, {SOC_ROCKCHIP_3288, SOC_VENDOR_ROCKCHIP, 28, "RK3288", NULL} },
|
{0x2388, {SOC_ROCKCHIP_3288, SOC_VENDOR_ROCKCHIP, 28, "RK3288", NULL} },
|
||||||
{0x2392, {SOC_ROCKCHIP_3229, SOC_VENDOR_ROCKCHIP, 28, "RK3229", NULL} }, // https://gadgetversus.com/processor/rockchip-rk3229-vs-rockchip-rk3128/
|
{0x2392, {SOC_ROCKCHIP_3229, SOC_VENDOR_ROCKCHIP, 28, "RK3229", NULL} }, // https://gadgetversus.com/processor/rockchip-rk3229-vs-rockchip-rk3128/
|
||||||
{0x3380, {SOC_ROCKCHIP_3308, SOC_VENDOR_ROCKCHIP, 28, "RK3308", NULL} }, // https://en.t-firefly.com/product/rocrk3308cc?theme=pc
|
{0x3380, {SOC_ROCKCHIP_3308, SOC_VENDOR_ROCKCHIP, 28, "RK3308", NULL} }, // https://en.t-firefly.com/product/rocrk3308cc?theme=pc
|
||||||
@@ -743,12 +742,10 @@ bool get_rk_soc_from_efuse(struct system_on_chip* soc, char* efuse) {
|
|||||||
{0x3382, {SOC_ROCKCHIP_3328, SOC_VENDOR_ROCKCHIP, 28, "RK3328", NULL} },
|
{0x3382, {SOC_ROCKCHIP_3328, SOC_VENDOR_ROCKCHIP, 28, "RK3328", NULL} },
|
||||||
{0x3386, {SOC_ROCKCHIP_3368, SOC_VENDOR_ROCKCHIP, 28, "RK3368", NULL} },
|
{0x3386, {SOC_ROCKCHIP_3368, SOC_VENDOR_ROCKCHIP, 28, "RK3368", NULL} },
|
||||||
{0x3399, {SOC_ROCKCHIP_3399, SOC_VENDOR_ROCKCHIP, 28, "RK3399", NULL} },
|
{0x3399, {SOC_ROCKCHIP_3399, SOC_VENDOR_ROCKCHIP, 28, "RK3399", NULL} },
|
||||||
// Normal Order (https://github.com/Dr-Noob/cpufetch/issues/209)
|
{0x5366, {SOC_ROCKCHIP_3566, SOC_VENDOR_ROCKCHIP, 22, "RK3566", NULL} },
|
||||||
{0x3528, {SOC_ROCKCHIP_3528, SOC_VENDOR_ROCKCHIP, 28, "RK3528", NULL} },
|
{0x5386, {SOC_ROCKCHIP_3568, SOC_VENDOR_ROCKCHIP, 22, "RK3568", NULL} },
|
||||||
{0x3562, {SOC_ROCKCHIP_3562, SOC_VENDOR_ROCKCHIP, 22, "RK3562", NULL} },
|
{0x5388, {SOC_ROCKCHIP_3588, SOC_VENDOR_ROCKCHIP, 8, "RK3588", NULL} },
|
||||||
{0x3566, {SOC_ROCKCHIP_3566, SOC_VENDOR_ROCKCHIP, 22, "RK3566", NULL} },
|
{0x3588, {SOC_ROCKCHIP_3588S, SOC_VENDOR_ROCKCHIP, 8, "RK3588S", NULL} }, // https://github.com/Dr-Noob/cpufetch/issues/188
|
||||||
{0x3568, {SOC_ROCKCHIP_3568, SOC_VENDOR_ROCKCHIP, 22, "RK3568", NULL} },
|
|
||||||
{0x3588, {SOC_ROCKCHIP_3588, SOC_VENDOR_ROCKCHIP, 8, "RK3588", NULL} }, // No known way to distingish between S version: https://github.com/Dr-Noob/cpufetch/issues/188,209
|
|
||||||
// Unknown
|
// Unknown
|
||||||
{0x0000, {UNKNOWN, SOC_VENDOR_UNKNOWN, -1, "", NULL} }
|
{0x0000, {UNKNOWN, SOC_VENDOR_UNKNOWN, -1, "", NULL} }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -349,11 +349,10 @@ enum {
|
|||||||
SOC_ROCKCHIP_3328,
|
SOC_ROCKCHIP_3328,
|
||||||
SOC_ROCKCHIP_3368,
|
SOC_ROCKCHIP_3368,
|
||||||
SOC_ROCKCHIP_3399,
|
SOC_ROCKCHIP_3399,
|
||||||
SOC_ROCKCHIP_3528,
|
|
||||||
SOC_ROCKCHIP_3562,
|
|
||||||
SOC_ROCKCHIP_3566,
|
SOC_ROCKCHIP_3566,
|
||||||
SOC_ROCKCHIP_3568,
|
SOC_ROCKCHIP_3568,
|
||||||
SOC_ROCKCHIP_3588,
|
SOC_ROCKCHIP_3588,
|
||||||
|
SOC_ROCKCHIP_3588S,
|
||||||
// GOOGLE
|
// GOOGLE
|
||||||
SOC_GOOGLE_TENSOR,
|
SOC_GOOGLE_TENSOR,
|
||||||
SOC_GOOGLE_TENSOR_G2,
|
SOC_GOOGLE_TENSOR_G2,
|
||||||
@@ -370,7 +369,7 @@ inline static VENDOR get_soc_vendor_from_soc(SOC soc) {
|
|||||||
else if(soc >= SOC_SNAPD_QSD8650 && soc <= SOC_SNAPD_SM8450) return SOC_VENDOR_SNAPDRAGON;
|
else if(soc >= SOC_SNAPD_QSD8650 && soc <= SOC_SNAPD_SM8450) return SOC_VENDOR_SNAPDRAGON;
|
||||||
else if(soc >= SOC_APPLE_M1 && soc <= SOC_APPLE_M3_MAX) return SOC_VENDOR_APPLE;
|
else if(soc >= SOC_APPLE_M1 && soc <= SOC_APPLE_M3_MAX) 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;
|
||||||
else if(soc >= SOC_ROCKCHIP_3288 && soc <= SOC_ROCKCHIP_3588) return SOC_VENDOR_ROCKCHIP;
|
else if(soc >= SOC_ROCKCHIP_3288 && soc <= SOC_ROCKCHIP_3588S) return SOC_VENDOR_ROCKCHIP;
|
||||||
else if(soc >= SOC_GOOGLE_TENSOR && soc <= SOC_GOOGLE_TENSOR_G3) return SOC_VENDOR_GOOGLE;
|
else if(soc >= SOC_GOOGLE_TENSOR && soc <= SOC_GOOGLE_TENSOR_G3) return SOC_VENDOR_GOOGLE;
|
||||||
return SOC_VENDOR_UNKNOWN;
|
return SOC_VENDOR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ void init_topology_struct(struct topology* topo, struct cache* cach) {
|
|||||||
topo->sockets = 0;
|
topo->sockets = 0;
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
topo->smt_available = 0;
|
topo->smt_available = 0;
|
||||||
topo->apic = ecalloc(1, sizeof(struct apic));
|
topo->apic = emalloc(sizeof(struct apic));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ enum {
|
|||||||
HV_VENDOR_PARALLELS,
|
HV_VENDOR_PARALLELS,
|
||||||
HV_VENDOR_PHYP,
|
HV_VENDOR_PHYP,
|
||||||
HV_VENDOR_BHYVE,
|
HV_VENDOR_BHYVE,
|
||||||
HV_VENDOR_APPLEVZ,
|
|
||||||
HV_VENDOR_INVALID
|
HV_VENDOR_INVALID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
static const char* ARCH_STR = "x86 / x86_64 build";
|
static const char* ARCH_STR = "x86_64 build";
|
||||||
#include "../x86/cpuid.h"
|
#include "../x86/cpuid.h"
|
||||||
#elif ARCH_PPC
|
#elif ARCH_PPC
|
||||||
static const char* ARCH_STR = "PowerPC build";
|
static const char* ARCH_STR = "PowerPC build";
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ static char *hv_vendors_name[] = {
|
|||||||
[HV_VENDOR_PARALLELS] = "Parallels",
|
[HV_VENDOR_PARALLELS] = "Parallels",
|
||||||
[HV_VENDOR_PHYP] = "pHyp",
|
[HV_VENDOR_PHYP] = "pHyp",
|
||||||
[HV_VENDOR_BHYVE] = "bhyve",
|
[HV_VENDOR_BHYVE] = "bhyve",
|
||||||
[HV_VENDOR_APPLEVZ] = "Apple VZ",
|
|
||||||
[HV_VENDOR_INVALID] = STRING_UNKNOWN
|
[HV_VENDOR_INVALID] = STRING_UNKNOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -280,6 +280,9 @@ char* get_str_process(struct cpuInfo* cpu) {
|
|||||||
if(process == UNK) {
|
if(process == UNK) {
|
||||||
snprintf(str, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
|
snprintf(str, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
else if(process > 100) {
|
||||||
|
sprintf(str, "%.2fum", (double)process/100);
|
||||||
|
}
|
||||||
else if(process > 0){
|
else if(process > 0){
|
||||||
sprintf(str, "%dnm", process);
|
sprintf(str, "%dnm", process);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,8 @@ static const char *hv_vendors_string[] = {
|
|||||||
[HV_VENDOR_VMWARE] = "VMwareVMware",
|
[HV_VENDOR_VMWARE] = "VMwareVMware",
|
||||||
[HV_VENDOR_XEN] = "XenVMMXenVMM",
|
[HV_VENDOR_XEN] = "XenVMMXenVMM",
|
||||||
[HV_VENDOR_PARALLELS] = "lrpepyh vr",
|
[HV_VENDOR_PARALLELS] = "lrpepyh vr",
|
||||||
[HV_VENDOR_PHYP] = NULL,
|
|
||||||
[HV_VENDOR_BHYVE] = "bhyve bhyve ",
|
[HV_VENDOR_BHYVE] = "bhyve bhyve ",
|
||||||
[HV_VENDOR_APPLEVZ] = "Apple VZ"
|
[HV_VENDOR_PHYP] = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *hv_vendors_name[] = {
|
static char *hv_vendors_name[] = {
|
||||||
@@ -44,7 +43,6 @@ static char *hv_vendors_name[] = {
|
|||||||
[HV_VENDOR_PARALLELS] = "Parallels",
|
[HV_VENDOR_PARALLELS] = "Parallels",
|
||||||
[HV_VENDOR_PHYP] = "pHyp",
|
[HV_VENDOR_PHYP] = "pHyp",
|
||||||
[HV_VENDOR_BHYVE] = "bhyve",
|
[HV_VENDOR_BHYVE] = "bhyve",
|
||||||
[HV_VENDOR_APPLEVZ] = "Apple VZ",
|
|
||||||
[HV_VENDOR_INVALID] = STRING_UNKNOWN
|
[HV_VENDOR_INVALID] = STRING_UNKNOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -286,7 +284,7 @@ struct hypervisor* get_hp_info(bool hv_present) {
|
|||||||
|
|
||||||
if(!found) {
|
if(!found) {
|
||||||
hv->hv_vendor = HV_VENDOR_INVALID;
|
hv->hv_vendor = HV_VENDOR_INVALID;
|
||||||
printBug("Unknown hypervisor vendor: '%s'", name);
|
printBug("Unknown hypervisor vendor: %s", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,8 +484,9 @@ struct cpuInfo* get_cpu_info(void) {
|
|||||||
cpu->cpu_name = get_str_cpu_name_internal();
|
cpu->cpu_name = get_str_cpu_name_internal();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cpu->cpu_name = NULL;
|
cpu->cpu_name = emalloc(sizeof(char) * (strlen(STRING_UNKNOWN) + 1));
|
||||||
printWarn("Can't read CPU name from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000004, cpu->maxExtendedLevels);
|
strcpy(cpu->cpu_name, STRING_UNKNOWN);
|
||||||
|
printWarn("Can't read cpu name from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000004, cpu->maxExtendedLevels);
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu->topology_extensions = false;
|
cpu->topology_extensions = false;
|
||||||
@@ -537,17 +536,12 @@ struct cpuInfo* get_cpu_info(void) {
|
|||||||
ptr->first_core_id = first_core;
|
ptr->first_core_id = first_core;
|
||||||
ptr->feat = get_features_info(ptr);
|
ptr->feat = get_features_info(ptr);
|
||||||
|
|
||||||
|
// If any field of the struct is NULL,
|
||||||
|
// return inmideately, as further functions
|
||||||
|
// require valid fields (cach, topo, etc)
|
||||||
ptr->arch = get_cpu_uarch(ptr);
|
ptr->arch = get_cpu_uarch(ptr);
|
||||||
ptr->freq = get_frequency_info(ptr);
|
ptr->freq = get_frequency_info(ptr);
|
||||||
|
|
||||||
if (cpu->cpu_name == NULL && ptr == cpu) {
|
|
||||||
// If we couldnt read CPU name from cpuid, infer it now
|
|
||||||
cpu->cpu_name = infer_cpu_name_from_uarch(cpu->arch);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If any field of the struct is NULL,
|
|
||||||
// return early, as next functions
|
|
||||||
// require non NULL fields in cach and topo
|
|
||||||
ptr->cach = get_cache_info(ptr);
|
ptr->cach = get_cache_info(ptr);
|
||||||
if(ptr->cach == NULL) return cpu;
|
if(ptr->cach == NULL) return cpu;
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,7 @@ enum {
|
|||||||
UARCH_UNKNOWN,
|
UARCH_UNKNOWN,
|
||||||
// INTEL //
|
// INTEL //
|
||||||
UARCH_P5,
|
UARCH_P5,
|
||||||
UARCH_P5_MMX,
|
UARCH_P6,
|
||||||
UARCH_P6_PENTIUM_II,
|
|
||||||
UARCH_P6_PENTIUM_III,
|
|
||||||
UARCH_DOTHAN,
|
UARCH_DOTHAN,
|
||||||
UARCH_YONAH,
|
UARCH_YONAH,
|
||||||
UARCH_MEROM,
|
UARCH_MEROM,
|
||||||
@@ -147,31 +145,31 @@ struct uarch* get_uarch_from_cpuid_intel(uint32_t ef, uint32_t f, uint32_t em, u
|
|||||||
// EM: Extended Model //
|
// EM: Extended Model //
|
||||||
// M: Model //
|
// M: Model //
|
||||||
// S: Stepping //
|
// S: Stepping //
|
||||||
// ------------------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------------- //
|
||||||
// EF F EM M S //
|
// EF F EM M S //
|
||||||
UARCH_START
|
UARCH_START
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 0, NA, "P5", UARCH_P5, 800)
|
CHECK_UARCH(arch, 0, 5, 0, 0, NA, "P5", UARCH_P5, 800)
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 1, NA, "P5", UARCH_P5, 800)
|
CHECK_UARCH(arch, 0, 5, 0, 1, NA, "P5", UARCH_P5, 800)
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 2, NA, "P5", UARCH_P5, UNK)
|
CHECK_UARCH(arch, 0, 5, 0, 2, NA, "P5", UARCH_P5, UNK)
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 3, NA, "P5", UARCH_P5, 600)
|
CHECK_UARCH(arch, 0, 5, 0, 3, NA, "P5", UARCH_P5, 600)
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 4, NA, "P5 (MMX)", UARCH_P5_MMX, UNK)
|
CHECK_UARCH(arch, 0, 5, 0, 4, NA, "P5 MMX", UARCH_P5, UNK)
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 7, NA, "P5 (MMX)", UARCH_P5_MMX, UNK)
|
CHECK_UARCH(arch, 0, 5, 0, 7, NA, "P5 MMX", UARCH_P5, UNK)
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 8, NA, "P5 (MMX)", UARCH_P5_MMX, 250)
|
CHECK_UARCH(arch, 0, 5, 0, 8, NA, "P5 MMX", UARCH_P5, 250)
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 9, 0, "Lakemont", UARCH_LAKEMONT, 32)
|
CHECK_UARCH(arch, 0, 5, 0, 9, 0, "Lakemont", UARCH_LAKEMONT, 32)
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 9, NA, "P5 (MMX)", UARCH_P5_MMX, UNK)
|
CHECK_UARCH(arch, 0, 5, 0, 9, NA, "P5 MMX", UARCH_P5, UNK)
|
||||||
CHECK_UARCH(arch, 0, 5, 0, 10, 0, "Lakemont", UARCH_LAKEMONT, 32)
|
CHECK_UARCH(arch, 0, 5, 0, 10, 0, "Lakemont", UARCH_LAKEMONT, 32)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 0, NA, "P6 (Pentium II)", UARCH_P6_PENTIUM_II, UNK)
|
CHECK_UARCH(arch, 0, 6, 0, 0, NA, "P6 Pentium II", UARCH_P6, UNK)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 1, NA, "P6 (Pentium II)", UARCH_P6_PENTIUM_II, UNK) // process depends on core
|
CHECK_UARCH(arch, 0, 6, 0, 1, NA, "P6 Pentium II", UARCH_P6, UNK) // process depends on core
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 2, NA, "P6 (Pentium II)", UARCH_P6_PENTIUM_II, UNK)
|
CHECK_UARCH(arch, 0, 6, 0, 2, NA, "P6 Pentium II", UARCH_P6, UNK)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 3, NA, "P6 (Klamath)", UARCH_P6_PENTIUM_II, 350) // http://instlatx64.atw.hu.
|
CHECK_UARCH(arch, 0, 6, 0, 3, NA, "P6 Pentium II", UARCH_P6, 350)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 4, NA, "P6 (Pentium II)", UARCH_P6_PENTIUM_II, UNK)
|
CHECK_UARCH(arch, 0, 6, 0, 4, NA, "P6 Pentium II", UARCH_P6, UNK)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 5, NA, "P6 (Deschutes)", UARCH_P6_PENTIUM_II, 250) // http://instlatx64.atw.hu.
|
CHECK_UARCH(arch, 0, 6, 0, 5, NA, "P6 Pentium II", UARCH_P6, 250)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 6, NA, "P6 (Dixon)", UARCH_P6_PENTIUM_II, UNK) // http://instlatx64.atw.hu.
|
CHECK_UARCH(arch, 0, 6, 0, 6, NA, "P6 Pentium II", UARCH_P6, UNK)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 7, NA, "P6 (Katmai)", UARCH_P6_PENTIUM_III, 250) // Core names from: https://en.wikichip.org/wiki/intel/cpuid. NOTE: Xeon core names are different! https://www.techpowerup.com/cpu-specs/?generation=Intel+Pentium+III+Xeon
|
CHECK_UARCH(arch, 0, 6, 0, 7, NA, "P6 Pentium III", UARCH_P6, 250)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 8, NA, "P6 (Coppermine)", UARCH_P6_PENTIUM_III, 180) // Also: https://en.wikipedia.org/wiki/Pentium_III
|
CHECK_UARCH(arch, 0, 6, 0, 8, NA, "P6 Pentium III", UARCH_P6, 180)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 9, NA, "P6 (Pentium M)", UARCH_P6_PENTIUM_III, 130)
|
CHECK_UARCH(arch, 0, 6, 0, 9, NA, "P6 Pentium M", UARCH_P6, 130)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 10, NA, "P6 (Coppermine T)", UARCH_P6_PENTIUM_III, 180)
|
CHECK_UARCH(arch, 0, 6, 0, 10, NA, "P6 Pentium III", UARCH_P6, 180)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 11, NA, "P6 (Tualatin)", UARCH_P6_PENTIUM_III, 130)
|
CHECK_UARCH(arch, 0, 6, 0, 11, NA, "P6 Pentium III", UARCH_P6, 130)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 13, NA, "Dothan", UARCH_DOTHAN, UNK) // process depends on core
|
CHECK_UARCH(arch, 0, 6, 0, 13, NA, "Dothan", UARCH_DOTHAN, UNK) // process depends on core
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 14, NA, "Yonah", UARCH_YONAH, 65)
|
CHECK_UARCH(arch, 0, 6, 0, 14, NA, "Yonah", UARCH_YONAH, 65)
|
||||||
CHECK_UARCH(arch, 0, 6, 0, 15, NA, "Merom", UARCH_MEROM, 65)
|
CHECK_UARCH(arch, 0, 6, 0, 15, NA, "Merom", UARCH_MEROM, 65)
|
||||||
@@ -394,16 +392,11 @@ struct uarch* get_uarch_from_cpuid_amd(uint32_t ef, uint32_t f, uint32_t em, uin
|
|||||||
|
|
||||||
struct uarch* get_uarch_from_cpuid(struct cpuInfo* cpu, uint32_t dump, uint32_t ef, uint32_t f, uint32_t em, uint32_t m, int s) {
|
struct uarch* get_uarch_from_cpuid(struct cpuInfo* cpu, uint32_t dump, uint32_t ef, uint32_t f, uint32_t em, uint32_t m, int s) {
|
||||||
if(cpu->cpu_vendor == CPU_VENDOR_INTEL) {
|
if(cpu->cpu_vendor == CPU_VENDOR_INTEL) {
|
||||||
struct uarch* arch = emalloc(sizeof(struct uarch));
|
|
||||||
if(dump == 0x000806E9) {
|
if(dump == 0x000806E9) {
|
||||||
if (cpu->cpu_name == NULL) {
|
|
||||||
printErr("Unable to find uarch without CPU name");
|
|
||||||
fill_uarch(arch, STRING_UNKNOWN, UARCH_UNKNOWN, UNK);
|
|
||||||
return arch;
|
|
||||||
}
|
|
||||||
|
|
||||||
// It is not possible to determine uarch only from CPUID dump (can be Kaby Lake or Amber Lake)
|
// It is not possible to determine uarch only from CPUID dump (can be Kaby Lake or Amber Lake)
|
||||||
// See issue https://github.com/Dr-Noob/cpufetch/issues/122
|
// See issue https://github.com/Dr-Noob/cpufetch/issues/122
|
||||||
|
struct uarch* arch = emalloc(sizeof(struct uarch));
|
||||||
|
|
||||||
if(strstr(cpu->cpu_name, "Y") != NULL) {
|
if(strstr(cpu->cpu_name, "Y") != NULL) {
|
||||||
fill_uarch(arch, "Amber Lake", UARCH_AMBER_LAKE, 14);
|
fill_uarch(arch, "Amber Lake", UARCH_AMBER_LAKE, 14);
|
||||||
}
|
}
|
||||||
@@ -414,14 +407,10 @@ struct uarch* get_uarch_from_cpuid(struct cpuInfo* cpu, uint32_t dump, uint32_t
|
|||||||
return arch;
|
return arch;
|
||||||
}
|
}
|
||||||
else if (dump == 0x000806EA) {
|
else if (dump == 0x000806EA) {
|
||||||
if (cpu->cpu_name == NULL) {
|
|
||||||
printErr("Unable to find uarch without CPU name");
|
|
||||||
fill_uarch(arch, STRING_UNKNOWN, UARCH_UNKNOWN, UNK);
|
|
||||||
return arch;
|
|
||||||
}
|
|
||||||
|
|
||||||
// It is not possible to determine uarch only from CPUID dump (can be Kaby Lake R or Coffee Lake U)
|
// It is not possible to determine uarch only from CPUID dump (can be Kaby Lake R or Coffee Lake U)
|
||||||
// See issue https://github.com/Dr-Noob/cpufetch/issues/149
|
// See issue https://github.com/Dr-Noob/cpufetch/issues/149
|
||||||
|
struct uarch* arch = emalloc(sizeof(struct uarch));
|
||||||
|
|
||||||
if(strstr(cpu->cpu_name, "i5-8250U") != NULL ||
|
if(strstr(cpu->cpu_name, "i5-8250U") != NULL ||
|
||||||
strstr(cpu->cpu_name, "i5-8350U") != NULL ||
|
strstr(cpu->cpu_name, "i5-8350U") != NULL ||
|
||||||
strstr(cpu->cpu_name, "i7-8550U") != NULL ||
|
strstr(cpu->cpu_name, "i7-8550U") != NULL ||
|
||||||
@@ -440,41 +429,6 @@ struct uarch* get_uarch_from_cpuid(struct cpuInfo* cpu, uint32_t dump, uint32_t
|
|||||||
return get_uarch_from_cpuid_amd(ef, f, em, m, s);
|
return get_uarch_from_cpuid_amd(ef, f, em, m, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we cannot get the CPU name from CPUID, try to infer it from uarch
|
|
||||||
char* infer_cpu_name_from_uarch(struct uarch* arch) {
|
|
||||||
char* cpu_name = NULL;
|
|
||||||
if (arch == NULL) {
|
|
||||||
printErr("infer_cpu_name_from_uarch: Unable to find CPU name");
|
|
||||||
cpu_name = ecalloc(strlen(STRING_UNKNOWN) + 1, sizeof(char));
|
|
||||||
strcpy(cpu_name, STRING_UNKNOWN);
|
|
||||||
return cpu_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *str = NULL;
|
|
||||||
|
|
||||||
if (arch->uarch == UARCH_P5)
|
|
||||||
str = "Intel Pentium";
|
|
||||||
else if (arch->uarch == UARCH_P5_MMX)
|
|
||||||
str = "Intel Pentium MMX";
|
|
||||||
else if (arch->uarch == UARCH_P6_PENTIUM_II)
|
|
||||||
str = "Intel Pentium II";
|
|
||||||
else if (arch->uarch == UARCH_P6_PENTIUM_III)
|
|
||||||
str = "Intel Pentium III";
|
|
||||||
else
|
|
||||||
printErr("Unable to find name from uarch: %d", arch->uarch);
|
|
||||||
|
|
||||||
if (str == NULL) {
|
|
||||||
cpu_name = ecalloc(strlen(STRING_UNKNOWN) + 1, sizeof(char));
|
|
||||||
strcpy(cpu_name, STRING_UNKNOWN);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cpu_name = ecalloc(strlen(str) + 1, sizeof(char));
|
|
||||||
strcpy(cpu_name, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cpu_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool vpus_are_AVX512(struct cpuInfo* cpu) {
|
bool vpus_are_AVX512(struct cpuInfo* cpu) {
|
||||||
return cpu->arch->uarch != UARCH_ICE_LAKE &&
|
return cpu->arch->uarch != UARCH_ICE_LAKE &&
|
||||||
cpu->arch->uarch != UARCH_TIGER_LAKE &&
|
cpu->arch->uarch != UARCH_TIGER_LAKE &&
|
||||||
@@ -545,6 +499,9 @@ char* get_str_process(struct cpuInfo* cpu) {
|
|||||||
if(process == UNK) {
|
if(process == UNK) {
|
||||||
snprintf(str, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
|
snprintf(str, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
else if(process > 100) {
|
||||||
|
sprintf(str, "%.2fum", (double)process/100);
|
||||||
|
}
|
||||||
else if(process > 0){
|
else if(process > 0){
|
||||||
sprintf(str, "%dnm", process);
|
sprintf(str, "%dnm", process);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
struct uarch;
|
struct uarch;
|
||||||
|
|
||||||
struct uarch* get_uarch_from_cpuid(struct cpuInfo* cpu, uint32_t dump, uint32_t ef, uint32_t f, uint32_t em, uint32_t m, int s);
|
struct uarch* get_uarch_from_cpuid(struct cpuInfo* cpu, uint32_t dump, uint32_t ef, uint32_t f, uint32_t em, uint32_t m, int s);
|
||||||
char* infer_cpu_name_from_uarch(struct uarch* arch);
|
|
||||||
bool vpus_are_AVX512(struct cpuInfo* cpu);
|
bool vpus_are_AVX512(struct cpuInfo* cpu);
|
||||||
bool is_knights_landing(struct cpuInfo* cpu);
|
bool is_knights_landing(struct cpuInfo* cpu);
|
||||||
int get_number_of_vpus(struct cpuInfo* cpu);
|
int get_number_of_vpus(struct cpuInfo* cpu);
|
||||||
|
|||||||
Reference in New Issue
Block a user