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 521

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

powered by: WebSVN 2.1.0

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