From 5119ece0dd4b383b990201f54ddf045927efe957 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Tue, 13 Oct 2020 00:00:20 +0200 Subject: [PATCH] Refactoring defines to enums --- src/args.c | 57 +++++++++---------- src/args.h | 9 +++ src/cpuid.c | 127 ++++++++++++++++++------------------------ src/cpuid.h | 26 +++++---- src/global.c | 6 +- src/printer.c | 149 +++++++++++++++++++++++++++----------------------- src/printer.h | 8 --- src/uarch.c | 119 ++++++++++++++++++++-------------------- 8 files changed, 251 insertions(+), 250 deletions(-) diff --git a/src/args.c b/src/args.c index b153da7..0aba3b6 100644 --- a/src/args.c +++ b/src/args.c @@ -5,27 +5,26 @@ #include "args.h" #include "global.h" -#define ARG_STR_STYLE "style" -#define ARG_STR_COLOR "color" -#define ARG_STR_HELP "help" -#define ARG_STR_LEVELS "levels" -#define ARG_STR_VERBOSE "verbose" -#define ARG_STR_VERSION "version" - -#define ARG_CHAR_STYLE 0 -#define ARG_CHAR_COLOR 1 -#define ARG_CHAR_HELP 2 -#define ARG_CHAR_LEVELS 3 -#define ARG_CHAR_VERBOSE 4 -#define ARG_CHAR_VERSION 5 - -#define STYLE_STR_1 "fancy" -#define STYLE_STR_2 "retro" -#define STYLE_STR_3 "legacy" - #define COLOR_STR_INTEL "intel" #define COLOR_STR_AMD "amd" +static const char *SYTLES_STR_LIST[] = { + [STYLE_EMPTY] = NULL, + [STYLE_FANCY] = "fancy", + [STYLE_RETRO] = "retro", + [STYLE_LEGACY] = "legacy", + [STYLE_INVALID] = NULL +}; + +enum { + ARG_CHAR_STYLE, + ARG_CHAR_COLOR, + ARG_CHAR_HELP, + ARG_CHAR_LEVELS, + ARG_CHAR_VERBOSE, + ARG_CHAR_VERSION +}; + struct args_struct { bool levels_flag; bool help_flag; @@ -35,7 +34,6 @@ struct args_struct { struct colors* colors; }; -static const char* SYTLES_STR_LIST[STYLES_COUNT] = { STYLE_STR_1, STYLE_STR_2, STYLE_STR_3 }; static struct args_struct args; STYLE get_style() { @@ -63,12 +61,15 @@ bool verbose_enabled() { } STYLE parse_style(char* style) { - int i = 0; - while(i != STYLES_COUNT && strcmp(SYTLES_STR_LIST[i],style) != 0) + uint8_t i = 0; + uint8_t styles_count = sizeof(SYTLES_STR_LIST) / sizeof(SYTLES_STR_LIST[0]); + + while(i != styles_count && (SYTLES_STR_LIST[i] == NULL || strcmp(SYTLES_STR_LIST[i], style) != 0)) i++; - if(i == STYLES_COUNT) + if(i == styles_count) return STYLE_INVALID; + return i; } @@ -164,12 +165,12 @@ bool parse_args(int argc, char* argv[]) { args.colors = NULL; static struct option long_options[] = { - {ARG_STR_STYLE, required_argument, 0, ARG_CHAR_STYLE }, - {ARG_STR_COLOR, required_argument, 0, ARG_CHAR_COLOR }, - {ARG_STR_HELP, no_argument, 0, ARG_CHAR_HELP }, - {ARG_STR_LEVELS, no_argument, 0, ARG_CHAR_LEVELS }, - {ARG_STR_VERBOSE, no_argument, 0, ARG_CHAR_VERBOSE }, - {ARG_STR_VERSION, no_argument, 0, ARG_CHAR_VERSION }, + {"style", required_argument, 0, ARG_CHAR_STYLE }, + {"color", required_argument, 0, ARG_CHAR_COLOR }, + {"help", no_argument, 0, ARG_CHAR_HELP }, + {"levels", no_argument, 0, ARG_CHAR_LEVELS }, + {"verbose", no_argument, 0, ARG_CHAR_VERBOSE }, + {"version", no_argument, 0, ARG_CHAR_VERSION }, {0, 0, 0, 0} }; diff --git a/src/args.h b/src/args.h index e0fb039..91c7e99 100644 --- a/src/args.h +++ b/src/args.h @@ -17,6 +17,15 @@ struct colors { struct color* c4; }; +enum { + STYLE_EMPTY, + STYLE_FANCY, + STYLE_WILD, + STYLE_RETRO, + STYLE_LEGACY, + STYLE_INVALID +}; + #include "printer.h" bool parse_args(int argc, char* argv[]); diff --git a/src/cpuid.c b/src/cpuid.c index 2d67c81..f1b627c 100755 --- a/src/cpuid.c +++ b/src/cpuid.c @@ -20,20 +20,25 @@ #define CPU_VENDOR_INTEL_STRING "GenuineIntel" #define CPU_VENDOR_AMD_STRING "AuthenticAMD" -#define HV_VENDOR_KVM_STRING "KVMKVMKVM" -#define HV_VENDOR_QEMU_STRING "TCGTCGTCGTCG" -#define HV_VENDOR_HYPERV_STRING "Microsoft Hv" -#define HV_VENDOR_VMWARE_STRING "VMwareVMware" -#define HV_VENDOR_XEN_STRING "XenVMMXenVMM" -#define HV_VENDOR_PARALLELS_STRING "lrpepyh vr" +static const char *hv_vendors_string[] = { + [HV_VENDOR_KVM] = "KVMKVMKVM", + [HV_VENDOR_QEMU] = "TCGTCGTCGTCG", + [HV_VENDOR_HYPERV] = "Microsoft Hv", + [HV_VENDOR_VMWARE] = "VMwareVMware", + [HV_VENDOR_XEN] = "XenVMMXenVMM", + [HV_VENDOR_PARALLELS] = "lrpepyh vr", + [HV_VENDOR_INVALID] = NULL +}; -#define HV_KVM_STRING "KVM" -#define HV_QEMU_STRING "QEMU" -#define HV_HYPERV_STRING "Microsoft Hyper-V" -#define HV_VMWARE_STRING "VMware" -#define HV_XEN_STRING "Xen" -#define HV_PARALLELS_STRING "Parallels" -#define HV_UNKNOWN_STRING "Unknown" +static char *hv_vendors_name[] = { + [HV_VENDOR_KVM] = "KVM", + [HV_VENDOR_QEMU] = "QEMU", + [HV_VENDOR_HYPERV] = "Microsoft Hyper-V", + [HV_VENDOR_VMWARE] = "VMware", + [HV_VENDOR_XEN] = "Xen", + [HV_VENDOR_PARALLELS] = "Parallels", + [HV_VENDOR_INVALID] = "Unknown" +}; #define STRING_YES "Yes" #define STRING_NO "No" @@ -106,40 +111,23 @@ void init_cache_struct(struct cache* cach) { cach->L3->exists = false; } -void get_cpu_vendor_internal(char* name, uint32_t ebx,uint32_t ecx,uint32_t edx) { - name[__COUNTER__] = ebx & MASK; - name[__COUNTER__] = (ebx>>8) & MASK; - name[__COUNTER__] = (ebx>>16) & MASK; - name[__COUNTER__] = (ebx>>24) & MASK; - - name[__COUNTER__] = edx & MASK; - name[__COUNTER__] = (edx>>8) & MASK; - name[__COUNTER__] = (edx>>16) & MASK; - name[__COUNTER__] = (edx>>24) & MASK; - - name[__COUNTER__] = ecx & MASK; - name[__COUNTER__] = (ecx>>8) & MASK; - name[__COUNTER__] = (ecx>>16) & MASK; - name[__COUNTER__] = (ecx>>24) & MASK; -} - -void get_hv_vendor_internal(char* name, uint32_t ebx, uint32_t ecx, uint32_t edx) { +void get_name_cpuid(char* name, uint32_t reg1, uint32_t reg2, uint32_t reg3) { uint32_t c = 0; - name[c++] = ebx & MASK; - name[c++] = (ebx>>8) & MASK; - name[c++] = (ebx>>16) & MASK; - name[c++] = (ebx>>24) & MASK; + name[c++] = reg1 & MASK; + name[c++] = (reg1>>8) & MASK; + name[c++] = (reg1>>16) & MASK; + name[c++] = (reg1>>24) & MASK; - name[c++] = ecx & MASK; - name[c++] = (ecx>>8) & MASK; - name[c++] = (ecx>>16) & MASK; - name[c++] = (ecx>>24) & MASK; + name[c++] = reg2 & MASK; + name[c++] = (reg2>>8) & MASK; + name[c++] = (reg2>>16) & MASK; + name[c++] = (reg2>>24) & MASK; - name[c++] = edx & MASK; - name[c++] = (edx>>8) & MASK; - name[c++] = (edx>>16) & MASK; - name[c++] = (edx>>24) & MASK; + name[c++] = reg3 & MASK; + name[c++] = (reg3>>8) & MASK; + name[c++] = (reg3>>16) & MASK; + name[c++] = (reg3>>24) & MASK; } char* get_str_cpu_name_internal() { @@ -214,9 +202,7 @@ struct hypervisor* get_hp_info(bool hv_present) { return hv; } - hv->present = true; - hv->hv_name = malloc(sizeof(char) * (HYPERVISOR_NAME_MAX_LENGTH+1)); - memset(hv->hv_name, 0, HYPERVISOR_NAME_MAX_LENGTH+1); + hv->present = true; uint32_t eax = 0x40000000; uint32_t ebx = 0; @@ -227,45 +213,31 @@ struct hypervisor* get_hp_info(bool hv_present) { char name[13]; memset(name, 0, 13); - get_hv_vendor_internal(name, ebx, ecx, edx); + get_name_cpuid(name, ebx, ecx, edx); - if(strcmp(HV_VENDOR_KVM_STRING, name) == 0) { - hv->hv_vendor = HV_VENDOR_KVM; - strcpy(hv->hv_name, HV_KVM_STRING); + bool found = false; + uint8_t len = sizeof(hv_vendors_string) / sizeof(hv_vendors_string[0]); + + for(uint8_t v=0; v < len && !found; v++) { + if(strcmp(hv_vendors_string[v], name) == 0) { + hv->hv_vendor = v; + found = true; + } } - else if (strcmp(HV_VENDOR_QEMU_STRING, name) == 0) { - hv->hv_vendor = HV_VENDOR_QEMU; - strcpy(hv->hv_name, HV_QEMU_STRING); - } - else if (strcmp(HV_VENDOR_HYPERV_STRING, name) == 0) { - hv->hv_vendor = HV_VENDOR_HYPERV; - strcpy(hv->hv_name, HV_HYPERV_STRING); - } - else if (strcmp(HV_VENDOR_VMWARE_STRING, name) == 0) { - hv->hv_vendor = HV_VENDOR_VMWARE; - strcpy(hv->hv_name, HV_VMWARE_STRING); - } - else if (strcmp(HV_VENDOR_XEN_STRING, name) == 0) { - hv->hv_vendor = HV_VENDOR_XEN; - strcpy(hv->hv_name, HV_XEN_STRING); - } - else if (strcmp(HV_VENDOR_PARALLELS_STRING, name) == 0) { - hv->hv_vendor = HV_VENDOR_PARALLELS; - strcpy(hv->hv_name, HV_PARALLELS_STRING); - } - else { + + if(!found) { hv->hv_vendor = HV_VENDOR_INVALID; - printWarn("Unknown hypervisor vendor: %s", name); - strcpy(hv->hv_name, HV_UNKNOWN_STRING); + printWarn("Unknown hypervisor vendor: %s", name); } + hv->hv_name = hv_vendors_name[hv->hv_vendor]; + return hv; } struct cpuInfo* get_cpu_info() { struct cpuInfo* cpu = malloc(sizeof(struct cpuInfo)); init_cpu_info(cpu); - cpu->hv = malloc(sizeof(struct hypervisor)); uint32_t eax = 0; uint32_t ebx = 0; @@ -279,7 +251,7 @@ struct cpuInfo* get_cpu_info() { //Fill vendor char name[13]; memset(name,0,13); - get_cpu_vendor_internal(name, ebx, ecx, edx); + get_name_cpuid(name, ebx, edx, ecx); if(strcmp(CPU_VENDOR_INTEL_STRING,name) == 0) cpu->cpu_vendor = CPU_VENDOR_INTEL; @@ -1076,8 +1048,13 @@ void free_freq_struct(struct frequency* freq) { free(freq); } +void free_hv_struct(struct hypervisor* hv) { + free(hv); +} + void free_cpuinfo_struct(struct cpuInfo* cpu) { free_uarch_struct(cpu->arch); + free_hv_struct(cpu->hv); free(cpu->cpu_name); free(cpu); } diff --git a/src/cpuid.h b/src/cpuid.h index 32f394c..4ff2b83 100644 --- a/src/cpuid.h +++ b/src/cpuid.h @@ -3,19 +3,21 @@ #include -#define CPU_VENDOR_EMPTY 0 -#define CPU_VENDOR_INTEL 1 -#define CPU_VENDOR_AMD 2 -#define CPU_VENDOR_INVALID 3 +enum { + CPU_VENDOR_INTEL, + CPU_VENDOR_AMD, + CPU_VENDOR_INVALID +}; -#define HV_VENDOR_EMPTY 0 -#define HV_VENDOR_KVM 1 -#define HV_VENDOR_QEMU 2 -#define HV_VENDOR_HYPERV 3 -#define HV_VENDOR_VMWARE 4 -#define HV_VENDOR_XEN 5 -#define HV_VENDOR_PARALLELS 6 -#define HV_VENDOR_INVALID 7 +enum { + HV_VENDOR_KVM, + HV_VENDOR_QEMU, + HV_VENDOR_HYPERV, + HV_VENDOR_VMWARE, + HV_VENDOR_XEN, + HV_VENDOR_PARALLELS, + HV_VENDOR_INVALID +}; #define UNKNOWN_FREQ -1 diff --git a/src/global.c b/src/global.c index cdd9154..f356122 100644 --- a/src/global.c +++ b/src/global.c @@ -16,8 +16,10 @@ #endif -#define LOG_LEVEL_NORMAL 0 -#define LOG_LEVEL_VERBOSE 1 +enum { + LOG_LEVEL_NORMAL, + LOG_LEVEL_VERBOSE +}; int LOG_LEVEL; diff --git a/src/printer.c b/src/printer.c index 7a507cc..babf6b8 100644 --- a/src/printer.c +++ b/src/printer.c @@ -24,56 +24,59 @@ #define COL_AMD_RETRO_2 "\x1b[32;1m" #define RESET "\x1b[m" -#define TITLE_NAME "Name:" -#define TITLE_FREQUENCY "Max Frequency:" -#define TITLE_SOCKETS "Sockets:" -#define TITLE_NCORES "Cores:" -#define TITLE_NCORES_DUAL "Cores (Total):" -#define TITLE_AVX "AVX:" -#define TITLE_SSE "SSE:" -#define TITLE_FMA "FMA:" -#define TITLE_AES "AES:" -#define TITLE_SHA "SHA:" -#define TITLE_L1i "L1i Size:" -#define TITLE_L1d "L1d Size:" -#define TITLE_L2 "L2 Size:" -#define TITLE_L3 "L3 Size:" -#define TITLE_PEAK "Peak Performance:" -#define TITLE_UARCH "Microarchitecture:" -#define TITLE_TECHNOLOGY "Technology:" -#define TITLE_HYPERVISOR "Hypervisor:" +enum { + ATTRIBUTE_NAME, + ATTRIBUTE_HYPERVISOR, + ATTRIBUTE_UARCH, + ATTRIBUTE_TECHNOLOGY, + ATTRIBUTE_FREQUENCY, + ATTRIBUTE_SOCKETS, + ATTRIBUTE_NCORES, + ATTRIBUTE_NCORES_DUAL, + ATTRIBUTE_AVX, + ATTRIBUTE_FMA, + ATTRIBUTE_L1i, + ATTRIBUTE_L1d, + ATTRIBUTE_L2, + ATTRIBUTE_L3, + ATTRIBUTE_PEAK +}; -#define MAX_ATTRIBUTE_COUNT 15 -#define ATTRIBUTE_NAME 0 -#define ATTRIBUTE_HYPERVISOR 1 -#define ATTRIBUTE_UARCH 2 -#define ATTRIBUTE_TECHNOLOGY 3 -#define ATTRIBUTE_FREQUENCY 4 -#define ATTRIBUTE_SOCKETS 5 -#define ATTRIBUTE_NCORES 6 -#define ATTRIBUTE_NCORES_DUAL 7 -#define ATTRIBUTE_AVX 8 -#define ATTRIBUTE_FMA 9 -#define ATTRIBUTE_L1i 10 -#define ATTRIBUTE_L1d 11 -#define ATTRIBUTE_L2 12 -#define ATTRIBUTE_L3 13 -#define ATTRIBUTE_PEAK 14 +static const char* ATTRIBUTE_FIELDS [] = { + "Name:", + "Hypervisor:", + "Microarchitecture:", + "Technology:", + "Max Frequency:", + "Sockets:", + "Cores:", + "Cores (Total):", + "AVX:", + "FMA:", + "L1i Size:", + "L1d Size:", + "L2 Size:", + "L3 Size:", + "Peak Performance:", +}; -static const char* ATTRIBUTE_FIELDS [MAX_ATTRIBUTE_COUNT] = { TITLE_NAME, TITLE_HYPERVISOR, TITLE_UARCH, TITLE_TECHNOLOGY, - TITLE_FREQUENCY, TITLE_SOCKETS, - TITLE_NCORES, TITLE_NCORES_DUAL, - TITLE_AVX, - TITLE_FMA, TITLE_L1i, TITLE_L1d, TITLE_L2, TITLE_L3, - TITLE_PEAK, - }; - -static const int ATTRIBUTE_LIST[MAX_ATTRIBUTE_COUNT] = { ATTRIBUTE_NAME, ATTRIBUTE_HYPERVISOR, ATTRIBUTE_UARCH, ATTRIBUTE_TECHNOLOGY, - ATTRIBUTE_FREQUENCY, ATTRIBUTE_SOCKETS, - ATTRIBUTE_NCORES, ATTRIBUTE_NCORES_DUAL, ATTRIBUTE_AVX, - ATTRIBUTE_FMA, - ATTRIBUTE_L1i, ATTRIBUTE_L1d, ATTRIBUTE_L2, ATTRIBUTE_L3, - ATTRIBUTE_PEAK }; +static const int ATTRIBUTE_LIST[] = { + ATTRIBUTE_NAME, + ATTRIBUTE_HYPERVISOR, + ATTRIBUTE_UARCH, + ATTRIBUTE_TECHNOLOGY, + ATTRIBUTE_FREQUENCY, + ATTRIBUTE_SOCKETS, + ATTRIBUTE_NCORES, + ATTRIBUTE_NCORES_DUAL, + ATTRIBUTE_AVX, + ATTRIBUTE_FMA, + ATTRIBUTE_L1i, + ATTRIBUTE_L1d, + ATTRIBUTE_L2, + ATTRIBUTE_L3, + ATTRIBUTE_PEAK +}; struct ascii { char art[NUMBER_OF_LINES][LINE_SIZE]; @@ -83,9 +86,11 @@ struct ascii { char color2_text[100]; char ascii_chars[2]; char reset[100]; - char* attributes[MAX_ATTRIBUTE_COUNT]; + char** attributes; + uint32_t max_attributes; uint32_t n_attributes_set; VENDOR vendor; + STYLE style; }; void setAttribute(struct ascii* art, int type, char* value) { @@ -110,7 +115,8 @@ char* rgb_to_ansi(struct color* c, bool background, bool bold) { struct ascii* set_ascii(VENDOR cpuVendor, STYLE style, struct colors* cs) { // Sanity checks // - for(int i=0; i < MAX_ATTRIBUTE_COUNT; i++) { + uint32_t max_attributes = sizeof(ATTRIBUTE_LIST) / sizeof(ATTRIBUTE_LIST[0]); + for(uint32_t i=0; i < max_attributes; i++) { if(ATTRIBUTE_FIELDS[i] == NULL) { printBug("Attribute field at position %d is empty", i); return NULL; @@ -125,11 +131,13 @@ struct ascii* set_ascii(VENDOR cpuVendor, STYLE style, struct colors* cs) { struct ascii* art = malloc(sizeof(struct ascii)); art->n_attributes_set = 0; art->vendor = cpuVendor; - for(int i=0; i < MAX_ATTRIBUTE_COUNT; i++) + art->max_attributes = max_attributes; + art->attributes = malloc(sizeof(char *) * art->max_attributes); + for(uint32_t i=0; i < art->max_attributes; i++) art->attributes[i] = NULL; strcpy(art->reset,RESET); - if(cpuVendor == CPU_VENDOR_INTEL) { + if(art->vendor == CPU_VENDOR_INTEL) { COL_FANCY_1 = COL_INTEL_FANCY_1; COL_FANCY_2 = COL_INTEL_FANCY_2; COL_FANCY_3 = COL_INTEL_FANCY_3; @@ -153,16 +161,18 @@ struct ascii* set_ascii(VENDOR cpuVendor, STYLE style, struct colors* cs) { } art->ascii_chars[1] = '#'; - // If style is emtpy, set the default style if(style == STYLE_EMPTY) { #ifdef _WIN32 - style = STYLE_LEGACY; + art->style = STYLE_LEGACY; #else - style = STYLE_FANCY; - #endif + art->style = STYLE_FANCY; + #endif + } + else { + art->style = style; } - switch(style) { + switch(art->style) { case STYLE_LEGACY: strcpy(art->color1_ascii,COL_NONE); strcpy(art->color2_ascii,COL_NONE); @@ -210,15 +220,18 @@ struct ascii* set_ascii(VENDOR cpuVendor, STYLE style, struct colors* cs) { break; case STYLE_INVALID: default: - printBug("Found invalid style (%d)",style); + printBug("Found invalid style (%d)", art->style); return NULL; } char tmp[NUMBER_OF_LINES*LINE_SIZE]; - if(cpuVendor == CPU_VENDOR_INTEL) strcpy(tmp, INTEL_ASCII); - else strcpy(tmp, AMD_ASCII); - for(int i=0; i < NUMBER_OF_LINES; i++) - strncpy(art->art[i], tmp + i*LINE_SIZE, LINE_SIZE); + if(art->vendor == CPU_VENDOR_INTEL) + strcpy(tmp, INTEL_ASCII); + else + strcpy(tmp, AMD_ASCII); + + for(int i=0; i < NUMBER_OF_LINES; i++) + strncpy(art->art[i], tmp + i*LINE_SIZE, LINE_SIZE); return art; } @@ -235,7 +248,7 @@ void print_ascii_intel(struct ascii* art, uint32_t la) { uint32_t space_right; uint32_t space_up = (NUMBER_OF_LINES - art->n_attributes_set)/2; uint32_t space_down = NUMBER_OF_LINES - art->n_attributes_set - space_up; - + printf("\n"); for(uint32_t n=0;ncolor2_ascii, art->ascii_chars[1], art->reset); } - else - printf("%s%c%s", art->color1_ascii, art->ascii_chars[0], art->reset); + else { + printf("%s%c%s", art->color1_ascii, art->ascii_chars[0], art->reset); + } } else { if(art->art[n][i] != ' ' && art->art[n][i] != '\0') { @@ -278,7 +292,7 @@ void print_ascii_amd(struct ascii* art, uint32_t la) { for(uint32_t n=0;nart[n][i] == '@') - printf("%s%c%s", art->color1_ascii, art->ascii_chars[0], art->reset); + printf("%s%c%s", art->color1_ascii, art->ascii_chars[0], art->reset); else if(art->art[n][i] == '#') printf("%s%c%s", art->color2_ascii, art->ascii_chars[1], art->reset); else @@ -300,7 +314,7 @@ uint32_t longest_attribute_length(struct ascii* art) { uint32_t max = 0; uint64_t len = 0; - for(int i=0; i < MAX_ATTRIBUTE_COUNT; i++) { + for(uint32_t i=0; i < art->max_attributes; i++) { if(art->attributes[i] != NULL) { len = strlen(ATTRIBUTE_FIELDS[i]); if(len > max) max = len; @@ -380,6 +394,7 @@ bool print_cpufetch(struct cpuInfo* cpu, struct cache* cach, struct frequency* f free(l3); free(pp); + free(art->attributes); free(art); if(cs != NULL) free_colors_struct(cs); diff --git a/src/printer.h b/src/printer.h index ed93266..0fe1e25 100644 --- a/src/printer.h +++ b/src/printer.h @@ -6,14 +6,6 @@ typedef int STYLE; #include "args.h" #include "cpuid.h" -#define STYLES_COUNT 3 - -#define STYLE_INVALID -2 -#define STYLE_EMPTY -1 -#define STYLE_FANCY 0 -#define STYLE_RETRO 1 -#define STYLE_LEGACY 2 - #define COLOR_DEFAULT_INTEL "15,125,194:230,230,230:40,150,220:230,230,230" #define COLOR_DEFAULT_AMD "250,250,250:0,154,102:250,250,250:0,154,102" diff --git a/src/uarch.c b/src/uarch.c index 4a53d5a..85ce6b5 100644 --- a/src/uarch.c +++ b/src/uarch.c @@ -43,64 +43,67 @@ typedef uint32_t MICROARCH; // Unknown manufacturing process #define UNK -1 -#define UARCH_UNKNOWN 0x000 -#define UARCH_P5 0x001 -#define UARCH_P6 0x002 -#define UARCH_DOTHAN 0x003 -#define UARCH_YONAH 0x004 -#define UARCH_MEROM 0x005 -#define UARCH_PENYR 0x006 -#define UARCH_NEHALEM 0x007 -#define UARCH_WESTMERE 0x008 -#define UARCH_BONNELL 0x009 -#define UARCH_SALTWELL 0x010 -#define UARCH_SANDY_BRIDGE 0x011 -#define UARCH_SILVERMONT 0x012 -#define UARCH_IVY_BRIDGE 0x013 -#define UARCH_HASWELL 0x014 -#define UARCH_BROADWELL 0x015 -#define UARCH_AIRMONT 0x016 -#define UARCH_KABY_LAKE 0x017 -#define UARCH_SKYLAKE 0x018 -#define UARCH_CASCADE_LAKE 0x019 -#define UARCH_COOPER_LAKE 0x020 -#define UARCH_KNIGHTS_LANDING 0x021 -#define UARCH_KNIGHTS_MILL 0x022 -#define UARCH_GOLDMONT 0x023 -#define UARCH_PALM_COVE 0x024 -#define UARCH_SUNNY_COVE 0x025 -#define UARCH_GOLDMONT_PLUS 0x026 -#define UARCH_TREMONT 0x027 -#define UARCH_WILLOW_COVE 0x028 -#define UARCH_COFFE_LAKE 0x029 -#define UARCH_ITANIUM 0x030 -#define UARCH_KNIGHTS_FERRY 0x031 -#define UARCH_KNIGHTS_CORNER 0x032 -#define UARCH_WILLAMETTE 0x033 -#define UARCH_NORTHWOOD 0x034 -#define UARCH_PRESCOTT 0x035 -#define UARCH_CEDAR_MILL 0x036 -#define UARCH_ITANIUM2 0x037 -#define UARCH_ICE_LAKE 0x038 - -#define UARCH_AM486 0x038 -#define UARCH_AM5X86 0x039 -#define UARCH_K6 0x040 -#define UARCH_K7 0x041 -#define UARCH_K8 0x042 -#define UARCH_K10 0x043 -#define UARCH_PUMA_2008 0x044 -#define UARCH_BOBCAT 0x045 -#define UARCH_BULLDOZER 0x046 -#define UARCH_PILEDRIVER 0x047 -#define UARCH_STEAMROLLER 0x048 -#define UARCH_EXCAVATOR 0x049 -#define UARCH_JAGUAR 0x050 -#define UARCH_PUMA_2014 0x051 -#define UARCH_ZEN 0x052 -#define UARCH_ZEN_PLUS 0x053 -#define UARCH_ZEN2 0x054 -#define UARCH_ZEN3 0x055 +enum { + UARCH_UNKNOWN, + // INTEL // + UARCH_P5, + UARCH_P6, + UARCH_DOTHAN, + UARCH_YONAH, + UARCH_MEROM, + UARCH_PENYR, + UARCH_NEHALEM, + UARCH_WESTMERE, + UARCH_BONNELL, + UARCH_SALTWELL, + UARCH_SANDY_BRIDGE, + UARCH_SILVERMONT, + UARCH_IVY_BRIDGE, + UARCH_HASWELL, + UARCH_BROADWELL, + UARCH_AIRMONT, + UARCH_KABY_LAKE, + UARCH_SKYLAKE, + UARCH_CASCADE_LAKE, + UARCH_COOPER_LAKE, + UARCH_KNIGHTS_LANDING, + UARCH_KNIGHTS_MILL, + UARCH_GOLDMONT, + UARCH_PALM_COVE, + UARCH_SUNNY_COVE, + UARCH_GOLDMONT_PLUS, + UARCH_TREMONT, + UARCH_WILLOW_COVE, + UARCH_COFFE_LAKE, + UARCH_ITANIUM, + UARCH_KNIGHTS_FERRY, + UARCH_KNIGHTS_CORNER, + UARCH_WILLAMETTE, + UARCH_NORTHWOOD, + UARCH_PRESCOTT, + UARCH_CEDAR_MILL, + UARCH_ITANIUM2, + UARCH_ICE_LAKE, + // AMD // + UARCH_AM486, + UARCH_AM5X86, + UARCH_K6, + UARCH_K7, + UARCH_K8, + UARCH_K10, + UARCH_PUMA_2008, + UARCH_BOBCAT, + UARCH_BULLDOZER, + UARCH_PILEDRIVER, + UARCH_STEAMROLLER, + UARCH_EXCAVATOR, + UARCH_JAGUAR, + UARCH_PUMA_2014, + UARCH_ZEN, + UARCH_ZEN_PLUS, + UARCH_ZEN2, + UARCH_ZEN3 +}; struct uarch { MICROARCH uarch;