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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_67/] [or1ksim/] [testbench/] [support/] [support.c] - Blame information for rev 226

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

powered by: WebSVN 2.1.0

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