adds extern to tohost/fromhost to avoid error during BSS initialization

This commit is contained in:
Hongyu Liu 2025-03-14 14:20:53 +01:00
parent 884d445cb9
commit 686d01ab3e

View File

@ -15,37 +15,36 @@ limitations under the License.
Original Author: Shay Gal-on Original Author: Shay Gal-on
*/ */
#include "coremark.h"
#include "core_portme.h" #include "core_portme.h"
#include "coremark.h"
// Read cycle CSR // Read cycle CSR
unsigned long long _read_cycle() unsigned long long _read_cycle() {
{
unsigned long long result; unsigned long long result;
unsigned long lower; unsigned long lower;
unsigned long upper1; unsigned long upper1;
unsigned long upper2; unsigned long upper2;
asm volatile ( asm volatile("repeat_cycle_%=: csrr %0, cycleh;\n"
"repeat_cycle_%=: csrr %0, cycleh;\n"
" csrr %1, cycle;\n" " csrr %1, cycle;\n"
" csrr %2, cycleh;\n" " csrr %2, cycleh;\n"
" bne %0, %2, repeat_cycle_%=;\n" " bne %0, %2, repeat_cycle_%=;\n"
: "=r" (upper1),"=r" (lower),"=r" (upper2) // Outputs : temp variable for load result : "=r"(upper1), "=r"(lower),
"=r"(upper2) // Outputs : temp variable for load result
: :
: :);
);
*(unsigned long *)(&result) = lower; *(unsigned long *)(&result) = lower;
*((unsigned long *)(&result) + 1) = upper1; *((unsigned long *)(&result) + 1) = upper1;
return result; return result;
} }
volatile int tohost; extern volatile int tohost;
volatile int fromhost; extern volatile int fromhost;
void exit(int n) { void exit(int n) {
tohost = 0x1; tohost = 0x1;
for (;;); for (;;)
;
} }
void __libc_init_array(void) { void __libc_init_array(void) {
@ -89,10 +88,7 @@ volatile ee_s32 seed5_volatile = 0;
time.h and windows.h definitions included. time.h and windows.h definitions included.
*/ */
CORETIMETYPE CORETIMETYPE
barebones_clock() barebones_clock() { return (CORETIMETYPE)_read_cycle(); }
{
return (CORETIMETYPE)_read_cycle();
}
/* Define : TIMER_RES_DIVIDER /* Define : TIMER_RES_DIVIDER
Divider to trade off timer resolution and total time that can be Divider to trade off timer resolution and total time that can be
measured. measured.
@ -118,11 +114,7 @@ static CORETIMETYPE start_time_val, stop_time_val;
example code) or zeroing some system parameters - e.g. setting the cpu clocks example code) or zeroing some system parameters - e.g. setting the cpu clocks
cycles to 0. cycles to 0.
*/ */
void void start_time(void) { GETMYTIME(&start_time_val); }
start_time(void)
{
GETMYTIME(&start_time_val);
}
/* Function : stop_time /* Function : stop_time
This function will be called right after ending the timed portion of the This function will be called right after ending the timed portion of the
benchmark. benchmark.
@ -131,11 +123,7 @@ start_time(void)
example code) or other system parameters - e.g. reading the current value of example code) or other system parameters - e.g. reading the current value of
cpu cycles counter. cpu cycles counter.
*/ */
void void stop_time(void) { GETMYTIME(&stop_time_val); }
stop_time(void)
{
GETMYTIME(&stop_time_val);
}
/* Function : get_time /* Function : get_time
Return an abstract "ticks" number that signifies time on the system. Return an abstract "ticks" number that signifies time on the system.
@ -146,10 +134,8 @@ stop_time(void)
controlled by <TIMER_RES_DIVIDER> controlled by <TIMER_RES_DIVIDER>
*/ */
CORE_TICKS CORE_TICKS
get_time(void) get_time(void) {
{ CORE_TICKS elapsed = (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
CORE_TICKS elapsed
= (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
return elapsed; return elapsed;
} }
/* Function : time_in_secs /* Function : time_in_secs
@ -159,9 +145,7 @@ get_time(void)
floating point. Default implementation implemented by the EE_TICKS_PER_SEC floating point. Default implementation implemented by the EE_TICKS_PER_SEC
macro above. macro above.
*/ */
secs_ret secs_ret time_in_secs(CORE_TICKS ticks) {
time_in_secs(CORE_TICKS ticks)
{
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC; secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
return retval; return retval;
} }
@ -172,17 +156,12 @@ ee_u32 default_num_contexts = 1;
Target specific initialization code Target specific initialization code
Test for some common mistakes. Test for some common mistakes.
*/ */
void void portable_init(core_portable *p, int *argc, char *argv[]) {
portable_init(core_portable *p, int *argc, char *argv[]) if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
{ ee_printf("ERROR! Please define ee_ptr_int to a type that holds a "
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *))
{
ee_printf(
"ERROR! Please define ee_ptr_int to a type that holds a "
"pointer!\n"); "pointer!\n");
} }
if (sizeof(ee_u32) != 4) if (sizeof(ee_u32) != 4) {
{
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n"); ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
} }
p->portable_id = 1; p->portable_id = 1;
@ -191,8 +170,4 @@ portable_init(core_portable *p, int *argc, char *argv[])
/* Function : portable_fini /* Function : portable_fini
Target specific final code Target specific final code
*/ */
void void portable_fini(core_portable *p) { p->portable_id = 0; }
portable_fini(core_portable *p)
{
p->portable_id = 0;
}