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

Subversion Repositories test_project

[/] [test_project/] [trunk/] [sw/] [support/] [support.c] - Blame information for rev 28

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

Line No. Rev Author Line
1 25 julius
/* Support */
2
 
3
#ifndef OR1K
4
#include <sys/time.h>
5
#endif
6
 
7
#include "spr_defs.h"
8
#include "support.h"
9
#include "int.h"
10
 
11
#if OR1K
12
void excpt_dummy();
13
void int_main();
14
 
15
unsigned long excpt_buserr = (unsigned long) excpt_dummy;
16
unsigned long excpt_dpfault = (unsigned long) excpt_dummy;
17
unsigned long excpt_ipfault = (unsigned long) excpt_dummy;
18
unsigned long excpt_tick = (unsigned long) excpt_dummy;
19
unsigned long excpt_align = (unsigned long) excpt_dummy;
20
unsigned long excpt_illinsn = (unsigned long) excpt_dummy;
21
unsigned long excpt_int = (unsigned long) int_main;
22
unsigned long excpt_dtlbmiss = (unsigned long) excpt_dummy;
23
unsigned long excpt_itlbmiss = (unsigned long) excpt_dummy;
24
unsigned long excpt_range = (unsigned long) excpt_dummy;
25
unsigned long excpt_syscall = (unsigned long) excpt_dummy;
26
unsigned long excpt_break = (unsigned long) excpt_dummy;
27
unsigned long excpt_trap = (unsigned long) excpt_dummy;
28
 
29
 
30
/* Start function, called by reset exception handler.  */
31
void reset ()
32
{
33
  int i = main();
34
  exit (i);
35
}
36
 
37
/* return value by making a syscall */
38
void exit (int i)
39
{
40
  asm("l.add r3,r0,%0": : "r" (i));
41
  asm("l.nop %0": :"K" (NOP_EXIT));
42
  while (1);
43
}
44
 
45
/* activate printf support in simulator */
46
void printf(const char *fmt, ...)
47
{
48
  va_list args;
49
  va_start(args, fmt);
50
  __asm__ __volatile__ ("  l.addi\tr3,%1,0\n \
51
                           l.addi\tr4,%2,0\n \
52
                           l.nop %0": :"K" (NOP_PRINTF), "r" (fmt), "r"  (args));
53
}
54
 
55
/* print long */
56
void report(unsigned long value)
57
{
58
  asm("l.addi\tr3,%0,0": :"r" (value));
59
  asm("l.nop %0": :"K" (NOP_REPORT));
60
}
61
 
62
/* just to satisfy linker */
63
void __main()
64
{
65
}
66
 
67
/* start_TIMER                    */
68
void start_timer(int x)
69
{
70
}
71
 
72
/* read_TIMER                    */
73
/*  Returns a value since started in uS */
74
unsigned int read_timer(int x)
75
{
76
  unsigned long count = 0;
77
 
78
  /* Read the Time Stamp Counter */
79
/*        asm("simrdtsc %0" :"=r" (count)); */
80
  /*asm("l.sys 201"); */
81
  return count;
82
}
83
 
84
/* For writing into SPR. */
85
void mtspr(unsigned long spr, unsigned long value)
86
{
87
  asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
88
}
89
 
90
/* For reading SPR. */
91
unsigned long mfspr(unsigned long spr)
92
{
93
  unsigned long value;
94
  asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
95
  return value;
96
}
97
 
98
#else
99
void report(unsigned long value)
100
{
101
  printf("report(0x%x);\n", (unsigned) value);
102
}
103
 
104
/* start_TIMER                    */
105
void start_timer(int tmrnum)
106
{
107
}
108
 
109
/* read_TIMER                    */
110
/*  Returns a value since started in uS */
111
unsigned int read_timer(int tmrnum)
112
{
113
  struct timeval tv;
114
  struct timezone tz;
115
 
116
  gettimeofday(&tv, &tz);
117
 
118
  return(tv.tv_sec*1000000+tv.tv_usec);
119
}
120
 
121
#endif
122
 
123
void *memcpy (void *__restrict dstvoid,
124
              __const void *__restrict srcvoid, size_t length)
125
{
126
  char *dst = dstvoid;
127
  const char *src = (const char *) srcvoid;
128
 
129
  while (length--)
130
    *dst++ = *src++;
131
  return dst;
132
}
133
 
134
void excpt_dummy() {}

powered by: WebSVN 2.1.0

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