mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
[v0.98][PPC] Start PowerPC port. It just compiles but nothing is displayed
This commit is contained in:
6
Makefile
6
Makefile
@@ -17,7 +17,13 @@ ifneq ($(OS),Windows_NT)
|
|||||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)cpuid.c $(SRC_DIR)apic.c $(SRC_DIR)cpuid_asm.c $(SRC_DIR)uarch.c
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)cpuid.c $(SRC_DIR)apic.c $(SRC_DIR)cpuid_asm.c $(SRC_DIR)uarch.c
|
||||||
HEADERS += $(COMMON_HDR) $(SRC_DIR)cpuid.h $(SRC_DIR)apic.h $(SRC_DIR)cpuid_asm.h $(SRC_DIR)uarch.h
|
HEADERS += $(COMMON_HDR) $(SRC_DIR)cpuid.h $(SRC_DIR)apic.h $(SRC_DIR)cpuid_asm.h $(SRC_DIR)uarch.h
|
||||||
CFLAGS += -DARCH_X86
|
CFLAGS += -DARCH_X86
|
||||||
|
else ifeq ($(arch), $(filter $(arch), ppc64el ppc64le ppc32))
|
||||||
|
SRC_DIR=src/ppc/
|
||||||
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)ppc.c $(SRC_DIR)uarch.c
|
||||||
|
HEADERS += $(COMMON_HDR) $(SRC_DIR)ppc.h $(SRC_DIR)uarch.h
|
||||||
|
CFLAGS += -DARCH_PPC
|
||||||
else
|
else
|
||||||
|
# Assume ARM
|
||||||
SRC_DIR=src/arm/
|
SRC_DIR=src/arm/
|
||||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)midr.c $(SRC_DIR)uarch.c $(SRC_DIR)soc.c $(SRC_DIR)udev.c
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)midr.c $(SRC_DIR)uarch.c $(SRC_DIR)soc.c $(SRC_DIR)udev.c
|
||||||
HEADERS += $(COMMON_HDR) $(SRC_DIR)midr.h $(SRC_DIR)uarch.h $(SRC_DIR)soc.h $(SRC_DIR)udev.c $(SRC_DIR)socs.h
|
HEADERS += $(COMMON_HDR) $(SRC_DIR)midr.h $(SRC_DIR)uarch.h $(SRC_DIR)soc.h $(SRC_DIR)udev.c $(SRC_DIR)socs.h
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
#include "../x86/uarch.h"
|
#include "../x86/uarch.h"
|
||||||
|
#elif ARCH_PPC
|
||||||
|
#include "../ppc/uarch.h"
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
#include "../arm/uarch.h"
|
#include "../arm/uarch.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -30,11 +32,13 @@ 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
|
||||||
|
|
||||||
|
#ifdef ARCH_X86
|
||||||
char* get_str_sockets(struct topology* topo) {
|
char* get_str_sockets(struct topology* topo) {
|
||||||
char* string = malloc(sizeof(char) * 2);
|
char* string = malloc(sizeof(char) * 2);
|
||||||
int32_t sanity_ret = snprintf(string, 2, "%d", topo->sockets);
|
int32_t sanity_ret = snprintf(string, 2, "%d", topo->sockets);
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ struct features {
|
|||||||
bool FMA3;
|
bool FMA3;
|
||||||
bool FMA4;
|
bool FMA4;
|
||||||
bool SHA;
|
bool SHA;
|
||||||
|
#elif ARCH_PPC
|
||||||
|
bool altivec;
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
bool NEON;
|
bool NEON;
|
||||||
bool SHA1;
|
bool SHA1;
|
||||||
@@ -112,6 +114,11 @@ struct cpuInfo {
|
|||||||
struct topology* topo;
|
struct topology* topo;
|
||||||
struct features* feat;
|
struct features* feat;
|
||||||
|
|
||||||
|
#ifdef ARCH_PPC
|
||||||
|
// CPU name from model
|
||||||
|
char* cpu_name;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
// CPU name from model
|
// CPU name from model
|
||||||
char* cpu_name;
|
char* cpu_name;
|
||||||
@@ -142,6 +149,10 @@ char* get_str_sockets(struct topology* topo);
|
|||||||
uint32_t get_nsockets(struct topology* topo);
|
uint32_t get_nsockets(struct topology* topo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARCH_PPC
|
||||||
|
char* get_str_cpu_name(struct cpuInfo* cpu);
|
||||||
|
#endif
|
||||||
|
|
||||||
VENDOR get_cpu_vendor(struct cpuInfo* cpu);
|
VENDOR get_cpu_vendor(struct cpuInfo* cpu);
|
||||||
int64_t get_freq(struct frequency* freq);
|
int64_t get_freq(struct frequency* freq);
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void printBug(const char *fmt, ...) {
|
|||||||
vsnprintf(buffer,buffer_size, fmt, args);
|
vsnprintf(buffer,buffer_size, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
fprintf(stderr,RED "[ERROR]: "RESET "%s\n",buffer);
|
fprintf(stderr,RED "[ERROR]: "RESET "%s\n",buffer);
|
||||||
#ifdef ARCH_X86
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
fprintf(stderr,"Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues\n");
|
fprintf(stderr,"Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues\n");
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
fprintf(stderr,"Please, create a new issue with this error message, your smartphone/computer model and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues\n");
|
fprintf(stderr,"Please, create a new issue with this error message, your smartphone/computer model and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues\n");
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
static const char* ARCH_STR = "x86_64 build";
|
static const char* ARCH_STR = "x86_64 build";
|
||||||
#include "../x86/cpuid.h"
|
#include "../x86/cpuid.h"
|
||||||
|
#elif ARCH_PPC
|
||||||
|
static const char* ARCH_STR = "PowerPC build";
|
||||||
|
#include "../ppc/ppc.h"
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
static const char* ARCH_STR = "ARM build";
|
static const char* ARCH_STR = "ARM build";
|
||||||
#include "../arm/midr.h"
|
#include "../arm/midr.h"
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
#include "../x86/uarch.h"
|
#include "../x86/uarch.h"
|
||||||
#include "../x86/cpuid.h"
|
#include "../x86/cpuid.h"
|
||||||
|
#elif ARCH_PPC
|
||||||
|
#include "../ppc/ppc.h"
|
||||||
#else
|
#else
|
||||||
#include "../arm/uarch.h"
|
#include "../arm/uarch.h"
|
||||||
#include "../arm/midr.h"
|
#include "../arm/midr.h"
|
||||||
@@ -45,7 +47,7 @@
|
|||||||
#define COLOR_RESET "\x1b[m"
|
#define COLOR_RESET "\x1b[m"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
#ifdef ARCH_X86
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
ATTRIBUTE_NAME,
|
ATTRIBUTE_NAME,
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
ATTRIBUTE_SOC,
|
ATTRIBUTE_SOC,
|
||||||
@@ -72,7 +74,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const char* ATTRIBUTE_FIELDS [] = {
|
static const char* ATTRIBUTE_FIELDS [] = {
|
||||||
#ifdef ARCH_X86
|
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||||
"Name:",
|
"Name:",
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
"SoC:",
|
"SoC:",
|
||||||
@@ -88,7 +90,7 @@ static const char* ATTRIBUTE_FIELDS [] = {
|
|||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
"AVX:",
|
"AVX:",
|
||||||
"FMA:",
|
"FMA:",
|
||||||
#elif ARCH_ARM
|
#elif defined(ARCH_ARM) || defined(ARCH_PPC)
|
||||||
"Features: ",
|
"Features: ",
|
||||||
#endif
|
#endif
|
||||||
"L1i Size:",
|
"L1i Size:",
|
||||||
@@ -176,6 +178,12 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct colors* cs) {
|
|||||||
printBug("Invalid CPU vendor in set_ascii (%d)", art->vendor);
|
printBug("Invalid CPU vendor in set_ascii (%d)", art->vendor);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#elif ARCH_PPC
|
||||||
|
COL_FANCY_1 = COLOR_BG_CYAN;
|
||||||
|
COL_FANCY_2 = COLOR_BG_WHITE;
|
||||||
|
COL_FANCY_3 = COLOR_FG_CYAN;
|
||||||
|
COL_FANCY_4 = COLOR_FG_WHITE;
|
||||||
|
art->ascii_chars[0] = '#';
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
if(art->vendor == SOC_VENDOR_SNAPDRAGON) {
|
if(art->vendor == SOC_VENDOR_SNAPDRAGON) {
|
||||||
COL_FANCY_1 = COLOR_BG_RED;
|
COL_FANCY_1 = COLOR_BG_RED;
|
||||||
@@ -315,6 +323,8 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct colors* cs) {
|
|||||||
strcpy(tmp, AMD_ASCII);
|
strcpy(tmp, AMD_ASCII);
|
||||||
else
|
else
|
||||||
strcpy(tmp, UNKNOWN_ASCII);
|
strcpy(tmp, UNKNOWN_ASCII);
|
||||||
|
#elif ARCH_PPC
|
||||||
|
strcpy(tmp, UNKNOWN_ASCII);
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
if(art->vendor == SOC_VENDOR_SNAPDRAGON)
|
if(art->vendor == SOC_VENDOR_SNAPDRAGON)
|
||||||
strcpy(tmp, SNAPDRAGON_ASCII);
|
strcpy(tmp, SNAPDRAGON_ASCII);
|
||||||
@@ -507,6 +517,110 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARCH_PPC
|
||||||
|
void print_algorithm_ppc(struct ascii* art, int n) {
|
||||||
|
for(int i=0; i < LINE_SIZE; i++) {
|
||||||
|
if(art->art[n][i] == '@')
|
||||||
|
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
|
||||||
|
printf("%c",art->art[n][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_ascii_ppc(struct ascii* art, uint32_t la) {
|
||||||
|
int attr_to_print = 0;
|
||||||
|
int attr_type;
|
||||||
|
char* attr_value;
|
||||||
|
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;
|
||||||
|
bool flag = false;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
for(uint32_t n=0;n<NUMBER_OF_LINES;n++) {
|
||||||
|
print_algorithm_ppc(art, n);
|
||||||
|
|
||||||
|
if(n > space_up-1 && n < NUMBER_OF_LINES-space_down) {
|
||||||
|
attr_type = art->attributes[attr_to_print]->type;
|
||||||
|
attr_value = art->attributes[attr_to_print]->value;
|
||||||
|
attr_to_print++;
|
||||||
|
|
||||||
|
space_right = 1 + (la - strlen(ATTRIBUTE_FIELDS[attr_type]));
|
||||||
|
printf("%s%s%s%*s%s%s%s\n", art->color1_text, ATTRIBUTE_FIELDS[attr_type], art->reset, space_right, "", art->color2_text, attr_value, art->reset);
|
||||||
|
}
|
||||||
|
else printf("\n");
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_ascii(struct ascii* art) {
|
||||||
|
uint32_t longest_attribute = longest_attribute_length(art);
|
||||||
|
|
||||||
|
print_ascii_ppc(art, longest_attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool print_cpufetch_ppc(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
||||||
|
struct ascii* art = set_ascii(get_cpu_vendor(cpu), s, cs);
|
||||||
|
if(art == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/*char* uarch = get_str_uarch(cpu);
|
||||||
|
char* manufacturing_process = get_str_process(cpu);
|
||||||
|
char* sockets = get_str_sockets(cpu->topo);
|
||||||
|
char* max_frequency = get_str_freq(cpu->freq);
|
||||||
|
char* n_cores = get_str_topology(cpu, cpu->topo, false);
|
||||||
|
char* n_cores_dual = get_str_topology(cpu, cpu->topo, true);
|
||||||
|
*/
|
||||||
|
char* cpu_name = get_str_cpu_name(cpu);
|
||||||
|
|
||||||
|
/*
|
||||||
|
char* l1i = get_str_l1i(cpu->cach);
|
||||||
|
char* l1d = get_str_l1d(cpu->cach);
|
||||||
|
char* l2 = get_str_l2(cpu->cach);
|
||||||
|
char* l3 = get_str_l3(cpu->cach);
|
||||||
|
char* pp = get_str_peak_performance(cpu,cpu->topo,get_freq(cpu->freq));*/
|
||||||
|
|
||||||
|
setAttribute(art,ATTRIBUTE_NAME,cpu_name);
|
||||||
|
/*
|
||||||
|
if(cpu->hv->present) {
|
||||||
|
setAttribute(art, ATTRIBUTE_HYPERVISOR, cpu->hv->hv_name);
|
||||||
|
}
|
||||||
|
setAttribute(art,ATTRIBUTE_UARCH,uarch);
|
||||||
|
setAttribute(art,ATTRIBUTE_TECHNOLOGY,manufacturing_process);
|
||||||
|
setAttribute(art,ATTRIBUTE_FREQUENCY,max_frequency);
|
||||||
|
uint32_t socket_num = get_nsockets(cpu->topo);
|
||||||
|
if (socket_num > 1) {
|
||||||
|
setAttribute(art, ATTRIBUTE_SOCKETS, sockets);
|
||||||
|
setAttribute(art, ATTRIBUTE_NCORES,n_cores);
|
||||||
|
setAttribute(art, ATTRIBUTE_NCORES_DUAL, n_cores_dual);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setAttribute(art,ATTRIBUTE_NCORES,n_cores);
|
||||||
|
}
|
||||||
|
setAttribute(art,ATTRIBUTE_AVX,avx);
|
||||||
|
setAttribute(art,ATTRIBUTE_FMA,fma);
|
||||||
|
setAttribute(art,ATTRIBUTE_L1i,l1i);
|
||||||
|
setAttribute(art,ATTRIBUTE_L1d,l1d);
|
||||||
|
setAttribute(art,ATTRIBUTE_L2,l2);
|
||||||
|
if(l3 != NULL) {
|
||||||
|
setAttribute(art,ATTRIBUTE_L3,l3);
|
||||||
|
}
|
||||||
|
setAttribute(art,ATTRIBUTE_PEAK,pp);
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(art->n_attributes_set > NUMBER_OF_LINES) {
|
||||||
|
printBug("The number of attributes set is bigger than the max that can be displayed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
print_ascii(art);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ARCH_ARM
|
#ifdef ARCH_ARM
|
||||||
void print_algorithm_snapd_mtk(struct ascii* art, int n) {
|
void print_algorithm_snapd_mtk(struct ascii* art, int n) {
|
||||||
for(int i=0; i < LINE_SIZE; i++) {
|
for(int i=0; i < LINE_SIZE; i++) {
|
||||||
@@ -715,6 +829,8 @@ bool print_cpufetch(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
return print_cpufetch_x86(cpu, s, cs);
|
return print_cpufetch_x86(cpu, s, cs);
|
||||||
|
#elif ARCH_PPC
|
||||||
|
return print_cpufetch_ppc(cpu, s, cs);
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
return print_cpufetch_arm(cpu, s, cs);
|
return print_cpufetch_arm(cpu, s, cs);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
28
src/ppc/ppc.c
Normal file
28
src/ppc/ppc.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "ppc.h"
|
||||||
|
|
||||||
|
#define STRING_UNKNOWN "Unknown"
|
||||||
|
|
||||||
|
struct cpuInfo* get_cpu_info() {
|
||||||
|
struct cpuInfo* cpu = malloc(sizeof(struct cpuInfo));
|
||||||
|
struct features* feat = malloc(sizeof(struct features));
|
||||||
|
cpu->feat = feat;
|
||||||
|
|
||||||
|
bool *ptr = &(feat->AES);
|
||||||
|
for(uint32_t i = 0; i < sizeof(struct features)/sizeof(bool); i++, ptr++) {
|
||||||
|
*ptr = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cpu->cpu_name = malloc(sizeof(char) * strlen(STRING_UNKNOWN) + 1);
|
||||||
|
snprintf(cpu->cpu_name, strlen(STRING_UNKNOWN) + 1, STRING_UNKNOWN);
|
||||||
|
|
||||||
|
return cpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug(struct cpuInfo* cpu) {
|
||||||
|
printf("TODO\n");
|
||||||
|
}
|
||||||
9
src/ppc/ppc.h
Normal file
9
src/ppc/ppc.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef __POWERPC__
|
||||||
|
#define __POWERPC__
|
||||||
|
|
||||||
|
#include "../common/cpu.h"
|
||||||
|
|
||||||
|
struct cpuInfo* get_cpu_info();
|
||||||
|
void print_debug(struct cpuInfo* cpu);
|
||||||
|
|
||||||
|
#endif
|
||||||
7
src/ppc/uarch.c
Normal file
7
src/ppc/uarch.c
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
struct uarch {
|
||||||
|
int d;
|
||||||
|
};
|
||||||
|
|
||||||
|
void free_uarch_struct(struct uarch* arch) {
|
||||||
|
|
||||||
|
}
|
||||||
6
src/ppc/uarch.h
Normal file
6
src/ppc/uarch.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __UARCH__
|
||||||
|
#define __UARCH__
|
||||||
|
|
||||||
|
void free_uarch_struct(struct uarch* arch);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user