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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc1/] [or1ksim/] [testbench/] [support/] [support.c] - Blame information for rev 1780

Go to most recent revision | 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
  asm("l.add r3,r0,%0": : "r" (i));
37 511 markom
  asm("l.nop %0": :"K" (NOP_EXIT));
38
  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 956 simons
  __asm__ __volatile__ ("  l.addi\tr3,%0,0\n": : "r" (fmt) : "r3", "r4");
47
  __asm__ __volatile__ ("  l.addi\tr4,%0,0\n": : "r" (args): "r3", "r4");
48 1027 simons
  __asm__ __volatile__ ("  l.nop  %0": : "K" (NOP_PRINTF));
49 226 markom
}
50
 
51
/* print long */
52
void report(unsigned long value)
53
{
54 511 markom
  asm("l.addi\tr3,%0,0": :"r" (value));
55
  asm("l.nop %0": :"K" (NOP_REPORT));
56 226 markom
}
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 511 markom
  /*asm("l.sys 201"); */
77 226 markom
  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 1024 simons
  printf("report(0x%x);\n", (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.