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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [z8ksim/] [glue.c] - Blame information for rev 258

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

Line No. Rev Author Line
1 207 jeremybenn
#include "sys/syscall.h"
2
#include <sys/types.h>
3
#include <sys/stat.h>
4
#include <_ansi.h>
5
#include <errno.h>
6
 
7
extern char _start_heap;
8
extern char _end_heap;
9
extern char _start_bss;
10
extern char _end_bss;
11
 
12
 
13
static int argl(long value)
14
{
15
  asm("ld r0,%H0" : : "r" (value));
16
  asm("ld r1,%I0" : : "r" (value));
17
  asm("sc %0" : : "i" (SYS_ARG));
18
}
19
 
20
 
21
static int argw(value)
22
{
23
  asm("ld r1,%H0" : : "r" ( value));
24
  asm("ld  r0,#0");
25
  asm("sc %0" : : "i" (SYS_ARG));
26
}
27
 
28
static int argp(void *value)
29
{
30
#ifdef __Z8001__  
31
  asm("ld r0,%H0" : : "r" (value));
32
  asm("ld r1,%I0" : : "r" (value));
33
#else
34
  asm("ld r1,%H0" : : "r" ( value));
35
  asm("ld  r0,#0");
36
#endif
37
  asm("sc %0" : : "i" (SYS_ARG));
38
 
39
}
40
 
41
 
42
 
43
#define ARGL(n, value)  argl(value)
44
#define ARGW(n, value)  argw(value)
45
#define ARGP(n, value) argp(value)
46
 
47
#define MACRO(n) asm("sc %0" : : "i" (n));
48
 
49
int _read (int fd, char *buf,size_t nbytes)
50
{
51
  ARGW(0,fd);
52
  ARGP(1,buf);
53
  ARGP(2,(void *)(nbytes));
54
  MACRO(SYS_read);
55
}
56
 
57
int _write (int fd, char *buf, size_t nbytes)
58
{
59
  ARGW(0,fd);
60
  ARGP(1,buf);
61
  ARGP(2,(void *)(nbytes));
62
  MACRO(SYS_write);
63
}
64
 
65
int _open (const char *buf, int flags, int mode)
66
{
67
  ARGP(0, buf);
68
  ARGW(1, flags);
69
  ARGW(2, mode);
70
  MACRO(SYS_open);
71
}
72
 
73
int _close (int fd)
74
{
75
  ARGW(0,fd);
76
  MACRO(SYS_close );
77
}
78
 
79
/*
80
 * sbrk -- changes heap size size. Get nbytes more
81
 *         RAM. We just increment a pointer in what's
82
 *         left of memory on the board.
83
 */
84
caddr_t _sbrk (size_t nbytes)
85
{
86
  static char* heap_ptr = NULL;
87
  caddr_t        base;
88
 
89
  if (heap_ptr == NULL) {
90
    heap_ptr = (caddr_t)&_start_heap;
91
  }
92
 
93
  if (heap_ptr + nbytes < &_end_heap) {
94
    base = heap_ptr;
95
    heap_ptr += nbytes;
96
    return (heap_ptr);
97
  } else {
98
    errno = ENOMEM;
99
    return ((caddr_t)-1);
100
  }
101
}
102
 
103
int isatty (int fd)
104
{
105
  ARGW(0,fd);
106
  MACRO(SYS_isatty);
107
}
108
 
109
off_t _lseek (int fd,  off_t offset, int whence)
110
{
111
  ARGW(0,fd);
112
  ARGL(1,offset);
113
  ARGW(2, whence);
114
  MACRO(SYS_lseek);
115
}
116
 
117
int _fstat (int fd, struct stat *buf)
118
{
119
  ARGW(0,fd);
120
  ARGP(1,buf);
121
  MACRO(SYS_fstat);
122
}
123
 
124
 
125
 
126
 
127
int
128
_exit(int val)
129
{
130
  ARGW(0,val);
131
  MACRO(SYS_exit);
132
}
133
 
134
time_t _time(time_t *timer)
135
{
136
  ARGP(0,timer);
137
  MACRO(SYS_time);
138
}
139
 
140
int
141
_creat (const char *path, int mode)
142
{
143
  ARGP(0, path);
144
  ARGW(1, mode);
145
  MACRO(SYS_creat);
146
}
147
 
148
_kill(int pid, int val)
149
{
150
  _exit(val);
151
}
152
 
153
_getpid()
154
{
155
  return 1;
156
}

powered by: WebSVN 2.1.0

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