From 30a2493ad9f1df0c9d2013ca818fb11641c89715 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Mon, 3 Apr 2023 14:08:58 +0200 Subject: [PATCH] [v1.03][RISCV] Add basic StarFive support --- src/common/ascii.h | 28 +++++++++++++++++++++++++++- src/common/printer.c | 2 ++ src/riscv/soc.c | 14 +++++++++++++- src/riscv/soc.h | 3 ++- src/riscv/socs.h | 3 +++ 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/common/ascii.h b/src/common/ascii.h index 7c1b17e..66aebc3 100644 --- a/src/common/ascii.h +++ b/src/common/ascii.h @@ -287,6 +287,31 @@ $C1 ###### ###### \ $C1 ########### \ $C1 ### " +#define ASCII_STARFIVE \ +"$C1 ####### \ +$C1 ################. \ +$C1 ############ ########### \ +$C1 ############ ##########. \ +$C1 ############ # ###### \ +$C1 ########### ##### ## \ +$C1 #######. ########## \ +$C1 ###### ### *########### \ +$C1 ###### #######. ########## \ +$C1 ######### ############ ###### \ +$C1 ###########. ###########* # \ +$C1 ############ ############ \ +$C1 # ############. .########### \ +$C1 ###### ########### ######### \ +$C1 ########## .######, ##### \ +$C1 ############ ##. #####. \ +$C1 ######### ######## \ +$C1 ## ##### ##########. \ +$C1 ####### # ############ \ +$C1 ########### ###########. \ +$C1 ###########. ############ \ +$C1 ################ \ +$C1 ####### " + // --------------------- LONG LOGOS ------------------------- // #define ASCII_AMD_L \ "$C1 \ @@ -390,7 +415,8 @@ asciiL logo_apple = { ASCII_APPLE, 32, 17, false, {C_FG_WHITE}, asciiL logo_allwinner = { ASCII_ALLWINNER, 47, 16, false, {C_FG_CYAN}, {C_FG_B_BLACK, C_FG_B_CYAN } }; asciiL logo_rockchip = { ASCII_ROCKCHIP, 58, 8, false, {C_FG_CYAN, C_FG_YELLOW}, {C_FG_CYAN, C_FG_YELLOW} }; asciiL logo_riscv = { ASCII_RISCV, 63, 18, false, {C_FG_CYAN, C_FG_YELLOW}, {C_FG_CYAN, C_FG_YELLOW} }; -asciiL logo_sifive = { ASCII_SIFIVE, 51, 19, false, {C_FG_WHITE}, {C_FG_WHITE, C_FG_B_CYAN} }; +asciiL logo_sifive = { ASCII_SIFIVE, 51, 19, false, {C_FG_WHITE}, {C_FG_WHITE, C_FG_CYAN} }; +asciiL logo_starfive = { ASCII_STARFIVE, 50, 24, false, {C_FG_WHITE}, {C_FG_WHITE, C_FG_BLUE} }; // Long variants | ----------------------------------------------------------------------------------------------------| asciiL logo_amd_l = { ASCII_AMD_L, 62, 19, true, {C_BG_WHITE, C_BG_GREEN}, {C_FG_WHITE, C_FG_GREEN} }; diff --git a/src/common/printer.c b/src/common/printer.c index 82b7f66..e9a1d96 100644 --- a/src/common/printer.c +++ b/src/common/printer.c @@ -371,6 +371,8 @@ void choose_ascii_art(struct ascii* art, struct color** cs, struct terminal* ter #elif ARCH_RISCV if(art->vendor == SOC_VENDOR_SIFIVE) art->art = &logo_sifive; + else if(art->vendor == SOC_VENDOR_STARFIVE) + art->art = &logo_starfive; else art->art = &logo_riscv; #endif diff --git a/src/riscv/soc.c b/src/riscv/soc.c index 1e23ef0..469e2fd 100644 --- a/src/riscv/soc.c +++ b/src/riscv/soc.c @@ -31,7 +31,8 @@ char* get_soc_name(struct system_on_chip* soc) { } static char* soc_trademark_string[] = { - [SOC_VENDOR_SIFIVE] = "SiFive " + [SOC_VENDOR_SIFIVE] = "SiFive ", + [SOC_VENDOR_STARFIVE] = "StarFive " }; void fill_soc(struct system_on_chip* soc, char* soc_name, SOC soc_model, int32_t process) { @@ -77,8 +78,19 @@ bool match_sifive(char* soc_name, struct system_on_chip* soc) { SOC_END } +bool match_starfive(char* soc_name, struct system_on_chip* soc) { + SOC_START + SOC_EQ(soc_name, "jh7110#", "VisionFive 2", SOC_STARFIVE_VF2, soc, 28) // https://blog.bitsofnetworks.org/benchmarking-risc-v-visionfive-2-vs-the-world.html + SOC_EQ(soc_name, "jh7110", "VisionFive 2", SOC_STARFIVE_VF2, soc, 28) + SOC_END +} + struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) { char* raw_name = soc->raw_name; + + if(match_starfive(raw_name, soc)) + return soc; + match_sifive(raw_name, soc); return soc; } diff --git a/src/riscv/soc.h b/src/riscv/soc.h index 368c3b9..007d370 100644 --- a/src/riscv/soc.h +++ b/src/riscv/soc.h @@ -8,7 +8,8 @@ typedef int32_t SOC; enum { SOC_VENDOR_UNKNOWN, - SOC_VENDOR_SIFIVE + SOC_VENDOR_SIFIVE, + SOC_VENDOR_STARFIVE }; struct system_on_chip { diff --git a/src/riscv/socs.h b/src/riscv/socs.h index cf587f6..56cff72 100644 --- a/src/riscv/socs.h +++ b/src/riscv/socs.h @@ -7,12 +7,15 @@ enum { // SIFIVE SOC_SIFIVE_U740, + // STARFIVE + SOC_STARFIVE_VF2, // UNKNOWN SOC_MODEL_UNKNOWN }; inline static VENDOR get_soc_vendor_from_soc(SOC soc) { if(soc >= SOC_SIFIVE_U740 && soc <= SOC_SIFIVE_U740) return SOC_VENDOR_SIFIVE; + if(soc >= SOC_STARFIVE_VF2 && soc <= SOC_STARFIVE_VF2) return SOC_VENDOR_STARFIVE; return SOC_VENDOR_UNKNOWN; }