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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [mp3/] [sw/] [support/] [support.c] - Blame information for rev 1774

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

Line No. Rev Author Line
1 505 lampret
/* 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 564 lampret
  asm("l.nop 1");
20 505 lampret
}
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 564 lampret
  asm("l.nop 3");
30 505 lampret
}
31
 
32
/* print long */
33
void report(unsigned long value)
34
{
35 564 lampret
  asm("l.nop 2");
36 505 lampret
  return;
37
}
38
 
39
/* just to satisfy linker */
40
void __main()
41
{
42
}
43
 
44
/* start_TIMER                    */
45
void start_timer(int x)
46
{
47
}
48
 
49
/* read_TIMER                    */
50
/*  Returns a value since started in uS */
51
unsigned int read_timer(int x)
52
{
53
  unsigned long count = 0;
54
 
55
  /* Read the Time Stamp Counter */
56 564 lampret
/*        asm("simrdtsc %0" :"=r" (count));
57
  asm("l.nop X"); */
58 505 lampret
  return count;
59
}
60
 
61
/* For writing into SPR. */
62
void mtspr(unsigned long spr, unsigned long value)
63
{
64
  asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
65
}
66
 
67
/* For reading SPR. */
68
unsigned long mfspr(unsigned long spr)
69
{
70
  unsigned long value;
71
  asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
72
  return value;
73
}
74
 
75
#else
76
void report(unsigned long value)
77
{
78
  return;
79
}
80
 
81
/* start_TIMER                    */
82
void start_timer(int tmrnum)
83
{
84
  return;
85
}
86
 
87
/* read_TIMER                    */
88
/*  Returns a value since started in uS */
89
unsigned int read_timer(int tmrnum)
90
{
91
  struct timeval tv;
92
  struct timezone tz;
93
 
94
  gettimeofday(&tv, &tz);
95
 
96
  return(tv.tv_sec*1000000+tv.tv_usec);
97
}
98
 
99
#endif
100
 
101
void *memcpy (void *__restrict dstvoid,
102
              __const void *__restrict srcvoid, size_t length)
103
{
104
  char *dst = dstvoid;
105
  const char *src = srcvoid;
106
 
107
  while (length--)
108
    *dst++ = *src++;
109
  return dst;
110
}

powered by: WebSVN 2.1.0

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