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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [libgloss/] [m32r/] [crtsysc.c] - Blame information for rev 40

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

Line No. Rev Author Line
1 39 lampret
#include <_ansi.h>
2
#include <sys/types.h>
3
#include <sys/stat.h>
4
#include <reent.h>
5
#include "sys/syscall.h"
6
 
7
int __trap0 (int function, int p1, int p2, int p3, struct _reent *r);
8
 
9
#define TRAP0(f, p1, p2, p3) \
10
__trap0 (f, (int) (p1), (int) (p2), (int) (p3), _REENT)
11
 
12
asm ("
13
        .text
14
        .global __trap0
15
__trap0:
16
        trap    #0              ; trap 0 returns result in r0, error code in r2
17
        cmpui   r2,#1           ; is error code zero?
18
        bc      .Lret           ; yes, skip setting errno
19
        .fillinsn
20
        ld      r4,@(sp)        ; no, set errno
21
        st      r2,@r4
22
.Lret:
23
        jmp     lr              ; return to caller
24
        .fillinsn
25
");
26
 
27
int
28
_open (const char *path, int flags)
29
{
30
  return TRAP0 (SYS_open, path, flags, 0);
31
}
32
 
33
int
34
_close (int file)
35
{
36
  return TRAP0 (SYS_close, file, 0, 0);
37
}
38
 
39
int
40
_read (int file, char *ptr, int len)
41
{
42
  return TRAP0 (SYS_read, file, ptr, len);
43
}
44
 
45
int
46
_lseek (int file, int ptr, int dir)
47
{
48
  return TRAP0 (SYS_lseek, file, ptr, dir);
49
}
50
 
51
int
52
_write (int file, char *ptr, int len)
53
{
54
  return TRAP0 (SYS_write, file, ptr, len);
55
}
56
 
57
caddr_t
58
_sbrk (int incr)
59
{
60
  /* `_end' is defined in the linker script.
61
     We must handle it carefully as we don't want the compiler to think
62
     it lives in the small data area.  Use medium model to ensure 32 bit
63
     addressability.  */
64
  extern char _end __attribute__ ((__model__(__medium__)));
65
  static char *heap_end;
66
  char *prev_heap_end;
67
  char *sp = (char *)&sp;
68
 
69
  if (heap_end == 0)
70
    {
71
      heap_end = &_end;
72
    }
73
  prev_heap_end = heap_end;
74
  if (heap_end > sp)
75
    {
76
      _write (1, "Heap and stack collision\n", 25);
77
      abort ();
78
    }
79
  heap_end += incr;
80
  return (caddr_t) prev_heap_end;
81
}
82
 
83
int
84
_fstat (int file, struct stat *st)
85
{
86
  st->st_mode = S_IFCHR;
87
  return 0;
88
}
89
 
90
int
91
_unlink ()
92
{
93
  return -1;
94
}
95
 
96
/* FIXME: can we not nuke the 10,000 copies of this function
97
   and fudge things (which is all this function does) in _fstat?  */
98
int
99
isatty (int fd)
100
{
101
  return 1;
102
}
103
 
104
void
105
_exit (n)
106
{
107
  TRAP0 (SYS_exit, n, 0, 0);
108
}
109
 
110
_kill (n, m)
111
{
112
  return TRAP0 (SYS_exit, 0xdead, 0, 0);
113
}
114
 
115
_getpid (n)
116
{
117
  return 1;
118
}
119
 
120
_raise ()
121
{
122
}
123
 
124
int
125
_stat (const char *path, struct stat *st)
126
 
127
{
128
  return TRAP0 (SYS_stat, path, st, 0);
129
}
130
 
131
int
132
_chmod (const char *path, short mode)
133
{
134
  return TRAP0 (SYS_chmod, path, mode, 0);
135
}
136
 
137
int
138
_utime (path, times)
139
     const char *path;
140
     char *times;
141
{
142
  return TRAP0 (SYS_utime, path, times, 0);
143
}

powered by: WebSVN 2.1.0

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