diff --git a/src/common/cpu.c b/src/common/cpu.c index f93e950..1acf45b 100644 --- a/src/common/cpu.c +++ b/src/common/cpu.c @@ -32,13 +32,11 @@ int64_t get_freq(struct frequency* freq) { return freq->max; } -#ifdef ARCH_X86 +#if defined(ARCH_X86) || defined(ARCH_PPC) char* get_str_cpu_name(struct cpuInfo* cpu) { return cpu->cpu_name; } -#endif -#if defined(ARCH_X86) || defined(ARCH_PPC) char* get_str_sockets(struct topology* topo) { char* string = emalloc(sizeof(char) * 2); int32_t sanity_ret = snprintf(string, 2, "%d", topo->sockets); diff --git a/src/common/cpu.h b/src/common/cpu.h index bd61f8c..ebb4e03 100644 --- a/src/common/cpu.h +++ b/src/common/cpu.h @@ -116,9 +116,12 @@ struct cpuInfo { struct topology* topo; struct features* feat; -#ifdef ARCH_X86 +#if defined(ARCH_X86) || defined(ARCH_PPC) // CPU name from model char* cpu_name; +#endif + +#ifdef ARCH_X86 // Max cpuids levels uint32_t maxLevels; // Max cpuids extended levels diff --git a/src/common/printer.c b/src/common/printer.c index c052ffa..f966082 100644 --- a/src/common/printer.c +++ b/src/common/printer.c @@ -48,7 +48,7 @@ #define COLOR_RESET "\x1b[m" enum { -#if defined(ARCH_X86) +#if defined(ARCH_X86) || defined(ARCH_PPC) ATTRIBUTE_NAME, #elif ARCH_ARM ATTRIBUTE_SOC, @@ -77,7 +77,7 @@ enum { }; static const char* ATTRIBUTE_FIELDS [] = { -#if defined(ARCH_X86) +#if defined(ARCH_X86) || defined(ARCH_PPC) "Name:", #elif ARCH_ARM "SoC:", @@ -572,6 +572,7 @@ bool print_cpufetch_ppc(struct cpuInfo* cpu, STYLE s, struct colors* cs) { char* manufacturing_process = get_str_process(cpu); char* sockets = get_str_sockets(cpu->topo); char* max_frequency = get_str_freq(cpu->freq); + char* cpu_name = get_str_cpu_name(cpu); char* n_cores = get_str_topology(cpu->topo, false); char* n_cores_dual = get_str_topology(cpu->topo, true); char* altivec = get_str_altivec(cpu); @@ -582,10 +583,9 @@ bool print_cpufetch_ppc(struct cpuInfo* cpu, STYLE s, struct colors* cs) { char* l3 = get_str_l3(cpu->cach); char* pp = get_str_peak_performance(cpu,cpu->topo,get_freq(cpu->freq)); - /* - if(cpu->hv->present) { - setAttribute(art, ATTRIBUTE_HYPERVISOR, cpu->hv->hv_name); - }*/ + if(cpu_name != NULL) { + setAttribute(art,ATTRIBUTE_NAME,cpu_name); + } setAttribute(art,ATTRIBUTE_UARCH,uarch); setAttribute(art,ATTRIBUTE_TECHNOLOGY,manufacturing_process); setAttribute(art,ATTRIBUTE_FREQUENCY,max_frequency); diff --git a/src/ppc/ppc.c b/src/ppc/ppc.c index a75e31d..66fc397 100644 --- a/src/ppc/ppc.c +++ b/src/ppc/ppc.c @@ -166,6 +166,11 @@ struct cpuInfo* get_cpu_info() { *ptr = false; } + int len; + char* path = emalloc(sizeof(char) * (strlen(_PATH_DT) + strlen(_PATH_DT_PART) + 1)); + sprintf(path, "%s%s", _PATH_DT, _PATH_DT_PART); + + cpu->cpu_name = read_file(path, &len); cpu->pvr = mfpvr(); cpu->arch = get_cpu_uarch(cpu); cpu->freq = get_frequency_info(); diff --git a/src/ppc/udev.h b/src/ppc/udev.h index e13ad16..8c21875 100644 --- a/src/ppc/udev.h +++ b/src/ppc/udev.h @@ -2,6 +2,8 @@ #define __UDEV_PPC__ #include "../common/udev.h" +#define _PATH_DT "/proc/device-tree/vpd/root-node-vpd@a000/enclosure@1e00/backplane@800/processor@1000" +#define _PATH_DT_PART "/part-number" bool fill_core_ids_from_sys(int *core_ids, int total_cores); bool fill_package_ids_from_sys(int* package_ids, int total_cores);