mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
[v0.98][PPC] Add part number detection using linux device tree
This commit is contained in:
@@ -32,13 +32,11 @@ int64_t get_freq(struct frequency* freq) {
|
|||||||
return freq->max;
|
return freq->max;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
char* get_str_cpu_name(struct cpuInfo* cpu) {
|
char* get_str_cpu_name(struct cpuInfo* cpu) {
|
||||||
return cpu->cpu_name;
|
return cpu->cpu_name;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
|
||||||
char* get_str_sockets(struct topology* topo) {
|
char* get_str_sockets(struct topology* topo) {
|
||||||
char* string = emalloc(sizeof(char) * 2);
|
char* string = emalloc(sizeof(char) * 2);
|
||||||
int32_t sanity_ret = snprintf(string, 2, "%d", topo->sockets);
|
int32_t sanity_ret = snprintf(string, 2, "%d", topo->sockets);
|
||||||
|
|||||||
@@ -116,9 +116,12 @@ struct cpuInfo {
|
|||||||
struct topology* topo;
|
struct topology* topo;
|
||||||
struct features* feat;
|
struct features* feat;
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
// CPU name from model
|
// CPU name from model
|
||||||
char* cpu_name;
|
char* cpu_name;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARCH_X86
|
||||||
// Max cpuids levels
|
// Max cpuids levels
|
||||||
uint32_t maxLevels;
|
uint32_t maxLevels;
|
||||||
// Max cpuids extended levels
|
// Max cpuids extended levels
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
#define COLOR_RESET "\x1b[m"
|
#define COLOR_RESET "\x1b[m"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
#if defined(ARCH_X86)
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
ATTRIBUTE_NAME,
|
ATTRIBUTE_NAME,
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
ATTRIBUTE_SOC,
|
ATTRIBUTE_SOC,
|
||||||
@@ -77,7 +77,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const char* ATTRIBUTE_FIELDS [] = {
|
static const char* ATTRIBUTE_FIELDS [] = {
|
||||||
#if defined(ARCH_X86)
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
"Name:",
|
"Name:",
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
"SoC:",
|
"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* manufacturing_process = get_str_process(cpu);
|
||||||
char* sockets = get_str_sockets(cpu->topo);
|
char* sockets = get_str_sockets(cpu->topo);
|
||||||
char* max_frequency = get_str_freq(cpu->freq);
|
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 = get_str_topology(cpu->topo, false);
|
||||||
char* n_cores_dual = get_str_topology(cpu->topo, true);
|
char* n_cores_dual = get_str_topology(cpu->topo, true);
|
||||||
char* altivec = get_str_altivec(cpu);
|
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* l3 = get_str_l3(cpu->cach);
|
||||||
char* pp = get_str_peak_performance(cpu,cpu->topo,get_freq(cpu->freq));
|
char* pp = get_str_peak_performance(cpu,cpu->topo,get_freq(cpu->freq));
|
||||||
|
|
||||||
/*
|
if(cpu_name != NULL) {
|
||||||
if(cpu->hv->present) {
|
setAttribute(art,ATTRIBUTE_NAME,cpu_name);
|
||||||
setAttribute(art, ATTRIBUTE_HYPERVISOR, cpu->hv->hv_name);
|
}
|
||||||
}*/
|
|
||||||
setAttribute(art,ATTRIBUTE_UARCH,uarch);
|
setAttribute(art,ATTRIBUTE_UARCH,uarch);
|
||||||
setAttribute(art,ATTRIBUTE_TECHNOLOGY,manufacturing_process);
|
setAttribute(art,ATTRIBUTE_TECHNOLOGY,manufacturing_process);
|
||||||
setAttribute(art,ATTRIBUTE_FREQUENCY,max_frequency);
|
setAttribute(art,ATTRIBUTE_FREQUENCY,max_frequency);
|
||||||
|
|||||||
@@ -166,6 +166,11 @@ struct cpuInfo* get_cpu_info() {
|
|||||||
*ptr = false;
|
*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->pvr = mfpvr();
|
||||||
cpu->arch = get_cpu_uarch(cpu);
|
cpu->arch = get_cpu_uarch(cpu);
|
||||||
cpu->freq = get_frequency_info();
|
cpu->freq = get_frequency_info();
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#define __UDEV_PPC__
|
#define __UDEV_PPC__
|
||||||
|
|
||||||
#include "../common/udev.h"
|
#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_core_ids_from_sys(int *core_ids, int total_cores);
|
||||||
bool fill_package_ids_from_sys(int* package_ids, int total_cores);
|
bool fill_package_ids_from_sys(int* package_ids, int total_cores);
|
||||||
|
|||||||
Reference in New Issue
Block a user