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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [testbench/] [support/] [support.c] - Blame information for rev 378

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 342 markom
void excpt_dummy();
8 378 markom
void int_main();
9 342 markom
 
10
unsigned long excpt_buserr = (unsigned long) excpt_dummy;
11
unsigned long excpt_dpfault = (unsigned long) excpt_dummy;
12
unsigned long excpt_ipfault = (unsigned long) excpt_dummy;
13 378 markom
unsigned long excpt_lpint = (unsigned long) int_main;
14 342 markom
unsigned long excpt_align = (unsigned long) excpt_dummy;
15
unsigned long excpt_illinsn = (unsigned long) excpt_dummy;
16
unsigned long excpt_hpint = (unsigned long) excpt_dummy;
17
unsigned long excpt_dtlbmiss = (unsigned long) excpt_dummy;
18
unsigned long excpt_itlbmiss = (unsigned long) excpt_dummy;
19
unsigned long excpt_range = (unsigned long) excpt_dummy;
20
unsigned long excpt_syscall = (unsigned long) excpt_dummy;
21
unsigned long excpt_break = (unsigned long) excpt_dummy;
22
unsigned long excpt_trap = (unsigned long) excpt_dummy;
23
 
24 226 markom
#if OR1K
25
 
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
  printf("l.mtspr %x,%x\n", spr, value);
99
  return;
100
}
101
 
102
/* start_TIMER                    */
103
void start_timer(int tmrnum)
104
{
105
  return;
106
}
107
 
108
/* read_TIMER                    */
109
/*  Returns a value since started in uS */
110
unsigned int read_timer(int tmrnum)
111
{
112
  struct timeval tv;
113
  struct timezone tz;
114
 
115
  gettimeofday(&tv, &tz);
116
 
117
  return(tv.tv_sec*1000000+tv.tv_usec);
118
}
119
 
120
#endif
121
 
122
void *memcpy (void *__restrict dstvoid,
123
              __const void *__restrict srcvoid, size_t length)
124
{
125
  char *dst = dstvoid;
126
  const char *src = srcvoid;
127
 
128
  while (length--)
129
    *dst++ = *src++;
130
  return dst;
131
}
132 342 markom
 
133
void excpt_dummy() {}

powered by: WebSVN 2.1.0

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