From 8b3dc54e5cf28037922720e9b60d183fce23fced Mon Sep 17 00:00:00 2001 From: Hongyu Liu Date: Tue, 15 Apr 2025 12:32:09 +0200 Subject: [PATCH] uses write_hex() in exit instead of tohost=0x1 --- benchmarks/coremark/core_portme.c | 10 +++++++--- benchmarks/dhrystone/dhry_stubs.c | 21 +++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/benchmarks/coremark/core_portme.c b/benchmarks/coremark/core_portme.c index 7f1119e..41a7714 100644 --- a/benchmarks/coremark/core_portme.c +++ b/benchmarks/coremark/core_portme.c @@ -17,6 +17,7 @@ Original Author: Shay Gal-on */ #include "core_portme.h" #include "coremark.h" +#include // Read cycle CSR unsigned long long _read_cycle() { unsigned long long result; @@ -38,11 +39,14 @@ unsigned long long _read_cycle() { return result; } -extern volatile int tohost; -extern volatile int fromhost; +// extern volatile int tohost; +// extern volatile int fromhost; + +void write_hex(int fd, uint32_t hex); void exit(int n) { - tohost = 0x1; + write_hex(STDERR_FILENO, 1); + // tohost = 0x1; for (;;) ; } diff --git a/benchmarks/dhrystone/dhry_stubs.c b/benchmarks/dhrystone/dhry_stubs.c index a3e7b7c..3a327e2 100644 --- a/benchmarks/dhrystone/dhry_stubs.c +++ b/benchmarks/dhrystone/dhry_stubs.c @@ -1,4 +1,5 @@ #include "platform.h" +#include #ifndef ITERATIONS #define ITERATIONS 20000 #endif @@ -6,20 +7,16 @@ /* The functions in this file are only meant to support Dhrystone on an * embedded RV32 system and are obviously incorrect in general. */ -long time(void) -{ - return get_timer_value(); -} +long time(void) { return get_timer_value(); } // set the number of dhrystone iterations -void __wrap_scanf(const char* fmt, int* n) -{ - *n = ITERATIONS; -} +void __wrap_scanf(const char *fmt, int *n) { *n = ITERATIONS; } -extern volatile uint32_t tohost; +// extern volatile uint64_t tohost; -void exit(int n){ - tohost = 0x1; - for (;;); +void exit(int n) { + // tohost = 0x1; + write_hex(STDERR_FILENO, 1); + for (;;) + ; }