[dcec5a4] | 1 | |
---|
| 2 | /* |
---|
| 3 | * This file contains the glue which maps newlib system calls onto their |
---|
| 4 | * RTEMS implementations. This formerly was in the file |
---|
| 5 | * libgloss/rtems/iface.c which was installed as rtems.o. Merging this |
---|
| 6 | * into the RTEMS source tree minimizes the files which must be linked |
---|
| 7 | * to build an rtems application. |
---|
| 8 | * |
---|
| 9 | * $Id$ |
---|
| 10 | * |
---|
| 11 | */ |
---|
| 12 | |
---|
| 13 | #include <rtems.h> |
---|
| 14 | #if defined(RTEMS_NEWLIB) |
---|
| 15 | |
---|
| 16 | #include <sys/types.h> |
---|
| 17 | #include <sys/stat.h> |
---|
| 18 | #include <errno.h> |
---|
[b1459dc] | 19 | #include <reent.h> |
---|
[dcec5a4] | 20 | |
---|
[1f581ec] | 21 | #include <termios.h> |
---|
| 22 | |
---|
[dcec5a4] | 23 | #include "internal.h" |
---|
| 24 | #include "libio.h" |
---|
| 25 | |
---|
| 26 | int |
---|
| 27 | read(int fd, |
---|
| 28 | char *buf, |
---|
| 29 | int nbytes) |
---|
| 30 | { |
---|
| 31 | return __rtems_read(fd, buf, nbytes); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | int |
---|
| 35 | write(int fd, |
---|
| 36 | char *buf, |
---|
| 37 | int nbytes) |
---|
| 38 | { |
---|
| 39 | return __rtems_write(fd, buf, nbytes); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | int |
---|
| 43 | open(char *buf, |
---|
| 44 | int flags, |
---|
| 45 | int mode) |
---|
| 46 | { |
---|
| 47 | return __rtems_open(buf, flags, mode); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | int |
---|
| 51 | close(int fd) |
---|
| 52 | { |
---|
| 53 | return __rtems_close(fd); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | /* |
---|
| 57 | * lseek -- move read/write pointer. Since a serial port |
---|
| 58 | * is non-seekable, we return an error. |
---|
| 59 | */ |
---|
| 60 | off_t |
---|
| 61 | lseek(int fd, |
---|
| 62 | off_t offset, |
---|
| 63 | int whence) |
---|
| 64 | { |
---|
| 65 | return __rtems_lseek(fd, offset, whence); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | /* |
---|
| 69 | * fstat -- get status of a file. Since we have no file |
---|
| 70 | * system, we just return an error. |
---|
| 71 | */ |
---|
| 72 | int |
---|
| 73 | fstat(int fd, |
---|
| 74 | struct stat *buf) |
---|
| 75 | { |
---|
| 76 | return __rtems_fstat(fd, buf); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | /* |
---|
| 80 | * getpid and kill are provided directly by rtems |
---|
| 81 | */ |
---|
| 82 | |
---|
[9deb5b8b] | 83 | /* |
---|
| 84 | * ioctl -- IO control |
---|
| 85 | */ |
---|
| 86 | |
---|
| 87 | int |
---|
| 88 | ioctl(int fd, int request, void *argp) |
---|
| 89 | { |
---|
| 90 | return __rtems_ioctl(fd,request,argp); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | /* |
---|
| 94 | * tcgetattr/tcsetattr -- get/set attributes of a device. |
---|
| 95 | * |
---|
| 96 | * by K.Shibuya |
---|
| 97 | */ |
---|
| 98 | |
---|
| 99 | int |
---|
| 100 | tcgetattr(int fd, struct termios *tp) |
---|
| 101 | { |
---|
| 102 | return __rtems_ioctl(fd,RTEMS_IO_GET_ATTRIBUTES,tp); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | int |
---|
| 106 | tcsetattr(int fd, int opt, struct termios *tp) |
---|
| 107 | { |
---|
| 108 | if(opt != TCSANOW) |
---|
| 109 | return -1; |
---|
| 110 | return __rtems_ioctl(fd,RTEMS_IO_SET_ATTRIBUTES,tp); |
---|
| 111 | } |
---|
| 112 | |
---|
[dcec5a4] | 113 | #endif |
---|