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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_61/] [or1ksim/] [testbench/] [support/] [support.c] - Blame information for rev 381

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 378 markom
#include "int.h"
6 226 markom
 
7 381 markom
#if OR1K
8 342 markom
void excpt_dummy();
9 378 markom
void int_main();
10 342 markom
 
11
unsigned long excpt_buserr = (unsigned long) excpt_dummy;
12
unsigned long excpt_dpfault = (unsigned long) excpt_dummy;
13
unsigned long excpt_ipfault = (unsigned long) excpt_dummy;
14 378 markom
unsigned long excpt_lpint = (unsigned long) int_main;
15 342 markom
unsigned long excpt_align = (unsigned long) excpt_dummy;
16
unsigned long excpt_illinsn = (unsigned long) excpt_dummy;
17
unsigned long excpt_hpint = (unsigned long) excpt_dummy;
18
unsigned long excpt_dtlbmiss = (unsigned long) excpt_dummy;
19
unsigned long excpt_itlbmiss = (unsigned long) excpt_dummy;
20
unsigned long excpt_range = (unsigned long) excpt_dummy;
21
unsigned long excpt_syscall = (unsigned long) excpt_dummy;
22
unsigned long excpt_break = (unsigned long) excpt_dummy;
23
unsigned long excpt_trap = (unsigned long) excpt_dummy;
24
 
25 226 markom
 
26
/* Start function, called by reset exception handler.  */
27
void reset ()
28
{
29
  int i = main();
30
  exit (i);
31
}
32
 
33
/* return value by making a syscall */
34
void exit (int i)
35
{
36
  asm("l.add r3,r0,%0": : "r" (i));
37
  asm("l.sys 203");
38
}
39
 
40
/* activate printf support in simulator */
41
void printf(const char *fmt, ...)
42
{
43
  va_list args;
44
  va_start(args, fmt);
45
  asm("l.addi\tr3,%0,0": :"r" (fmt));
46
  asm("l.addi\tr4,%0,0": :"r" (args));
47
  asm("l.sys 202");
48
}
49
 
50
/* print long */
51
void report(unsigned long value)
52
{
53
  unsigned long spr = 0x1234;
54
  asm("l.mtspr\t\t%0,%1,0x0" : : "r" (spr), "r" (value));
55
  return;
56
}
57
 
58
/* just to satisfy linker */
59
void __main()
60
{
61
}
62
 
63
/* start_TIMER                    */
64
void start_timer(int x)
65
{
66
}
67
 
68
/* read_TIMER                    */
69
/*  Returns a value since started in uS */
70
unsigned int read_timer(int x)
71
{
72
  unsigned long count = 0;
73
 
74
  /* Read the Time Stamp Counter */
75
/*        asm("simrdtsc %0" :"=r" (count)); */
76
  asm("l.sys 201");
77
  return count;
78
}
79
 
80
/* For writing into SPR. */
81
void mtspr(unsigned long spr, unsigned long value)
82
{
83
  asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
84
}
85
 
86
/* For reading SPR. */
87
unsigned long mfspr(unsigned long spr)
88
{
89
  unsigned long value;
90
  asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
91
  return value;
92
}
93
 
94
#else
95
void report(unsigned long value)
96
{
97
  unsigned long spr = 0x1234;
98 381 markom
  printf("l.mtspr 0x%x, 0x%x\n", (unsigned) spr, (unsigned) value);
99 226 markom
}
100
 
101
/* start_TIMER                    */
102
void start_timer(int tmrnum)
103
{
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 381 markom
  const char *src = (const char *) srcvoid;
125 226 markom
 
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.