[444] | 1 | /* syscalls.c -- reentrant syscalls for OpenRISC 1000. |
---|
| 2 | * |
---|
| 3 | * Copyright (c) 2011, 2014 Authors |
---|
| 4 | * |
---|
| 5 | * Contributor Julius Baxter <juliusbaxter@gmail.com> |
---|
| 6 | * Contributor Stefan Wallentowitz <stefan.wallentowitz@tum.de> |
---|
| 7 | * |
---|
| 8 | * The authors hereby grant permission to use, copy, modify, distribute, |
---|
| 9 | * and license this software and its documentation for any purpose, provided |
---|
| 10 | * that existing copyright notices are retained in all copies and that this |
---|
| 11 | * notice is included verbatim in any distributions. No written agreement, |
---|
| 12 | * license, or royalty fee is required for any of the authorized uses. |
---|
| 13 | * Modifications to this software may be copyrighted by their authors |
---|
| 14 | * and need not follow the licensing terms described here, provided that |
---|
| 15 | * the new terms are clearly indicated on the first page of each file where |
---|
| 16 | * they apply. |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | #include <errno.h> |
---|
| 20 | #include <reent.h> |
---|
| 21 | #include <sys/types.h> |
---|
| 22 | #include <sys/stat.h> |
---|
| 23 | #include <sys/time.h> |
---|
| 24 | #include "board.h" |
---|
| 25 | |
---|
| 26 | /* Write is actually the only thing we provide. All other are stubs.. */ |
---|
| 27 | |
---|
| 28 | extern void _or1k_outbyte(char c); |
---|
| 29 | |
---|
| 30 | _ssize_t |
---|
| 31 | _write_r(struct _reent * reent, int fd, const void *buf, size_t nbytes) |
---|
| 32 | { |
---|
| 33 | int i; |
---|
| 34 | char* b = (char*) buf; |
---|
| 35 | |
---|
| 36 | for (i = 0; i < nbytes; i++) { |
---|
| 37 | if (*(b + i) == '\n') { |
---|
| 38 | _or1k_outbyte ('\r'); |
---|
| 39 | } |
---|
| 40 | _or1k_outbyte (*(b + i)); |
---|
| 41 | } |
---|
| 42 | return (nbytes); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | void |
---|
| 46 | _exit(int rc) |
---|
| 47 | { |
---|
| 48 | _or1k_board_exit(); |
---|
| 49 | while (1) {} |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | int |
---|
| 53 | _close_r(struct _reent *reent, int fildes) |
---|
| 54 | { |
---|
| 55 | reent->_errno = ENOSYS; |
---|
| 56 | return -1; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | int |
---|
| 60 | _execve_r(struct _reent *reent, const char *name, char * const *argv, |
---|
| 61 | char * const *env) |
---|
| 62 | { |
---|
| 63 | reent->_errno = ENOSYS; |
---|
| 64 | return -1; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | int |
---|
| 68 | _fork_r(struct _reent *reent) |
---|
| 69 | { |
---|
| 70 | errno = ENOSYS; |
---|
| 71 | return -1; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | int |
---|
| 75 | _fstat_r(struct _reent *reent, int fildes, struct stat *st) |
---|
| 76 | { |
---|
| 77 | reent->_errno = ENOSYS; |
---|
| 78 | return -1; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | int |
---|
| 82 | _getpid_r(struct _reent *reent) |
---|
| 83 | { |
---|
| 84 | reent->_errno = ENOSYS; |
---|
| 85 | return -1; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | int |
---|
| 89 | _gettimeofday(struct _reent *reent, struct timeval *ptimeval, void *ptimezone) |
---|
| 90 | { |
---|
| 91 | reent->_errno = ENOSYS; |
---|
| 92 | return -1; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | int |
---|
| 96 | _isatty_r(struct _reent *reent, int file) |
---|
| 97 | { |
---|
| 98 | reent->_errno = ENOSYS; |
---|
| 99 | return 0; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | int |
---|
| 103 | _kill_r(struct _reent *reent, int pid, int sig) |
---|
| 104 | { |
---|
| 105 | reent->_errno = ENOSYS; |
---|
| 106 | return -1; |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | int |
---|
| 110 | _link_r(struct _reent *reent, const char *existing, const char *new) |
---|
| 111 | { |
---|
| 112 | reent->_errno = ENOSYS; |
---|
| 113 | return -1; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | _off_t |
---|
| 117 | _lseek_r(struct _reent *reent, int file, _off_t ptr, int dir) |
---|
| 118 | { |
---|
| 119 | errno = ENOSYS; |
---|
| 120 | return -1; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | int |
---|
| 124 | _open_r(struct _reent *reent, const char *file, int flags, int mode) |
---|
| 125 | { |
---|
| 126 | reent->_errno = ENOSYS; |
---|
| 127 | return -1; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | _ssize_t |
---|
| 131 | _read_r(struct _reent *reent, int file, void *ptr, size_t len) |
---|
| 132 | { |
---|
| 133 | reent->_errno = ENOSYS; |
---|
| 134 | return -1; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | int |
---|
| 138 | _readlink_r(struct _reent *reent, const char *path, char *buf, size_t bufsize) |
---|
| 139 | { |
---|
| 140 | reent->_errno = ENOSYS; |
---|
| 141 | return -1; |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | int |
---|
| 145 | _stat_r(struct _reent *reent, const char *path, struct stat *buf) |
---|
| 146 | { |
---|
| 147 | reent->_errno = EIO; |
---|
| 148 | return -1; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | int |
---|
| 152 | _unlink_r(struct _reent *reent, const char * path) |
---|
| 153 | { |
---|
| 154 | reent->_errno = EIO; |
---|
| 155 | return (-1); |
---|
| 156 | } |
---|
| 157 | |
---|