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,55 +15,54 @@ limitations under the License.
Original Author: Shay Gal-on
*/
#include "coremark.h"
#include "core_portme.h"
//Read cycle CSR
unsigned long long _read_cycle()
{
unsigned long long result;
unsigned long lower;
unsigned long upper1;
unsigned long upper2;
#include "coremark.h"
// Read cycle CSR
unsigned long long _read_cycle() {
unsigned long long result;
unsigned long lower;
unsigned long upper1;
unsigned long upper2;
asm volatile (
"repeat_cycle_%=: csrr %0, cycleh;\n"
" csrr %1, cycle;\n"
" csrr %2, cycleh;\n"
" bne %0, %2, repeat_cycle_%=;\n"
: "=r" (upper1),"=r" (lower),"=r" (upper2) // Outputs : temp variable for load result
:
:
);
*(unsigned long *)(&result) = lower;
*((unsigned long *)(&result)+1) = upper1;
asm volatile("repeat_cycle_%=: csrr %0, cycleh;\n"
" csrr %1, cycle;\n"
" csrr %2, cycleh;\n"
" bne %0, %2, repeat_cycle_%=;\n"
: "=r"(upper1), "=r"(lower),
"=r"(upper2) // Outputs : temp variable for load result
:
:);
*(unsigned long *)(&result) = lower;
*((unsigned long *)(&result) + 1) = upper1;
return result;
return result;
}
volatile int tohost;
volatile int fromhost;
extern volatile int tohost;
extern volatile int fromhost;
void exit(int n){
tohost = 0x1;
for (;;);
void exit(int n) {
tohost = 0x1;
for (;;)
;
}
void __libc_init_array (void) {
/*
size_t count;
size_t i;
count = __preinit_array_end - __preinit_array_start;
for (i = 0; i < count; i++)
__preinit_array_start[i] ();
void __libc_init_array(void) {
/*
size_t count;
size_t i;
count = __preinit_array_end - __preinit_array_start;
for (i = 0; i < count; i++)
__preinit_array_start[i] ();
#ifdef HAVE_INIT_FINI
_init ();
#endif
#ifdef HAVE_INIT_FINI
_init ();
#endif
count = __init_array_end - __init_array_start;
for (i = 0; i < count; i++)
__init_array_start[i] ();
*/
count = __init_array_end - __init_array_start;
for (i = 0; i < count; i++)
__init_array_start[i] ();
*/
}
#if VALIDATION_RUN
volatile ee_s32 seed1_volatile = 0x3415;
@ -89,10 +88,7 @@ volatile ee_s32 seed5_volatile = 0;
time.h and windows.h definitions included.
*/
CORETIMETYPE
barebones_clock()
{
return (CORETIMETYPE)_read_cycle();
}
barebones_clock() { return (CORETIMETYPE)_read_cycle(); }
/* Define : TIMER_RES_DIVIDER
Divider to trade off timer resolution and total time that can be
measured.
@ -101,11 +97,11 @@ barebones_clock()
does not occur. If there are issues with the return value overflowing,
increase this value.
*/
#define GETMYTIME(_t) (*_t = barebones_clock())
#define MYTIMEDIFF(fin, ini) ((fin) - (ini))
#define TIMER_RES_DIVIDER 1
#define GETMYTIME(_t) (*_t = barebones_clock())
#define MYTIMEDIFF(fin, ini) ((fin) - (ini))
#define TIMER_RES_DIVIDER 1
#define SAMPLE_TIME_IMPLEMENTATION 1
#define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
#define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
/** Define Host specific (POSIX), or target specific global time variables. */
static CORETIMETYPE start_time_val, stop_time_val;
@ -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
cycles to 0.
*/
void
start_time(void)
{
GETMYTIME(&start_time_val);
}
void start_time(void) { GETMYTIME(&start_time_val); }
/* Function : stop_time
This function will be called right after ending the timed portion of the
benchmark.
@ -131,11 +123,7 @@ start_time(void)
example code) or other system parameters - e.g. reading the current value of
cpu cycles counter.
*/
void
stop_time(void)
{
GETMYTIME(&stop_time_val);
}
void stop_time(void) { GETMYTIME(&stop_time_val); }
/* Function : get_time
Return an abstract "ticks" number that signifies time on the system.
@ -146,11 +134,9 @@ stop_time(void)
controlled by <TIMER_RES_DIVIDER>
*/
CORE_TICKS
get_time(void)
{
CORE_TICKS elapsed
= (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
return elapsed;
get_time(void) {
CORE_TICKS elapsed = (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
return elapsed;
}
/* Function : time_in_secs
Convert the value returned by get_time to seconds.
@ -159,11 +145,9 @@ get_time(void)
floating point. Default implementation implemented by the EE_TICKS_PER_SEC
macro above.
*/
secs_ret
time_in_secs(CORE_TICKS ticks)
{
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
return retval;
secs_ret time_in_secs(CORE_TICKS ticks) {
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
return retval;
}
ee_u32 default_num_contexts = 1;
@ -172,27 +156,18 @@ ee_u32 default_num_contexts = 1;
Target specific initialization code
Test for some common mistakes.
*/
void
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 "
"pointer!\n");
}
if (sizeof(ee_u32) != 4)
{
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
}
p->portable_id = 1;
ee_printf("portable_init finished.\n");
void 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 "
"pointer!\n");
}
if (sizeof(ee_u32) != 4) {
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
}
p->portable_id = 1;
ee_printf("portable_init finished.\n");
}
/* Function : portable_fini
Target specific final code
*/
void
portable_fini(core_portable *p)
{
p->portable_id = 0;
}
void portable_fini(core_portable *p) { p->portable_id = 0; }