|
| 1 | +/* Support files for GNU libc. Files in the system namespace go here. |
| 2 | + Files in the C namespace (ie those that do not start with an |
| 3 | + underscore) go in .c. */ |
| 4 | + |
| 5 | +#include <_ansi.h> |
| 6 | +#include <sys/types.h> |
| 7 | +#include <sys/stat.h> |
| 8 | +#include <sys/fcntl.h> |
| 9 | +#include <stdio.h> |
| 10 | +#include <time.h> |
| 11 | +#include <sys/time.h> |
| 12 | +#include <sys/times.h> |
| 13 | +#include <errno.h> |
| 14 | +#include <reent.h> |
| 15 | + |
| 16 | +void uart_putc ( unsigned int c ); |
| 17 | + |
| 18 | +unsigned int heap_end=0x0020000; |
| 19 | +unsigned int prev_heap_end; |
| 20 | + |
| 21 | +/* Forward prototypes. */ |
| 22 | +int _system _PARAMS ((const char *)); |
| 23 | +int _rename _PARAMS ((const char *, const char *)); |
| 24 | +int isatty _PARAMS ((int)); |
| 25 | +clock_t _times _PARAMS ((struct tms *)); |
| 26 | +int _gettimeofday _PARAMS ((struct timeval *, struct timezone *)); |
| 27 | +void _raise _PARAMS ((void)); |
| 28 | +int _unlink _PARAMS ((void)); |
| 29 | +int _link _PARAMS ((void)); |
| 30 | +int _stat _PARAMS ((const char *, struct stat *)); |
| 31 | +int _fstat _PARAMS ((int, struct stat *)); |
| 32 | +caddr_t _sbrk _PARAMS ((int)); |
| 33 | +int _getpid _PARAMS ((int)); |
| 34 | +int _kill _PARAMS ((int, int)); |
| 35 | +void _exit _PARAMS ((int)); |
| 36 | +int _close _PARAMS ((int)); |
| 37 | +int _open _PARAMS ((const char *, int, ...)); |
| 38 | +int _write _PARAMS ((int, char *, int)); |
| 39 | +int _lseek _PARAMS ((int, int, int)); |
| 40 | +int _read _PARAMS ((int, char *, int)); |
| 41 | +void initialise_monitor_handles _PARAMS ((void)); |
| 42 | + |
| 43 | +//static int |
| 44 | +//remap_handle (int fh) |
| 45 | +//{ |
| 46 | + //return 0; |
| 47 | +//} |
| 48 | + |
| 49 | +void |
| 50 | +initialise_monitor_handles (void) |
| 51 | +{ |
| 52 | +} |
| 53 | + |
| 54 | +//static int |
| 55 | +//get_errno (void) |
| 56 | +//{ |
| 57 | + //return(0); |
| 58 | +//} |
| 59 | + |
| 60 | +//static int |
| 61 | +//error (int result) |
| 62 | +//{ |
| 63 | + //errno = get_errno (); |
| 64 | + //return result; |
| 65 | +//} |
| 66 | + |
| 67 | + |
| 68 | +int |
| 69 | +_read (int file, |
| 70 | + char * ptr, |
| 71 | + int len) |
| 72 | +{ |
| 73 | + return len; |
| 74 | +} |
| 75 | + |
| 76 | + |
| 77 | +int |
| 78 | +_lseek (int file, |
| 79 | + int ptr, |
| 80 | + int dir) |
| 81 | +{ |
| 82 | + return 0; |
| 83 | +} |
| 84 | + |
| 85 | + |
| 86 | +int |
| 87 | +_write (int file, |
| 88 | + char * ptr, |
| 89 | + int len) |
| 90 | +{ |
| 91 | + int r; |
| 92 | + for(r=0;r<len;r++) uart_putc(ptr[r]); |
| 93 | + return len; |
| 94 | +} |
| 95 | + |
| 96 | +int |
| 97 | +_open (const char * path, |
| 98 | + int flags, |
| 99 | + ...) |
| 100 | +{ |
| 101 | + return 0; |
| 102 | +} |
| 103 | + |
| 104 | + |
| 105 | +int |
| 106 | +_close (int file) |
| 107 | +{ |
| 108 | + return 0; |
| 109 | +} |
| 110 | + |
| 111 | +void |
| 112 | +_exit (int n) |
| 113 | +{ |
| 114 | + while(1); |
| 115 | +} |
| 116 | + |
| 117 | +int |
| 118 | +_kill (int n, int m) |
| 119 | +{ |
| 120 | + return(0); |
| 121 | +} |
| 122 | + |
| 123 | +int |
| 124 | +_getpid (int n) |
| 125 | +{ |
| 126 | + return 1; |
| 127 | + n = n; |
| 128 | +} |
| 129 | + |
| 130 | + |
| 131 | +caddr_t |
| 132 | +_sbrk (int incr) |
| 133 | +{ |
| 134 | + prev_heap_end = heap_end; |
| 135 | + heap_end += incr; |
| 136 | + return (caddr_t) prev_heap_end; |
| 137 | +} |
| 138 | + |
| 139 | +int |
| 140 | +_fstat (int file, struct stat * st) |
| 141 | +{ |
| 142 | + return 0; |
| 143 | +} |
| 144 | + |
| 145 | +int _stat (const char *fname, struct stat *st) |
| 146 | +{ |
| 147 | + return 0; |
| 148 | +} |
| 149 | + |
| 150 | +int |
| 151 | +_link (void) |
| 152 | +{ |
| 153 | + return -1; |
| 154 | +} |
| 155 | + |
| 156 | +int |
| 157 | +_unlink (void) |
| 158 | +{ |
| 159 | + return -1; |
| 160 | +} |
| 161 | + |
| 162 | +void |
| 163 | +_raise (void) |
| 164 | +{ |
| 165 | + return; |
| 166 | +} |
| 167 | + |
| 168 | +int |
| 169 | +_gettimeofday (struct timeval * tp, struct timezone * tzp) |
| 170 | +{ |
| 171 | + if(tp) |
| 172 | + { |
| 173 | + tp->tv_sec = 10; |
| 174 | + tp->tv_usec = 0; |
| 175 | + } |
| 176 | + if (tzp) |
| 177 | + { |
| 178 | + tzp->tz_minuteswest = 0; |
| 179 | + tzp->tz_dsttime = 0; |
| 180 | + } |
| 181 | + return 0; |
| 182 | +} |
| 183 | + |
| 184 | +clock_t |
| 185 | +_times (struct tms * tp) |
| 186 | +{ |
| 187 | + clock_t timeval; |
| 188 | + |
| 189 | + timeval = 10; |
| 190 | + if (tp) |
| 191 | + { |
| 192 | + tp->tms_utime = timeval; /* user time */ |
| 193 | + tp->tms_stime = 0; /* system time */ |
| 194 | + tp->tms_cutime = 0; /* user time, children */ |
| 195 | + tp->tms_cstime = 0; /* system time, children */ |
| 196 | + } |
| 197 | + return timeval; |
| 198 | +}; |
| 199 | + |
| 200 | + |
| 201 | +int |
| 202 | +_isatty (int fd) |
| 203 | +{ |
| 204 | + return 1; |
| 205 | + fd = fd; |
| 206 | +} |
| 207 | + |
| 208 | +int |
| 209 | +_system (const char *s) |
| 210 | +{ |
| 211 | + if (s == NULL) |
| 212 | + return 0; |
| 213 | + errno = ENOSYS; |
| 214 | + return -1; |
| 215 | +} |
| 216 | + |
| 217 | +int |
| 218 | +_rename (const char * oldpath, const char * newpath) |
| 219 | +{ |
| 220 | + errno = ENOSYS; |
| 221 | + return -1; |
| 222 | +} |
0 commit comments