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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [or1ksim/] [or1ksim-0.3.0/] [testbench/] [support/] [support.c] - Blame information for rev 403

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

Line No. Rev Author Line
1 19 jeremybenn
/* Support */
2
 
3
#include "spr_defs.h"
4
#include "support.h"
5
#include "int.h"
6
 
7
#if OR1K
8
void excpt_dummy();
9
void int_main();
10
 
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
unsigned long excpt_tick = (unsigned long) excpt_dummy;
15
unsigned long excpt_align = (unsigned long) excpt_dummy;
16
unsigned long excpt_illinsn = (unsigned long) excpt_dummy;
17
unsigned long excpt_int = (unsigned long) int_main;
18
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
 
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__ __volatile__ ("l.add r3,r0,%0\n\t"
37
                        "l.nop %1": : "r" (i), "K" (NOP_EXIT));
38
  while (1);
39
}
40
 
41
/* activate printf support in simulator */
42
void printf(const char *fmt, ...)
43
{
44
  va_list args;
45
  va_start(args, fmt);
46
  __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
}
52
 
53
/* print long */
54
void report(unsigned long value)
55
{
56
  __asm__ __volatile__ ("l.addi\tr3,%0,0\n\t"
57
                        "l.nop %1": : "r" (value), "K" (NOP_REPORT));
58
}
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
  /*asm("l.sys 201"); */
79
  return count;
80
}
81
 
82
/* For writing into SPR. */
83
void mtspr(unsigned long spr, unsigned long value)
84
{
85
  __asm__ __volatile__ ("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
86
}
87
 
88
/* For reading SPR. */
89
unsigned long mfspr(unsigned long spr)
90
{
91
  unsigned long value;
92
  __asm__ __volatile__ ("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
93
  return value;
94
}
95
 
96
#else
97
void report(unsigned long value)
98
{
99
  printf("report(0x%x);\n", (unsigned) value);
100
}
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
  const char *src = (const char *) srcvoid;
126
 
127
  while (length--)
128
    *dst++ = *src++;
129
  return dst;
130
}
131
 
132
void excpt_dummy() {}

powered by: WebSVN 2.1.0

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