OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_58/] [or1ksim/] [testbench/] [support/] [support.c] - Blame information for rev 342

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 226 markom
/* Support */
2
 
3
#include <sys/time.h> 
4
#include "support.h"
5
 
6 342 markom
void excpt_dummy();
7
 
8
unsigned long excpt_buserr = (unsigned long) excpt_dummy;
9
unsigned long excpt_dpfault = (unsigned long) excpt_dummy;
10
unsigned long excpt_ipfault = (unsigned long) excpt_dummy;
11
unsigned long excpt_lpint = (unsigned long) excpt_dummy;
12
unsigned long excpt_align = (unsigned long) excpt_dummy;
13
unsigned long excpt_illinsn = (unsigned long) excpt_dummy;
14
unsigned long excpt_hpint = (unsigned long) excpt_dummy;
15
unsigned long excpt_dtlbmiss = (unsigned long) excpt_dummy;
16
unsigned long excpt_itlbmiss = (unsigned long) excpt_dummy;
17
unsigned long excpt_range = (unsigned long) excpt_dummy;
18
unsigned long excpt_syscall = (unsigned long) excpt_dummy;
19
unsigned long excpt_break = (unsigned long) excpt_dummy;
20
unsigned long excpt_trap = (unsigned long) excpt_dummy;
21
 
22 226 markom
#if OR1K
23
 
24
/* Start function, called by reset exception handler.  */
25
void reset ()
26
{
27
  int i = main();
28
  exit (i);
29
}
30
 
31
/* return value by making a syscall */
32
void exit (int i)
33
{
34
  asm("l.add r3,r0,%0": : "r" (i));
35
  asm("l.sys 203");
36
}
37
 
38
/* activate printf support in simulator */
39
void printf(const char *fmt, ...)
40
{
41
  va_list args;
42
  va_start(args, fmt);
43
  asm("l.addi\tr3,%0,0": :"r" (fmt));
44
  asm("l.addi\tr4,%0,0": :"r" (args));
45
  asm("l.sys 202");
46
}
47
 
48
/* print long */
49
void report(unsigned long value)
50
{
51
  unsigned long spr = 0x1234;
52
  asm("l.mtspr\t\t%0,%1,0x0" : : "r" (spr), "r" (value));
53
  return;
54
}
55
 
56
/* just to satisfy linker */
57
void __main()
58
{
59
}
60
 
61
/* start_TIMER                    */
62
void start_timer(int x)
63
{
64
}
65
 
66
/* read_TIMER                    */
67
/*  Returns a value since started in uS */
68
unsigned int read_timer(int x)
69
{
70
  unsigned long count = 0;
71
 
72
  /* Read the Time Stamp Counter */
73
/*        asm("simrdtsc %0" :"=r" (count)); */
74
  asm("l.sys 201");
75
  return count;
76
}
77
 
78
/* For writing into SPR. */
79
void mtspr(unsigned long spr, unsigned long value)
80
{
81
  asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
82
}
83
 
84
/* For reading SPR. */
85
unsigned long mfspr(unsigned long spr)
86
{
87
  unsigned long value;
88
  asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
89
  return value;
90
}
91
 
92
#else
93
void report(unsigned long value)
94
{
95
  unsigned long spr = 0x1234;
96
  printf("l.mtspr %x,%x\n", spr, value);
97
  return;
98
}
99
 
100
/* start_TIMER                    */
101
void start_timer(int tmrnum)
102
{
103
  return;
104
}
105
 
106
/* read_TIMER                    */
107
/*  Returns a value since started in uS */
108
unsigned int read_timer(int tmrnum)
109
{
110
  struct timeval tv;
111
  struct timezone tz;
112
 
113
  gettimeofday(&tv, &tz);
114
 
115
  return(tv.tv_sec*1000000+tv.tv_usec);
116
}
117
 
118
#endif
119
 
120
void *memcpy (void *__restrict dstvoid,
121
              __const void *__restrict srcvoid, size_t length)
122
{
123
  char *dst = dstvoid;
124
  const char *src = srcvoid;
125
 
126
  while (length--)
127
    *dst++ = *src++;
128
  return dst;
129
}
130 342 markom
 
131
void excpt_dummy() {}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.