mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-24 23:40:39 +01:00
[v1.03][RISCV] Add support for compiling to RISC-V
This commit is contained in:
5
Makefile
5
Makefile
@@ -41,6 +41,11 @@ ifneq ($(OS),Windows_NT)
|
|||||||
SOURCE += $(SRC_DIR)sysctl.c
|
SOURCE += $(SRC_DIR)sysctl.c
|
||||||
HEADERS += $(SRC_DIR)sysctl.h
|
HEADERS += $(SRC_DIR)sysctl.h
|
||||||
endif
|
endif
|
||||||
|
else ifeq ($(arch), $(filter $(arch), riscv64 riscv32))
|
||||||
|
SRC_DIR=src/riscv/
|
||||||
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)riscv.c $(SRC_DIR)uarch.c
|
||||||
|
HEADERS += $(COMMON_SRC) $(SRC_DIR)riscv.h $(SRC_DIR)uarch.h
|
||||||
|
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
|
||||||
$(warning Unsupported arch detected: $(arch). See https://github.com/Dr-Noob/cpufetch#1-support)
|
$(warning Unsupported arch detected: $(arch). See https://github.com/Dr-Noob/cpufetch#1-support)
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include "../ppc/uarch.h"
|
#include "../ppc/uarch.h"
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
#include "../arm/uarch.h"
|
#include "../arm/uarch.h"
|
||||||
|
#elif ARCH_RISCV
|
||||||
|
#include "../riscv/uarch.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STRING_YES "Yes"
|
#define STRING_YES "Yes"
|
||||||
|
|||||||
@@ -29,6 +29,9 @@
|
|||||||
#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"
|
||||||
|
#elif ARCH_RISCV
|
||||||
|
static const char* ARCH_STR = "RISC-V build";
|
||||||
|
#include "../riscv/riscv.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|||||||
@@ -16,10 +16,12 @@
|
|||||||
#elif ARCH_PPC
|
#elif ARCH_PPC
|
||||||
#include "../ppc/uarch.h"
|
#include "../ppc/uarch.h"
|
||||||
#include "../ppc/ppc.h"
|
#include "../ppc/ppc.h"
|
||||||
#else
|
#elif ARCH_ARM
|
||||||
#include "../arm/uarch.h"
|
#include "../arm/uarch.h"
|
||||||
#include "../arm/midr.h"
|
#include "../arm/midr.h"
|
||||||
#include "../arm/soc.h"
|
#include "../arm/soc.h"
|
||||||
|
#elif ARCH_RISCV
|
||||||
|
#include "../riscv/riscv.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -911,6 +913,13 @@ bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct color** cs, struct
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARCH_RISCV
|
||||||
|
bool print_cpufetch_riscv(struct cpuInfo* cpu, STYLE s, struct color** cs, struct terminal* term) {
|
||||||
|
printf("Unimplemented\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct terminal* get_terminal_size(void) {
|
struct terminal* get_terminal_size(void) {
|
||||||
struct terminal* term = emalloc(sizeof(struct terminal));
|
struct terminal* term = emalloc(sizeof(struct terminal));
|
||||||
|
|
||||||
@@ -948,5 +957,7 @@ bool print_cpufetch(struct cpuInfo* cpu, STYLE s, struct color** cs, bool show_f
|
|||||||
return print_cpufetch_ppc(cpu, s, cs, term, show_full_cpu_name);
|
return print_cpufetch_ppc(cpu, s, cs, term, show_full_cpu_name);
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
return print_cpufetch_arm(cpu, s, cs, term);
|
return print_cpufetch_arm(cpu, s, cs, term);
|
||||||
|
#elif ARCH_RISCV
|
||||||
|
return print_cpufetch_riscv(cpu, s, cs, term);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ typedef int STYLE;
|
|||||||
#include "../ppc/ppc.h"
|
#include "../ppc/ppc.h"
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
#include "../arm/midr.h"
|
#include "../arm/midr.h"
|
||||||
|
#elif ARCH_RISCV
|
||||||
|
#include "../riscv/riscv.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// +-----------------------------------+-----------------------+
|
// +-----------------------------------+-----------------------+
|
||||||
|
|||||||
12
src/riscv/riscv.c
Normal file
12
src/riscv/riscv.c
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
struct cpuInfo* get_cpu_info(void) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug(struct cpuInfo* cpu) {
|
||||||
|
printf("Unimplemented!\n");
|
||||||
|
}
|
||||||
9
src/riscv/riscv.h
Normal file
9
src/riscv/riscv.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef __RISCV__
|
||||||
|
#define __RISCV__
|
||||||
|
|
||||||
|
#include "../common/cpu.h"
|
||||||
|
|
||||||
|
struct cpuInfo* get_cpu_info(void);
|
||||||
|
void print_debug(struct cpuInfo* cpu);
|
||||||
|
|
||||||
|
#endif
|
||||||
11
src/riscv/uarch.c
Normal file
11
src/riscv/uarch.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct uarch {
|
||||||
|
//MICROARCH uarch;
|
||||||
|
char* uarch_str;
|
||||||
|
int32_t process; // measured in nanometers
|
||||||
|
};
|
||||||
|
|
||||||
|
void free_uarch_struct(struct uarch* arch) {
|
||||||
|
|
||||||
|
}
|
||||||
11
src/riscv/uarch.h
Normal file
11
src/riscv/uarch.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef __UARCH__
|
||||||
|
#define __UARCH__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "riscv.h"
|
||||||
|
|
||||||
|
struct uarch;
|
||||||
|
|
||||||
|
void free_uarch_struct(struct uarch* arch);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user