mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +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;
|
||||
}
|
||||
|
||||
#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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user