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

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [testbench/] [support/] [support.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 226 markom
/* Support */
2
 
3 511 markom
#include "spr_defs.h"
4 226 markom
#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 600 simons
unsigned long excpt_tick = (unsigned long) excpt_dummy;
15 342 markom
unsigned long excpt_align = (unsigned long) excpt_dummy;
16
unsigned long excpt_illinsn = (unsigned long) excpt_dummy;
17 600 simons
unsigned long excpt_int = (unsigned long) int_main;
18 342 markom
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 1578 nogj
  __asm__ __volatile__ ("l.add r3,r0,%0\n\t"
37
                        "l.nop %1": : "r" (i), "K" (NOP_EXIT));
38 511 markom
  while (1);
39 226 markom
}
40
 
41 1024 simons
/* activate printf support in simulator */
42
void printf(const char *fmt, ...)
43 226 markom
{
44
  va_list args;
45
  va_start(args, fmt);
46 1578 nogj
  __asm__ __volatile__ ("l.addi\tr3,%0,0\n\t"
47
                        "l.addi\tr4,%1,0\n\t"
48
                        "l.nop  %2"
49
                        : : "r" (fmt), "r" (args), "K" (NOP_PRINTF)
50
                        : "r3", "r4");
51 226 markom
}
52
 
53
/* print long */
54
void report(unsigned long value)
55
{
56 1578 nogj
  __asm__ __volatile__ ("l.addi\tr3,%0,0\n\t"
57
                        "l.nop %1": : "r" (value), "K" (NOP_REPORT));
58 226 markom
}
59
 
60
/* just to satisfy linker */
61
void __main()
62
{
63
}
64
 
65
/* start_TIMER                    */
66
void start_timer(int x)
67
{
68
}
69
 
70
/* read_TIMER                    */
71
/*  Returns a value since started in uS */
72
unsigned int read_timer(int x)
73
{
74
  unsigned long count = 0;
75
 
76
  /* Read the Time Stamp Counter */
77
/*        asm("simrdtsc %0" :"=r" (count)); */
78 511 markom
  /*asm("l.sys 201"); */
79 226 markom
  return count;
80
}
81
 
82
/* For writing into SPR. */
83
void mtspr(unsigned long spr, unsigned long value)
84
{
85 1578 nogj
  __asm__ __volatile__ ("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
86 226 markom
}
87
 
88
/* For reading SPR. */
89
unsigned long mfspr(unsigned long spr)
90
{
91
  unsigned long value;
92 1578 nogj
  __asm__ __volatile__ ("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
93 226 markom
  return value;
94
}
95
 
96
#else
97
void report(unsigned long value)
98
{
99 1024 simons
  printf("report(0x%x);\n", (unsigned) value);
100 226 markom
}
101
 
102
/* start_TIMER                    */
103
void start_timer(int tmrnum)
104
{
105
}
106
 
107
/* read_TIMER                    */
108
/*  Returns a value since started in uS */
109
unsigned int read_timer(int tmrnum)
110
{
111
  struct timeval tv;
112
  struct timezone tz;
113
 
114
  gettimeofday(&tv, &tz);
115
 
116
  return(tv.tv_sec*1000000+tv.tv_usec);
117
}
118
 
119
#endif
120
 
121
void *memcpy (void *__restrict dstvoid,
122
              __const void *__restrict srcvoid, size_t length)
123
{
124
  char *dst = dstvoid;
125 381 markom
  const char *src = (const char *) srcvoid;
126 226 markom
 
127
  while (length--)
128
    *dst++ = *src++;
129
  return dst;
130
}
131 342 markom
 
132
void excpt_dummy() {}

powered by: WebSVN 2.1.0

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