mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
Compare commits
8 Commits
5bddbc6b06
...
i290
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad5c9e6037 | ||
|
|
6ada3ec361 | ||
|
|
91c92bbdf6 | ||
|
|
d0cc04529c | ||
|
|
f826125395 | ||
|
|
2272423163 | ||
|
|
5194976739 | ||
|
|
417d7ce730 |
@@ -446,24 +446,24 @@ $C1 ########### ___########### __________ \
|
|||||||
$C1.########## |__________| |__________| "
|
$C1.########## |__________| |__________| "
|
||||||
|
|
||||||
#define ASCII_SPACEMIT \
|
#define ASCII_SPACEMIT \
|
||||||
"$C1 :#: \
|
"$C1 :#: \
|
||||||
$C1 :####: \
|
$C1 :####: \
|
||||||
$C1 :#######: \
|
$C1 :#######: \
|
||||||
$C1 :#########: \
|
$C1 :#########: \
|
||||||
$C1 :#########: \
|
$C1 :#########: \
|
||||||
$C1 :#######: \
|
$C1 :#######: \
|
||||||
$C1 :####: \
|
$C1 :####: \
|
||||||
$C1 :#: \
|
$C1 :#: \
|
||||||
$C1:##: :#: \
|
$C1:##: :#: \
|
||||||
$C1:####: :###: \
|
$C1:####: :###: \
|
||||||
$C1:#######: :####: \
|
$C1:#######: :####: \
|
||||||
$C1:##########: :###: \
|
$C1:##########: :###: \
|
||||||
$C1:###########: :#: \
|
$C1:###########: :#: \
|
||||||
$C1:###########: \
|
$C1:###########: \
|
||||||
$C1 :##########: \
|
$C1 :##########: \
|
||||||
$C1 :#######: \
|
$C1 :#######: \
|
||||||
$C1 :####: \
|
$C1 :####: \
|
||||||
$C1 :##: "
|
$C1 :##: "
|
||||||
|
|
||||||
// --------------------- LONG LOGOS ------------------------- //
|
// --------------------- LONG LOGOS ------------------------- //
|
||||||
#define ASCII_AMD_L \
|
#define ASCII_AMD_L \
|
||||||
@@ -644,7 +644,7 @@ asciiL logo_ampere = { ASCII_AMPERE, 50, 17, false, {C_FG_RED},
|
|||||||
asciiL logo_nxp = { ASCII_NXP, 55, 8, false, {C_FG_YELLOW, C_FG_CYAN, C_FG_GREEN}, {C_FG_CYAN, C_FG_WHITE} };
|
asciiL logo_nxp = { ASCII_NXP, 55, 8, false, {C_FG_YELLOW, C_FG_CYAN, C_FG_GREEN}, {C_FG_CYAN, C_FG_WHITE} };
|
||||||
asciiL logo_amlogic = { ASCII_AMLOGIC, 58, 8, false, {C_FG_BLUE}, {C_FG_BLUE, C_FG_B_WHITE} };
|
asciiL logo_amlogic = { ASCII_AMLOGIC, 58, 8, false, {C_FG_BLUE}, {C_FG_BLUE, C_FG_B_WHITE} };
|
||||||
asciiL logo_marvell = { ASCII_MARVELL, 56, 10, false, {C_FG_B_BLACK}, {C_FG_B_BLACK, C_FG_B_WHITE} };
|
asciiL logo_marvell = { ASCII_MARVELL, 56, 10, false, {C_FG_B_BLACK}, {C_FG_B_BLACK, C_FG_B_WHITE} };
|
||||||
asciiL logo_spacemit = { ASCII_SPACEMIT, 27, 18, false, {C_FG_B_GREEN}, {C_FG_B_GREEN, C_FG_B_WHITE} };
|
asciiL logo_spacemit = { ASCII_SPACEMIT, 26, 18, false, {C_FG_B_GREEN}, {C_FG_B_GREEN, C_FG_B_WHITE} };
|
||||||
|
|
||||||
// Long variants | ----------------------------------------------------------------------------------------------------------------|
|
// Long variants | ----------------------------------------------------------------------------------------------------------------|
|
||||||
asciiL logo_amd_l = { ASCII_AMD_L, 62, 19, true, {C_BG_WHITE, C_BG_GREEN}, {C_FG_WHITE, C_FG_GREEN} };
|
asciiL logo_amd_l = { ASCII_AMD_L, 62, 19, true, {C_BG_WHITE, C_BG_GREEN}, {C_FG_WHITE, C_FG_GREEN} };
|
||||||
|
|||||||
@@ -45,17 +45,9 @@
|
|||||||
#define MAX_ATTRIBUTES 100
|
#define MAX_ATTRIBUTES 100
|
||||||
#define MAX_TERM_SIZE 1024
|
#define MAX_TERM_SIZE 1024
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int id;
|
|
||||||
const char *name;
|
|
||||||
const char *shortname;
|
|
||||||
} AttributeField;
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
#if defined(ARCH_X86)
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
ATTRIBUTE_NAME,
|
ATTRIBUTE_NAME,
|
||||||
#elif defined(ARCH_PPC)
|
|
||||||
ATTRIBUTE_PART_NUMBER,
|
|
||||||
#elif defined(ARCH_ARM) || defined(ARCH_RISCV)
|
#elif defined(ARCH_ARM) || defined(ARCH_RISCV)
|
||||||
ATTRIBUTE_SOC,
|
ATTRIBUTE_SOC,
|
||||||
#endif
|
#endif
|
||||||
@@ -87,40 +79,76 @@ enum {
|
|||||||
ATTRIBUTE_PEAK
|
ATTRIBUTE_PEAK
|
||||||
};
|
};
|
||||||
|
|
||||||
static const AttributeField ATTRIBUTE_INFO[] = {
|
static const char* ATTRIBUTE_FIELDS [] = {
|
||||||
#if defined(ARCH_X86)
|
#ifdef ARCH_X86
|
||||||
{ ATTRIBUTE_NAME, "Name:", "Name:" },
|
"Name:",
|
||||||
#elif defined(ARCH_PPC)
|
#elif ARCH_PPC
|
||||||
{ ATTRIBUTE_PART_NUMBER, "Part Number:", "P/N:" },
|
"Part Number:",
|
||||||
#elif defined(ARCH_ARM) || defined(ARCH_RISCV)
|
#elif defined(ARCH_ARM) || defined(ARCH_RISCV)
|
||||||
{ ATTRIBUTE_SOC, "SoC:", "SoC:" },
|
"SoC:",
|
||||||
#endif
|
#endif
|
||||||
#if defined(ARCH_X86) || defined(ARCH_ARM)
|
#if defined(ARCH_X86) || defined(ARCH_ARM)
|
||||||
{ ATTRIBUTE_CPU_NUM, "", "" },
|
"",
|
||||||
#endif
|
#endif
|
||||||
{ ATTRIBUTE_HYPERVISOR, "Hypervisor:", "Hypervisor:" },
|
"Hypervisor:",
|
||||||
{ ATTRIBUTE_UARCH, "Microarchitecture:", "uArch:" },
|
"Microarchitecture:",
|
||||||
{ ATTRIBUTE_TECHNOLOGY, "Technology:", "Technology:" },
|
"Technology:",
|
||||||
{ ATTRIBUTE_FREQUENCY, "Max Frequency:", "Max Freq:" },
|
"Max Frequency:",
|
||||||
{ ATTRIBUTE_SOCKETS, "Sockets:", "Sockets:" },
|
"Sockets:",
|
||||||
{ ATTRIBUTE_NCORES, "Cores:", "Cores:" },
|
"Cores:",
|
||||||
{ ATTRIBUTE_NCORES_DUAL, "Cores (Total):", "Cores (Total):" },
|
"Cores (Total):",
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
{ ATTRIBUTE_SSE, "SSE:", "SSE:" },
|
"SSE:",
|
||||||
{ ATTRIBUTE_AVX, "AVX:", "AVX:" },
|
"AVX:",
|
||||||
{ ATTRIBUTE_FMA, "FMA:", "FMA:" },
|
"FMA:",
|
||||||
#elif ARCH_PPC
|
#elif ARCH_PPC
|
||||||
{ ATTRIBUTE_ALTIVEC, "Altivec: ", "Altivec: " },
|
"Altivec: ",
|
||||||
#elif ARCH_ARM
|
#elif defined(ARCH_ARM)
|
||||||
{ ATTRIBUTE_FEATURES, "Features: ", "Features: " },
|
"Features: ",
|
||||||
#elif ARCH_RISCV
|
#elif defined(ARCH_RISCV)
|
||||||
{ ATTRIBUTE_EXTENSIONS, "Extensions: ", "Extensions: " },
|
"Extensions: ",
|
||||||
#endif
|
#endif
|
||||||
{ ATTRIBUTE_L1i, "L1i Size:", "L1i Size:" },
|
"L1i Size:",
|
||||||
{ ATTRIBUTE_L1d, "L1d Size:", "L1d Size:" },
|
"L1d Size:",
|
||||||
{ ATTRIBUTE_L2, "L2 Size:", "L2 Size:" },
|
"L2 Size:",
|
||||||
{ ATTRIBUTE_L3, "L3 Size:", "L3 Size:" },
|
"L3 Size:",
|
||||||
{ ATTRIBUTE_PEAK, "Peak Performance:", "Peak Perf.:" },
|
"Peak Performance:",
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* ATTRIBUTE_FIELDS_SHORT [] = {
|
||||||
|
#if defined(ARCH_X86)
|
||||||
|
"Name:",
|
||||||
|
#elif ARCH_PPC
|
||||||
|
"P/N:",
|
||||||
|
#elif ARCH_ARM
|
||||||
|
"SoC:",
|
||||||
|
#endif
|
||||||
|
#if defined(ARCH_X86) || defined(ARCH_ARM)
|
||||||
|
"",
|
||||||
|
#endif
|
||||||
|
"Hypervisor:",
|
||||||
|
"uArch:",
|
||||||
|
"Technology:",
|
||||||
|
"Max Freq:",
|
||||||
|
"Sockets:",
|
||||||
|
"Cores:",
|
||||||
|
"Cores (Total):",
|
||||||
|
#ifdef ARCH_X86
|
||||||
|
"SSE:",
|
||||||
|
"AVX:",
|
||||||
|
"FMA:",
|
||||||
|
#elif ARCH_PPC
|
||||||
|
"Altivec: ",
|
||||||
|
#elif defined(ARCH_ARM)
|
||||||
|
"Features: ",
|
||||||
|
#elif defined(ARCH_RISCV)
|
||||||
|
"Extensions: ",
|
||||||
|
#endif
|
||||||
|
"L1i Size:",
|
||||||
|
"L1d Size:",
|
||||||
|
"L2 Size:",
|
||||||
|
"L3 Size:",
|
||||||
|
"Peak Perf.:",
|
||||||
};
|
};
|
||||||
|
|
||||||
struct terminal {
|
struct terminal {
|
||||||
@@ -426,14 +454,13 @@ void choose_ascii_art(struct ascii* art, struct color** cs, struct terminal* ter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t longest_attribute_length(struct ascii* art, bool use_short) {
|
uint32_t longest_attribute_length(struct ascii* art, const char** attribute_fields) {
|
||||||
uint32_t max = 0;
|
uint32_t max = 0;
|
||||||
uint64_t len = 0;
|
uint64_t len = 0;
|
||||||
|
|
||||||
for(uint32_t i=0; i < art->n_attributes_set; i++) {
|
for(uint32_t i=0; i < art->n_attributes_set; i++) {
|
||||||
if(art->attributes[i]->value != NULL) {
|
if(art->attributes[i]->value != NULL) {
|
||||||
const char* str = use_short ? ATTRIBUTE_INFO[art->attributes[i]->type].shortname : ATTRIBUTE_INFO[art->attributes[i]->type].name;
|
len = strlen(attribute_fields[art->attributes[i]->type]);
|
||||||
len = strlen(str);
|
|
||||||
if(len > max) max = len;
|
if(len > max) max = len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -458,7 +485,7 @@ uint32_t longest_field_length(struct ascii* art, int la) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
void print_ascii_generic(struct ascii* art, uint32_t la, int32_t termw, bool use_short, bool hybrid_architecture) {
|
void print_ascii_generic(struct ascii* art, uint32_t la, int32_t termw, const char** attribute_fields, bool hybrid_architecture) {
|
||||||
struct ascii_logo* logo = art->art;
|
struct ascii_logo* logo = art->art;
|
||||||
int attr_to_print = 0;
|
int attr_to_print = 0;
|
||||||
int attr_type;
|
int attr_type;
|
||||||
@@ -520,15 +547,14 @@ void print_ascii_generic(struct ascii* art, uint32_t la, int32_t termw, bool use
|
|||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
beg_space = 0;
|
beg_space = 0;
|
||||||
const char* attr_str = use_short ? ATTRIBUTE_INFO[attr_type].shortname : ATTRIBUTE_INFO[attr_type].name;
|
space_right = 2 + 1 + (la - strlen(attribute_fields[attr_type]));
|
||||||
space_right = 2 + 1 + (la - strlen(attr_str));
|
|
||||||
if(hybrid_architecture && add_space) {
|
if(hybrid_architecture && add_space) {
|
||||||
beg_space = 2;
|
beg_space = 2;
|
||||||
space_right -= 2;
|
space_right -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
printOut(lbuf, beg_space + strlen(attr_str) + space_right + strlen(attr_value),
|
printOut(lbuf, beg_space + strlen(attribute_fields[attr_type]) + space_right + strlen(attr_value),
|
||||||
"%*s%s%s%s%*s%s%s%s", beg_space, "", logo->color_text[0], attr_str, art->reset, space_right, "", logo->color_text[1], attr_value, art->reset);
|
"%*s%s%s%s%*s%s%s%s", beg_space, "", logo->color_text[0], attribute_fields[attr_type], art->reset, space_right, "", logo->color_text[1], attr_value, art->reset);
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -637,19 +663,19 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct color** cs, struct
|
|||||||
setAttribute(art, ATTRIBUTE_PEAK, pp);
|
setAttribute(art, ATTRIBUTE_PEAK, pp);
|
||||||
|
|
||||||
// Step 3. Print output
|
// Step 3. Print output
|
||||||
bool use_short = false;
|
const char** attribute_fields = ATTRIBUTE_FIELDS;
|
||||||
uint32_t longest_attribute = longest_attribute_length(art, use_short);
|
uint32_t longest_attribute = longest_attribute_length(art, attribute_fields);
|
||||||
uint32_t longest_field = longest_field_length(art, longest_attribute);
|
uint32_t longest_field = longest_field_length(art, longest_attribute);
|
||||||
choose_ascii_art(art, cs, term, longest_field);
|
choose_ascii_art(art, cs, term, longest_field);
|
||||||
|
|
||||||
if(!ascii_fits_screen(term->w, *art->art, longest_field)) {
|
if(!ascii_fits_screen(term->w, *art->art, longest_field)) {
|
||||||
// Despite of choosing the smallest logo, the output does not fit
|
// Despite of choosing the smallest logo, the output does not fit
|
||||||
// Choose the shorter field names and recalculate the longest attr
|
// Choose the shorter field names and recalculate the longest attr
|
||||||
use_short = true;
|
attribute_fields = ATTRIBUTE_FIELDS_SHORT;
|
||||||
longest_attribute = longest_attribute_length(art, use_short);
|
longest_attribute = longest_attribute_length(art, attribute_fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
print_ascii_generic(art, longest_attribute, term->w, use_short, hybrid_architecture);
|
print_ascii_generic(art, longest_attribute, term->w, attribute_fields, hybrid_architecture);
|
||||||
|
|
||||||
free(manufacturing_process);
|
free(manufacturing_process);
|
||||||
free(sockets);
|
free(sockets);
|
||||||
@@ -698,7 +724,7 @@ bool print_cpufetch_ppc(struct cpuInfo* cpu, STYLE s, struct color** cs, struct
|
|||||||
|
|
||||||
// Step 2. Set attributes
|
// Step 2. Set attributes
|
||||||
if(cpu_name != NULL) {
|
if(cpu_name != NULL) {
|
||||||
setAttribute(art, ATTRIBUTE_PART_NUMBER, cpu_name);
|
setAttribute(art, ATTRIBUTE_NAME, cpu_name);
|
||||||
}
|
}
|
||||||
setAttribute(art, ATTRIBUTE_UARCH, uarch);
|
setAttribute(art, ATTRIBUTE_UARCH, uarch);
|
||||||
if(cpu->hv->present) {
|
if(cpu->hv->present) {
|
||||||
@@ -725,19 +751,19 @@ bool print_cpufetch_ppc(struct cpuInfo* cpu, STYLE s, struct color** cs, struct
|
|||||||
setAttribute(art, ATTRIBUTE_PEAK, pp);
|
setAttribute(art, ATTRIBUTE_PEAK, pp);
|
||||||
|
|
||||||
// Step 3. Print output
|
// Step 3. Print output
|
||||||
bool use_short = false;
|
const char** attribute_fields = ATTRIBUTE_FIELDS;
|
||||||
uint32_t longest_attribute = longest_attribute_length(art, use_short);
|
uint32_t longest_attribute = longest_attribute_length(art, attribute_fields);
|
||||||
uint32_t longest_field = longest_field_length(art, longest_attribute);
|
uint32_t longest_field = longest_field_length(art, longest_attribute);
|
||||||
choose_ascii_art(art, cs, term, longest_field);
|
choose_ascii_art(art, cs, term, longest_field);
|
||||||
|
|
||||||
if(!ascii_fits_screen(term->w, *art->art, longest_field)) {
|
if(!ascii_fits_screen(term->w, *art->art, longest_field)) {
|
||||||
// Despite of choosing the smallest logo, the output does not fit
|
// Despite of choosing the smallest logo, the output does not fit
|
||||||
// Choose the shorter field names and recalculate the longest attr
|
// Choose the shorter field names and recalculate the longest attr
|
||||||
use_short = true;
|
attribute_fields = ATTRIBUTE_FIELDS_SHORT;
|
||||||
longest_attribute = longest_attribute_length(art, use_short);
|
longest_attribute = longest_attribute_length(art, attribute_fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
print_ascii_generic(art, longest_attribute, term->w, use_short, false);
|
print_ascii_generic(art, longest_attribute, term->w, attribute_fields, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -765,7 +791,7 @@ uint32_t longest_field_length_arm(struct ascii* art, int la) {
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii_arm(struct ascii* art, uint32_t la, int32_t termw, bool use_short) {
|
void print_ascii_arm(struct ascii* art, uint32_t la, int32_t termw, const char** attribute_fields) {
|
||||||
struct ascii_logo* logo = art->art;
|
struct ascii_logo* logo = art->art;
|
||||||
int attr_to_print = 0;
|
int attr_to_print = 0;
|
||||||
int attr_type;
|
int attr_type;
|
||||||
@@ -836,15 +862,14 @@ void print_ascii_arm(struct ascii* art, uint32_t la, int32_t termw, bool use_sho
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
beg_space = 0;
|
beg_space = 0;
|
||||||
const char* attr_str = use_short ? ATTRIBUTE_INFO[attr_type].shortname : ATTRIBUTE_INFO[attr_type].name;
|
space_right = 2 + 1 + (la - strlen(attribute_fields[attr_type]));
|
||||||
space_right = 2 + 1 + (la - strlen(attr_str));
|
|
||||||
if(add_space) {
|
if(add_space) {
|
||||||
beg_space = 2;
|
beg_space = 2;
|
||||||
space_right -= 2;
|
space_right -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
printOut(lbuf, beg_space + strlen(attr_str) + space_right + strlen(attr_value),
|
printOut(lbuf, beg_space + strlen(attribute_fields[attr_type]) + space_right + strlen(attr_value),
|
||||||
"%*s%s%s%s%*s%s%s%s", beg_space, "", logo->color_text[0], attr_str, art->reset, space_right, "", logo->color_text[1], attr_value, art->reset);
|
"%*s%s%s%s%*s%s%s%s", beg_space, "", logo->color_text[0], attribute_fields[attr_type], art->reset, space_right, "", logo->color_text[1], attr_value, art->reset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printOutLine(lbuf, art, termw);
|
printOutLine(lbuf, art, termw);
|
||||||
@@ -914,8 +939,8 @@ bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct color** cs, struct
|
|||||||
setAttribute(art, ATTRIBUTE_HYPERVISOR, cpu->hv->hv_name);
|
setAttribute(art, ATTRIBUTE_HYPERVISOR, cpu->hv->hv_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool use_short = false;
|
const char** attribute_fields = ATTRIBUTE_FIELDS;
|
||||||
uint32_t longest_attribute = longest_attribute_length(art, use_short);
|
uint32_t longest_attribute = longest_attribute_length(art, attribute_fields);
|
||||||
uint32_t longest_field = longest_field_length_arm(art, longest_attribute);
|
uint32_t longest_field = longest_field_length_arm(art, longest_attribute);
|
||||||
choose_ascii_art(art, cs, term, longest_field);
|
choose_ascii_art(art, cs, term, longest_field);
|
||||||
|
|
||||||
@@ -927,11 +952,11 @@ bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct color** cs, struct
|
|||||||
if(!ascii_fits_screen(term->w, *art->art, longest_field)) {
|
if(!ascii_fits_screen(term->w, *art->art, longest_field)) {
|
||||||
// Despite of choosing the smallest logo, the output does not fit
|
// Despite of choosing the smallest logo, the output does not fit
|
||||||
// Choose the shorter field names and recalculate the longest attr
|
// Choose the shorter field names and recalculate the longest attr
|
||||||
use_short = true;
|
attribute_fields = ATTRIBUTE_FIELDS_SHORT;
|
||||||
longest_attribute = longest_attribute_length(art, use_short);
|
longest_attribute = longest_attribute_length(art, attribute_fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
print_ascii_arm(art, longest_attribute, term->w, use_short);
|
print_ascii_arm(art, longest_attribute, term->w, attribute_fields);
|
||||||
|
|
||||||
free(manufacturing_process);
|
free(manufacturing_process);
|
||||||
free(pp);
|
free(pp);
|
||||||
@@ -956,7 +981,7 @@ uint64_t number_of_bits(uint64_t i) {
|
|||||||
return (((i + (i >> 4)) & 0xF0F0F0F0F0F0F0F) * 0x101010101010101) >> 56;
|
return (((i + (i >> 4)) & 0xF0F0F0F0F0F0F0F) * 0x101010101010101) >> 56;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii_riscv(struct ascii* art, uint32_t la, int32_t termw, bool use_short, uint64_t extensions_mask) {
|
void print_ascii_riscv(struct ascii* art, uint32_t la, int32_t termw, const char** attribute_fields, uint64_t extensions_mask) {
|
||||||
struct ascii_logo* logo = art->art;
|
struct ascii_logo* logo = art->art;
|
||||||
int attr_to_print = 0;
|
int attr_to_print = 0;
|
||||||
int attr_type;
|
int attr_type;
|
||||||
@@ -1024,11 +1049,10 @@ void print_ascii_riscv(struct ascii* art, uint32_t la, int32_t termw, bool use_s
|
|||||||
else {
|
else {
|
||||||
attr_to_print++;
|
attr_to_print++;
|
||||||
beg_space = 0;
|
beg_space = 0;
|
||||||
const char* attr_str = use_short ? ATTRIBUTE_INFO[attr_type].shortname : ATTRIBUTE_INFO[attr_type].name;
|
space_right = 2 + 1 + (la - strlen(attribute_fields[attr_type]));
|
||||||
space_right = 2 + 1 + (la - strlen(attr_str));
|
|
||||||
|
|
||||||
printOut(lbuf, beg_space + strlen(attr_str) + space_right + strlen(attr_value),
|
printOut(lbuf, beg_space + strlen(attribute_fields[attr_type]) + space_right + strlen(attr_value),
|
||||||
"%*s%s%s%s%*s%s%s%s", beg_space, "", logo->color_text[0], attr_str, art->reset, space_right, "", logo->color_text[1], attr_value, art->reset);
|
"%*s%s%s%s%*s%s%s%s", beg_space, "", logo->color_text[0], attribute_fields[attr_type], art->reset, space_right, "", logo->color_text[1], attr_value, art->reset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printOutLine(lbuf, art, termw);
|
printOutLine(lbuf, art, termw);
|
||||||
@@ -1066,19 +1090,19 @@ bool print_cpufetch_riscv(struct cpuInfo* cpu, STYLE s, struct color** cs, struc
|
|||||||
setAttribute(art, ATTRIBUTE_PEAK, pp);
|
setAttribute(art, ATTRIBUTE_PEAK, pp);
|
||||||
|
|
||||||
// Step 3. Print output
|
// Step 3. Print output
|
||||||
bool use_short = false;
|
const char** attribute_fields = ATTRIBUTE_FIELDS;
|
||||||
uint32_t longest_attribute = longest_attribute_length(art, use_short);
|
uint32_t longest_attribute = longest_attribute_length(art, attribute_fields);
|
||||||
uint32_t longest_field = longest_field_length(art, longest_attribute);
|
uint32_t longest_field = longest_field_length(art, longest_attribute);
|
||||||
choose_ascii_art(art, cs, term, longest_field);
|
choose_ascii_art(art, cs, term, longest_field);
|
||||||
|
|
||||||
if(!ascii_fits_screen(term->w, *art->art, longest_field)) {
|
if(!ascii_fits_screen(term->w, *art->art, longest_field)) {
|
||||||
// Despite of choosing the smallest logo, the output does not fit
|
// Despite of choosing the smallest logo, the output does not fit
|
||||||
// Choose the shorter field names and recalculate the longest attr
|
// Choose the shorter field names and recalculate the longest attr
|
||||||
use_short = true;
|
attribute_fields = ATTRIBUTE_FIELDS_SHORT;
|
||||||
longest_attribute = longest_attribute_length(art, use_short);
|
longest_attribute = longest_attribute_length(art, attribute_fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
print_ascii_riscv(art, longest_attribute, term->w, use_short, cpu->ext->mask);
|
print_ascii_riscv(art, longest_attribute, term->w, attribute_fields, cpu->ext->mask);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,15 +333,6 @@ struct features* get_features_info(struct cpuInfo* cpu) {
|
|||||||
bool hv_present = (ecx & (1U << 31)) != 0;
|
bool hv_present = (ecx & (1U << 31)) != 0;
|
||||||
if((cpu->hv = get_hp_info(hv_present)) == NULL)
|
if((cpu->hv = get_hp_info(hv_present)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if(cpu->hv->present) {
|
|
||||||
// Hypervisor will likely mess up something and users will think that
|
|
||||||
// there is something wrong with cpufetch whereas actually cpufetch has
|
|
||||||
// nothing to do with it.
|
|
||||||
// https://github.com/Dr-Noob/cpufetch/issues/96
|
|
||||||
// https://github.com/Dr-Noob/cpufetch/issues/267
|
|
||||||
// https://github.com/Dr-Noob/cpufetch/issues/293
|
|
||||||
printWarn("You are running an hypervisor. Please note that it will likely tamper your results, so do not post an issue if you find anything incorrect");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printWarn("Can't read features information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000001, cpu->maxLevels);
|
printWarn("Can't read features information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000001, cpu->maxLevels);
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ struct uarch* get_uarch_from_cpuid_intel(uint32_t ef, uint32_t f, uint32_t em, u
|
|||||||
// CHECK_UARCH(arch, 0, 6, 8, 14, 9, ...) It is not possible to determine uarch only from CPUID dump (can be Kaby Lake or Amber Lake)
|
// CHECK_UARCH(arch, 0, 6, 8, 14, 9, ...) It is not possible to determine uarch only from CPUID dump (can be Kaby Lake or Amber Lake)
|
||||||
// CHECK_UARCH(arch, 0, 6, 8, 14, 10, ...) It is not possible to determine uarch only from CPUID dump (can be Kaby Lake R or Coffee Lake U)
|
// CHECK_UARCH(arch, 0, 6, 8, 14, 10, ...) It is not possible to determine uarch only from CPUID dump (can be Kaby Lake R or Coffee Lake U)
|
||||||
CHECK_UARCH(arch, 0, 6, 8, 14, 11, "Whiskey Lake", UARCH_WHISKEY_LAKE, 14) // wikichip
|
CHECK_UARCH(arch, 0, 6, 8, 14, 11, "Whiskey Lake", UARCH_WHISKEY_LAKE, 14) // wikichip
|
||||||
// CHECK_UARCH(arch, 0, 6, 8, 14, 12, ...) It is not possible to determine uarch only from CPUID dump (can be Comet Lake U or Whiskey Lake U)
|
CHECK_UARCH(arch, 0, 6, 8, 14, 12, "Comet Lake", UARCH_COMET_LAKE, 14) // wikichip
|
||||||
CHECK_UARCH(arch, 0, 6, 8, 15, 8, "Sapphire Rapids", UARCH_SAPPHIRE_RAPIDS, 7) // wikichip
|
CHECK_UARCH(arch, 0, 6, 8, 15, 8, "Sapphire Rapids", UARCH_SAPPHIRE_RAPIDS, 7) // wikichip
|
||||||
CHECK_UARCH(arch, 0, 6, 9, 6, NA, "Tremont", UARCH_TREMONT, 10) // LX*
|
CHECK_UARCH(arch, 0, 6, 9, 6, NA, "Tremont", UARCH_TREMONT, 10) // LX*
|
||||||
CHECK_UARCH(arch, 0, 6, 9, 7, NA, "Alder Lake", UARCH_ALDER_LAKE, 10) // instlatx64 (Alder Lake-S)
|
CHECK_UARCH(arch, 0, 6, 9, 7, NA, "Alder Lake", UARCH_ALDER_LAKE, 10) // instlatx64 (Alder Lake-S)
|
||||||
@@ -447,7 +447,6 @@ struct uarch* get_uarch_from_cpuid_hygon(uint32_t ef, uint32_t f, uint32_t em, u
|
|||||||
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));
|
struct uarch* arch = emalloc(sizeof(struct uarch));
|
||||||
// TODO: Refactor these 3 checks in a common function.
|
|
||||||
if(dump == 0x000806E9) {
|
if(dump == 0x000806E9) {
|
||||||
if (cpu->cpu_name == NULL) {
|
if (cpu->cpu_name == NULL) {
|
||||||
printErr("Unable to find uarch without CPU name");
|
printErr("Unable to find uarch without CPU name");
|
||||||
@@ -487,30 +486,6 @@ struct uarch* get_uarch_from_cpuid(struct cpuInfo* cpu, uint32_t dump, uint32_t
|
|||||||
|
|
||||||
return arch;
|
return arch;
|
||||||
}
|
}
|
||||||
else if (dump == 0x000806EC) {
|
|
||||||
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 Comet Lake U or Whiskey Lake U)
|
|
||||||
// https://github.com/Dr-Noob/cpufetch/issues/298
|
|
||||||
if (strstr(cpu->cpu_name, "i3-8145U") != NULL ||
|
|
||||||
strstr(cpu->cpu_name, "i5-8265U") != NULL ||
|
|
||||||
strstr(cpu->cpu_name, "i5-8365U") != NULL ||
|
|
||||||
strstr(cpu->cpu_name, "i7-8565U") != NULL ||
|
|
||||||
strstr(cpu->cpu_name, "i7-8665U") != NULL ||
|
|
||||||
strstr(cpu->cpu_name, "5405U") != NULL ||
|
|
||||||
strstr(cpu->cpu_name, "4205U") != NULL) {
|
|
||||||
fill_uarch(arch, "Whiskey Lake", UARCH_WHISKEY_LAKE, 14);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fill_uarch(arch, "Comet Lake", UARCH_COMET_LAKE, 14);
|
|
||||||
}
|
|
||||||
|
|
||||||
return arch;
|
|
||||||
}
|
|
||||||
return get_uarch_from_cpuid_intel(ef, f, em, m, s);
|
return get_uarch_from_cpuid_intel(ef, f, em, m, s);
|
||||||
}
|
}
|
||||||
else if(cpu->cpu_vendor == CPU_VENDOR_AMD) {
|
else if(cpu->cpu_vendor == CPU_VENDOR_AMD) {
|
||||||
|
|||||||
Reference in New Issue
Block a user