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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [testbench/] [support/] [support.c] - Blame information for rev 1782

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

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