/* Support */
|
/* Support */
|
|
|
#include <sys/time.h>
|
#include <sys/time.h>
|
#include "spr_defs.h"
|
#include "spr_defs.h"
|
#include "support.h"
|
#include "support.h"
|
#include "int.h"
|
#include "int.h"
|
|
|
#if OR1K
|
#if OR1K
|
void excpt_dummy();
|
void excpt_dummy();
|
void int_main();
|
void int_main();
|
|
|
unsigned long excpt_buserr = (unsigned long) excpt_dummy;
|
unsigned long excpt_buserr = (unsigned long) excpt_dummy;
|
unsigned long excpt_dpfault = (unsigned long) excpt_dummy;
|
unsigned long excpt_dpfault = (unsigned long) excpt_dummy;
|
unsigned long excpt_ipfault = (unsigned long) excpt_dummy;
|
unsigned long excpt_ipfault = (unsigned long) excpt_dummy;
|
unsigned long excpt_lpint = (unsigned long) int_main;
|
unsigned long excpt_lpint = (unsigned long) int_main;
|
unsigned long excpt_align = (unsigned long) excpt_dummy;
|
unsigned long excpt_align = (unsigned long) excpt_dummy;
|
unsigned long excpt_illinsn = (unsigned long) excpt_dummy;
|
unsigned long excpt_illinsn = (unsigned long) excpt_dummy;
|
unsigned long excpt_hpint = (unsigned long) excpt_dummy;
|
unsigned long excpt_hpint = (unsigned long) excpt_dummy;
|
unsigned long excpt_dtlbmiss = (unsigned long) excpt_dummy;
|
unsigned long excpt_dtlbmiss = (unsigned long) excpt_dummy;
|
unsigned long excpt_itlbmiss = (unsigned long) excpt_dummy;
|
unsigned long excpt_itlbmiss = (unsigned long) excpt_dummy;
|
unsigned long excpt_range = (unsigned long) excpt_dummy;
|
unsigned long excpt_range = (unsigned long) excpt_dummy;
|
unsigned long excpt_syscall = (unsigned long) excpt_dummy;
|
unsigned long excpt_syscall = (unsigned long) excpt_dummy;
|
unsigned long excpt_break = (unsigned long) excpt_dummy;
|
unsigned long excpt_break = (unsigned long) excpt_dummy;
|
unsigned long excpt_trap = (unsigned long) excpt_dummy;
|
unsigned long excpt_trap = (unsigned long) excpt_dummy;
|
|
|
|
|
/* Start function, called by reset exception handler. */
|
/* Start function, called by reset exception handler. */
|
void reset ()
|
void reset ()
|
{
|
{
|
int i = main();
|
int i = main();
|
exit (i);
|
exit (i);
|
}
|
}
|
|
|
/* return value by making a syscall */
|
/* return value by making a syscall */
|
void exit (int i)
|
void exit (int i)
|
{
|
{
|
asm("l.add r3,r0,%0": : "r" (i));
|
asm("l.add r3,r0,%0": : "r" (i));
|
asm("l.nop %0": :"K" (NOP_EXIT));
|
asm("l.nop %0": :"K" (NOP_EXIT));
|
while (1);
|
while (1);
|
}
|
}
|
|
|
/* activate printf support in simulator */
|
/* activate printf support in simulator */
|
void printf(const char *fmt, ...)
|
void printf(const char *fmt, ...)
|
{
|
{
|
va_list args;
|
va_list args;
|
va_start(args, fmt);
|
va_start(args, fmt);
|
asm("l.addi\tr3,%0,0": :"r" (fmt));
|
__asm__ __volatile__ ("l.nop %0": :"K" (NOP_PRINTF), "r" (fmt), "r" (args));
|
asm("l.addi\tr4,%0,0": :"r" (args));
|
|
asm("l.nop %0": :"K" (NOP_PRINTF));
|
|
}
|
}
|
|
|
/* print long */
|
/* print long */
|
void report(unsigned long value)
|
void report(unsigned long value)
|
{
|
{
|
asm("l.addi\tr3,%0,0": :"r" (value));
|
asm("l.addi\tr3,%0,0": :"r" (value));
|
asm("l.nop %0": :"K" (NOP_REPORT));
|
asm("l.nop %0": :"K" (NOP_REPORT));
|
}
|
}
|
|
|
/* just to satisfy linker */
|
/* just to satisfy linker */
|
void __main()
|
void __main()
|
{
|
{
|
}
|
}
|
|
|
/* start_TIMER */
|
/* start_TIMER */
|
void start_timer(int x)
|
void start_timer(int x)
|
{
|
{
|
}
|
}
|
|
|
/* read_TIMER */
|
/* read_TIMER */
|
/* Returns a value since started in uS */
|
/* Returns a value since started in uS */
|
unsigned int read_timer(int x)
|
unsigned int read_timer(int x)
|
{
|
{
|
unsigned long count = 0;
|
unsigned long count = 0;
|
|
|
/* Read the Time Stamp Counter */
|
/* Read the Time Stamp Counter */
|
/* asm("simrdtsc %0" :"=r" (count)); */
|
/* asm("simrdtsc %0" :"=r" (count)); */
|
/*asm("l.sys 201"); */
|
/*asm("l.sys 201"); */
|
return count;
|
return count;
|
}
|
}
|
|
|
/* For writing into SPR. */
|
/* For writing into SPR. */
|
void mtspr(unsigned long spr, unsigned long value)
|
void mtspr(unsigned long spr, unsigned long value)
|
{
|
{
|
asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
|
asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
|
}
|
}
|
|
|
/* For reading SPR. */
|
/* For reading SPR. */
|
unsigned long mfspr(unsigned long spr)
|
unsigned long mfspr(unsigned long spr)
|
{
|
{
|
unsigned long value;
|
unsigned long value;
|
asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
|
asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
|
return value;
|
return value;
|
}
|
}
|
|
|
#else
|
#else
|
void report(unsigned long value)
|
void report(unsigned long value)
|
{
|
{
|
unsigned long spr = 0x1234;
|
unsigned long spr = 0x1234;
|
printf("l.mtspr 0x%x, 0x%x\n", (unsigned) spr, (unsigned) value);
|
printf("l.mtspr 0x%x, 0x%x\n", (unsigned) spr, (unsigned) value);
|
}
|
}
|
|
|
/* start_TIMER */
|
/* start_TIMER */
|
void start_timer(int tmrnum)
|
void start_timer(int tmrnum)
|
{
|
{
|
}
|
}
|
|
|
/* read_TIMER */
|
/* read_TIMER */
|
/* Returns a value since started in uS */
|
/* Returns a value since started in uS */
|
unsigned int read_timer(int tmrnum)
|
unsigned int read_timer(int tmrnum)
|
{
|
{
|
struct timeval tv;
|
struct timeval tv;
|
struct timezone tz;
|
struct timezone tz;
|
|
|
gettimeofday(&tv, &tz);
|
gettimeofday(&tv, &tz);
|
|
|
return(tv.tv_sec*1000000+tv.tv_usec);
|
return(tv.tv_sec*1000000+tv.tv_usec);
|
}
|
}
|
|
|
#endif
|
#endif
|
|
|
void *memcpy (void *__restrict dstvoid,
|
void *memcpy (void *__restrict dstvoid,
|
__const void *__restrict srcvoid, size_t length)
|
__const void *__restrict srcvoid, size_t length)
|
{
|
{
|
char *dst = dstvoid;
|
char *dst = dstvoid;
|
const char *src = (const char *) srcvoid;
|
const char *src = (const char *) srcvoid;
|
|
|
while (length--)
|
while (length--)
|
*dst++ = *src++;
|
*dst++ = *src++;
|
return dst;
|
return dst;
|
}
|
}
|
|
|
void excpt_dummy() {}
|
void excpt_dummy() {}
|
|
|