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> |
---|
19 | #include <reent.h> |
---|
20 | |
---|
21 | #include <termios.h> |
---|
22 | |
---|
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 | * isatty -- returns 1 if connected to a terminal device, |
---|
58 | * returns 0 if not. |
---|
59 | */ |
---|
60 | int |
---|
61 | isatty(int fd) |
---|
62 | { |
---|
63 | return __rtems_isatty(fd); |
---|
64 | } |
---|
65 | |
---|
66 | /* |
---|
67 | * lseek -- move read/write pointer. Since a serial port |
---|
68 | * is non-seekable, we return an error. |
---|
69 | */ |
---|
70 | off_t |
---|
71 | lseek(int fd, |
---|
72 | off_t offset, |
---|
73 | int whence) |
---|
74 | { |
---|
75 | return __rtems_lseek(fd, offset, whence); |
---|
76 | } |
---|
77 | |
---|
78 | /* |
---|
79 | * fstat -- get status of a file. Since we have no file |
---|
80 | * system, we just return an error. |
---|
81 | */ |
---|
82 | int |
---|
83 | fstat(int fd, |
---|
84 | struct stat *buf) |
---|
85 | { |
---|
86 | return __rtems_fstat(fd, buf); |
---|
87 | } |
---|
88 | |
---|
89 | /* |
---|
90 | * getpid and kill are provided directly by rtems |
---|
91 | */ |
---|
92 | |
---|
93 | /* |
---|
94 | * ioctl -- IO control |
---|
95 | */ |
---|
96 | |
---|
97 | int |
---|
98 | ioctl(int fd, int request, void *argp) |
---|
99 | { |
---|
100 | return __rtems_ioctl(fd,request,argp); |
---|
101 | } |
---|
102 | |
---|
103 | /* |
---|
104 | * tcgetattr/tcsetattr -- get/set attributes of a device. |
---|
105 | * |
---|
106 | * by K.Shibuya |
---|
107 | */ |
---|
108 | |
---|
109 | int |
---|
110 | tcgetattr(int fd, struct termios *tp) |
---|
111 | { |
---|
112 | return __rtems_ioctl(fd,RTEMS_IO_GET_ATTRIBUTES,tp); |
---|
113 | } |
---|
114 | |
---|
115 | int |
---|
116 | tcsetattr(int fd, int opt, struct termios *tp) |
---|
117 | { |
---|
118 | if(opt != TCSANOW) |
---|
119 | return -1; |
---|
120 | return __rtems_ioctl(fd,RTEMS_IO_SET_ATTRIBUTES,tp); |
---|
121 | } |
---|
122 | |
---|
123 | #endif |
---|