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