mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-24 23:40:39 +01:00
[v1.03][RISCV] Fix bug in Makefile and implement --debug option
This commit is contained in:
2
Makefile
2
Makefile
@@ -44,7 +44,7 @@ ifneq ($(OS),Windows_NT)
|
|||||||
else ifeq ($(arch), $(filter $(arch), riscv64 riscv32))
|
else ifeq ($(arch), $(filter $(arch), riscv64 riscv32))
|
||||||
SRC_DIR=src/riscv/
|
SRC_DIR=src/riscv/
|
||||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)riscv.c $(SRC_DIR)uarch.c $(SRC_DIR)soc.c $(SRC_DIR)udev.c
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)riscv.c $(SRC_DIR)uarch.c $(SRC_DIR)soc.c $(SRC_DIR)udev.c
|
||||||
HEADERS += $(COMMON_SRC) $(SRC_DIR)riscv.h $(SRC_DIR)uarch.h $(SRC_DIR)soc.h $(SRC_DIR)udev.h $(SRC_DIR)socs.h
|
HEADERS += $(COMMON_HDR) $(SRC_DIR)riscv.h $(SRC_DIR)uarch.h $(SRC_DIR)soc.h $(SRC_DIR)udev.h $(SRC_DIR)socs.h
|
||||||
CFLAGS += -DARCH_RISCV -Wno-unused-parameter -std=c99 -fstack-protector-all
|
CFLAGS += -DARCH_RISCV -Wno-unused-parameter -std=c99 -fstack-protector-all
|
||||||
else
|
else
|
||||||
# Error lines should not be tabulated because Makefile complains about it
|
# Error lines should not be tabulated because Makefile complains about it
|
||||||
|
|||||||
@@ -101,5 +101,20 @@ char* get_str_extensions(struct cpuInfo* cpu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void print_debug(struct cpuInfo* cpu) {
|
void print_debug(struct cpuInfo* cpu) {
|
||||||
printf("Unimplemented!\n");
|
printf("- soc: ");
|
||||||
|
if(cpu->soc->raw_name == NULL) {
|
||||||
|
printf("NULL\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("'%s'\n", cpu->soc->raw_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("- uarch: ");
|
||||||
|
char* arch_cpuinfo_str = get_arch_cpuinfo_str(cpu);
|
||||||
|
if(arch_cpuinfo_str == NULL) {
|
||||||
|
printf("NULL\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("'%s'\n", arch_cpuinfo_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ typedef uint32_t MICROARCH;
|
|||||||
struct uarch {
|
struct uarch {
|
||||||
MICROARCH uarch;
|
MICROARCH uarch;
|
||||||
char* uarch_str;
|
char* uarch_str;
|
||||||
|
char* cpuinfo_str;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -40,6 +41,7 @@ void fill_uarch(struct uarch* arch, struct cpuInfo* cpu, char* str, MICROARCH u,
|
|||||||
// T-Head: https://www.t-head.cn/product/c906
|
// T-Head: https://www.t-head.cn/product/c906
|
||||||
struct uarch* get_uarch_from_cpuinfo_str(char* cpuinfo_str, struct cpuInfo* cpu) {
|
struct uarch* get_uarch_from_cpuinfo_str(char* cpuinfo_str, struct cpuInfo* cpu) {
|
||||||
struct uarch* arch = emalloc(sizeof(struct uarch));
|
struct uarch* arch = emalloc(sizeof(struct uarch));
|
||||||
|
arch->cpuinfo_str = cpuinfo_str;
|
||||||
if(cpuinfo_str == NULL) {
|
if(cpuinfo_str == NULL) {
|
||||||
printWarn("get_uarch_from_cpuinfo: Unable to detect microarchitecture, cpuinfo_str is NULL");
|
printWarn("get_uarch_from_cpuinfo: Unable to detect microarchitecture, cpuinfo_str is NULL");
|
||||||
fill_uarch(arch, cpu, "Unknown", UARCH_UNKNOWN, CPU_VENDOR_UNKNOWN);
|
fill_uarch(arch, cpu, "Unknown", UARCH_UNKNOWN, CPU_VENDOR_UNKNOWN);
|
||||||
@@ -72,6 +74,10 @@ char* get_str_uarch(struct cpuInfo* cpu) {
|
|||||||
return cpu->arch->uarch_str;
|
return cpu->arch->uarch_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* get_arch_cpuinfo_str(struct cpuInfo* cpu) {
|
||||||
|
return cpu->arch->cpuinfo_str;
|
||||||
|
}
|
||||||
|
|
||||||
void free_uarch_struct(struct uarch* arch) {
|
void free_uarch_struct(struct uarch* arch) {
|
||||||
free(arch->uarch_str);
|
free(arch->uarch_str);
|
||||||
free(arch);
|
free(arch);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
struct uarch;
|
struct uarch;
|
||||||
|
|
||||||
|
char* get_arch_cpuinfo_str(struct cpuInfo* cpu);
|
||||||
char* get_str_uarch(struct cpuInfo* cpu);
|
char* get_str_uarch(struct cpuInfo* cpu);
|
||||||
void free_uarch_struct(struct uarch* arch);
|
void free_uarch_struct(struct uarch* arch);
|
||||||
struct uarch* get_uarch_from_cpuinfo_str(char* cpuinfo_str, struct cpuInfo* cpu);
|
struct uarch* get_uarch_from_cpuinfo_str(char* cpuinfo_str, struct cpuInfo* cpu);
|
||||||
|
|||||||
Reference in New Issue
Block a user