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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_AT91SAM7X256_Eclipse/] [RTOSDemo/] [syscalls.c] - Blame information for rev 615

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

Line No. Rev Author Line
1 577 jeremybenn
/****************************************************************************
2
*  Copyright (c) 2009 by Michael Fischer. All rights reserved.
3
*
4
*  Redistribution and use in source and binary forms, with or without
5
*  modification, are permitted provided that the following conditions
6
*  are met:
7
*
8
*  1. Redistributions of source code must retain the above copyright
9
*     notice, this list of conditions and the following disclaimer.
10
*  2. Redistributions in binary form must reproduce the above copyright
11
*     notice, this list of conditions and the following disclaimer in the
12
*     documentation and/or other materials provided with the distribution.
13
*  3. Neither the name of the author nor the names of its contributors may
14
*     be used to endorse or promote products derived from this software
15
*     without specific prior written permission.
16
*
17
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20
*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21
*  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22
*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23
*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24
*  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25
*  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
*  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27
*  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
*  SUCH DAMAGE.
29
*
30
****************************************************************************
31
*  History:
32
*
33
*  28.03.09  mifi   First Version, based on the original syscall.c from
34
*                   newlib version 1.17.0
35
****************************************************************************/
36
 
37
#include <stdlib.h>
38
#include <errno.h>
39
#include <string.h>
40
#include <sys/stat.h>
41
#include <sys/types.h>
42
 
43
/***************************************************************************/
44
 
45
int _read_r (struct _reent *r, int file, char * ptr, int len)
46
{
47
  r = r;
48
  file = file;
49
  ptr = ptr;
50
  len = len;
51
 
52
  errno = EINVAL;
53
  return -1;
54
}
55
 
56
/***************************************************************************/
57
 
58
int _lseek_r (struct _reent *r, int file, int ptr, int dir)
59
{
60
  r = r;
61
  file = file;
62
  ptr = ptr;
63
  dir = dir;
64
 
65
  return 0;
66
}
67
 
68
/***************************************************************************/
69
 
70
int _write_r (struct _reent *r, int file, char * ptr, int len)
71
{
72
  r = r;
73
  file = file;
74
  ptr = ptr;
75
 
76
#if 0
77
  int index;
78
 
79
  /* For example, output string by UART */
80
  for(index=0; index<len; index++)
81
  {
82
    if (ptr[index] == '\n')
83
    {
84
      uart_putc('\r');
85
    }
86
 
87
    uart_putc(ptr[index]);
88
  }
89
#endif   
90
 
91
  return len;
92
}
93
 
94
/***************************************************************************/
95
 
96
int _close_r (struct _reent *r, int file)
97
{
98
  return 0;
99
}
100
 
101
/***************************************************************************/
102
 
103
/* Register name faking - works in collusion with the linker.  */
104
register char * stack_ptr asm ("sp");
105
 
106
caddr_t _sbrk_r (struct _reent *r, int incr)
107
{
108
  extern char   end asm ("end"); /* Defined by the linker.  */
109
  static char * heap_end;
110
  char *        prev_heap_end;
111
 
112
  if (heap_end == NULL)
113
    heap_end = & end;
114
 
115
  prev_heap_end = heap_end;
116
 
117
  if (heap_end + incr > stack_ptr)
118
  {
119
      /* Some of the libstdc++-v3 tests rely upon detecting
120
        out of memory errors, so do not abort here.  */
121
#if 0
122
      extern void abort (void);
123
 
124
      _write (1, "_sbrk: Heap and stack collision\n", 32);
125
 
126
      abort ();
127
#else
128
      errno = ENOMEM;
129
      return (caddr_t) -1;
130
#endif
131
  }
132
 
133
  heap_end += incr;
134
 
135
  return (caddr_t) prev_heap_end;
136
}
137
 
138
/***************************************************************************/
139
 
140
int _fstat_r (struct _reent *r, int file, struct stat * st)
141
{
142
  r = r;
143
  file = file;
144
 
145
  memset (st, 0, sizeof (* st));
146
  st->st_mode = S_IFCHR;
147
  return 0;
148
}
149
 
150
/***************************************************************************/
151
 
152
int _isatty_r(struct _reent *r, int fd)
153
{
154
  r = r;
155
  fd = fd;
156
 
157
  return 1;
158
}
159
 
160
/*** EOF ***/
161
 
162
 

powered by: WebSVN 2.1.0

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