Statistics
| Branch: | Revision:

root / prex-0.9.0 / include / sys / termios.h @ 03e9c04a

History | View | Annotate | Download (11.6 KB)

1
/*
2
 * Copyright (c) 1988, 1989, 1993, 1994
3
 *        The Regents of the University of California.  All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. Neither the name of the University nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 *
29
 *        @(#)termios.h        8.3 (Berkeley) 3/28/94
30
 */
31

    
32
#ifndef _SYS_TERMIOS_H_
33
#define _SYS_TERMIOS_H_
34

    
35
#include <sys/ioctl.h>
36

    
37
/*
38
 * Special Control Characters
39
 *
40
 * Index into c_cc[] character array.
41
 *
42
 *        Name             Subscript        Enabled by
43
 */
44
#define        VEOF                0        /* ICANON */
45
#define        VEOL                1        /* ICANON */
46
#define        VEOL2                2        /* ICANON */
47
#define        VERASE                3        /* ICANON */
48
#define VWERASE         4        /* ICANON */
49
#define VKILL                5        /* ICANON */
50
#define        VREPRINT         6        /* ICANON */
51
/*                        7           spare 1 */
52
#define VINTR                8        /* ISIG */
53
#define VQUIT                9        /* ISIG */
54
#define VSUSP                10        /* ISIG */
55
#define VDSUSP                11        /* ISIG */
56
#define VSTART                12        /* IXON, IXOFF */
57
#define VSTOP                13        /* IXON, IXOFF */
58
#define        VLNEXT                14        /* IEXTEN */
59
#define        VDISCARD        15        /* IEXTEN */
60
#define VMIN                16        /* !ICANON */
61
#define VTIME                17        /* !ICANON */
62
#define VSTATUS                18        /* ICANON */
63
#define VDDB                19        /* Prex: debugger key */
64
#define        NCCS                20
65

    
66
#define _POSIX_VDISABLE        ((unsigned char)'\377')
67

    
68
#define CCEQ(val, c)        (c == val ? val != _POSIX_VDISABLE : 0)
69

    
70
/*
71
 * Input flags - software input processing
72
 */
73
#define        IGNBRK                0x00000001        /* ignore BREAK condition */
74
#define        BRKINT                0x00000002        /* map BREAK to SIGINTR */
75
#define        IGNPAR                0x00000004        /* ignore (discard) parity errors */
76
#define        PARMRK                0x00000008        /* mark parity and framing errors */
77
#define        INPCK                0x00000010        /* enable checking of parity errors */
78
#define        ISTRIP                0x00000020        /* strip 8th bit off chars */
79
#define        INLCR                0x00000040        /* map NL into CR */
80
#define        IGNCR                0x00000080        /* ignore CR */
81
#define        ICRNL                0x00000100        /* map CR to NL (ala CRMOD) */
82
#define        IXON                0x00000200        /* enable output flow control */
83
#define        IXOFF                0x00000400        /* enable input flow control */
84
#define        IXANY                0x00000800        /* any char will restart after stop */
85
#define IMAXBEL                0x00002000        /* ring bell on input queue full */
86

    
87
/*
88
 * Output flags - software output processing
89
 */
90
#define        OPOST                0x00000001        /* enable following output processing */
91
#define ONLCR                0x00000002        /* map NL to CR-NL (ala CRMOD) */
92
#define OXTABS                0x00000004        /* expand tabs to spaces */
93
#define ONOEOT                0x00000008        /* discard EOT's (^D) on output) */
94

    
95
/*
96
 * Control flags - hardware control of terminal
97
 */
98
#define        CIGNORE                0x00000001        /* ignore control flags */
99
#define CSIZE                0x00000300        /* character size mask */
100
#define     CS5                    0x00000000            /* 5 bits (pseudo) */
101
#define     CS6                    0x00000100            /* 6 bits */
102
#define     CS7                    0x00000200            /* 7 bits */
103
#define     CS8                    0x00000300            /* 8 bits */
104
#define CSTOPB                0x00000400        /* send 2 stop bits */
105
#define CREAD                0x00000800        /* enable receiver */
106
#define PARENB                0x00001000        /* parity enable */
107
#define PARODD                0x00002000        /* odd parity, else even */
108
#define HUPCL                0x00004000        /* hang up on last close */
109
#define CLOCAL                0x00008000        /* ignore modem status lines */
110
#define CCTS_OFLOW        0x00010000        /* CTS flow control of output */
111
#define CRTSCTS                CCTS_OFLOW        /* ??? */
112
#define CRTS_IFLOW        0x00020000        /* RTS flow control of input */
113
#define        MDMBUF                0x00100000        /* flow control output via Carrier */
114

    
115
/*
116
 * "Local" flags - dumping ground for other state
117
 *
118
 * Warning: some flags in this structure begin with
119
 * the letter "I" and look like they belong in the
120
 * input flag.
121
 */
122

    
123
#ifndef _POSIX_SOURCE
124
#define        ECHOKE                0x00000001        /* visual erase for line kill */
125
#endif  /*_POSIX_SOURCE */
126
#define        ECHOE                0x00000002        /* visually erase chars */
127
#define        ECHOK                0x00000004        /* echo NL after line kill */
128
#define ECHO                0x00000008        /* enable echoing */
129
#define        ECHONL                0x00000010        /* echo NL even if ECHO is off */
130
#ifndef _POSIX_SOURCE
131
#define        ECHOPRT                0x00000020        /* visual erase mode for hardcopy */
132
#define ECHOCTL          0x00000040        /* echo control chars as ^(Char) */
133
#endif  /*_POSIX_SOURCE */
134
#define        ISIG                0x00000080        /* enable signals INTR, QUIT, [D]SUSP */
135
#define        ICANON                0x00000100        /* canonicalize input lines */
136
#ifndef _POSIX_SOURCE
137
#define ALTWERASE        0x00000200        /* use alternate WERASE algorithm */
138
#endif  /*_POSIX_SOURCE */
139
#define        IEXTEN                0x00000400        /* enable DISCARD and LNEXT */
140
#define EXTPROC         0x00000800      /* external processing */
141
#define TOSTOP                0x00400000        /* stop background jobs from output */
142
#ifndef _POSIX_SOURCE
143
#define FLUSHO                0x00800000        /* output being flushed (state) */
144
#define        NOKERNINFO        0x02000000        /* no kernel output from VSTATUS */
145
#define PENDIN                0x20000000        /* XXX retype pending input (state) */
146
#endif  /*_POSIX_SOURCE */
147
#define        NOFLSH                0x80000000        /* don't flush after interrupt */
148

    
149
typedef unsigned long        tcflag_t;
150
typedef unsigned char        cc_t;
151
typedef long                speed_t;
152

    
153
struct termios {
154
        tcflag_t        c_iflag;        /* input flags */
155
        tcflag_t        c_oflag;        /* output flags */
156
        tcflag_t        c_cflag;        /* control flags */
157
        tcflag_t        c_lflag;        /* local flags */
158
        cc_t                c_cc[NCCS];        /* control chars */
159
        long                c_ispeed;        /* input speed */
160
        long                c_ospeed;        /* output speed */
161
};
162

    
163
/*
164
 * Commands passed to tcsetattr() for setting the termios structure.
165
 */
166
#define        TCSANOW                0                /* make change immediate */
167
#define        TCSADRAIN        1                /* drain output, then change */
168
#define        TCSAFLUSH        2                /* drain output, flush input */
169
#ifndef _POSIX_SOURCE
170
#define TCSASOFT        0x10                /* flag - don't alter h.w. state */
171
#endif
172

    
173
/*
174
 * Standard speeds
175
 */
176
#define B0        0
177
#define B50        50
178
#define B75        75
179
#define B110        110
180
#define B134        134
181
#define B150        150
182
#define B200        200
183
#define B300        300
184
#define B600        600
185
#define B1200        1200
186
#define        B1800        1800
187
#define B2400        2400
188
#define B4800        4800
189
#define B9600        9600
190
#define B19200        19200
191
#define B38400        38400
192

    
193
#ifndef KERNEL
194

    
195
#define        TCIFLUSH        1
196
#define        TCOFLUSH        2
197
#define TCIOFLUSH        3
198
#define        TCOOFF                1
199
#define        TCOON                2
200
#define TCIOFF                3
201
#define TCION                4
202

    
203
#include <sys/cdefs.h>
204

    
205
__BEGIN_DECLS
206
speed_t        cfgetispeed(const struct termios *);
207
speed_t        cfgetospeed(const struct termios *);
208
int        cfsetispeed(struct termios *, speed_t);
209
int        cfsetospeed(struct termios *, speed_t);
210
int        tcgetattr(int, struct termios *);
211
int        tcsetattr(int, int, const struct termios *);
212
int        tcdrain(int);
213
int        tcflow(int, int);
214
int        tcflush(int, int);
215
int        tcsendbreak(int, int);
216

    
217
#ifndef _POSIX_SOURCE
218
void        cfmakeraw(struct termios *);
219
int        cfsetspeed(struct termios *, speed_t);
220
#endif /* !_POSIX_SOURCE */
221
__END_DECLS
222

    
223
#endif /* !KERNEL */
224

    
225

    
226
/*
227
 * Tty ioctl's except for those supported only for backwards compatibility
228
 * with the old tty driver.
229
 */
230

    
231
/*
232
 * Window/terminal size structure.  This information is stored by the kernel
233
 * in order to provide a consistent interface, but is not used by the kernel.
234
 */
235
struct winsize {
236
        unsigned short        ws_row;                /* rows, in characters */
237
        unsigned short        ws_col;                /* columns, in characters */
238
        unsigned short        ws_xpixel;        /* horizontal size, pixels */
239
        unsigned short        ws_ypixel;        /* vertical size, pixels */
240
};
241

    
242
#define        TIOCEXCL         _IO('t', 13)                /* set exclusive use of tty */
243
#define        TIOCNXCL         _IO('t', 14)                /* reset exclusive use of tty */
244
                                                /* 15 unused */
245
#define        TIOCFLUSH        _IOW('t', 16, int)        /* flush buffers */
246
                                                /* 17-18 compat */
247
#define        TIOCGETA        _IOR('t', 19, struct termios) /* get termios struct */
248
#define        TIOCSETA        _IOW('t', 20, struct termios) /* set termios struct */
249
#define        TIOCSETAW        _IOW('t', 21, struct termios) /* drain output, set */
250
#define        TIOCSETAF        _IOW('t', 22, struct termios) /* drn out, fls in, set */
251
#define        TIOCGETD        _IOR('t', 26, int)        /* get line discipline */
252
#define        TIOCSETD        _IOW('t', 27, int)        /* set line discipline */
253
                                                /* 127-124 compat */
254
#define        TIOCSBRK         _IO('t', 123)                /* set break bit */
255
#define        TIOCCBRK         _IO('t', 122)                /* clear break bit */
256
#define        TIOCSDTR         _IO('t', 121)                /* set data terminal ready */
257
#define        TIOCCDTR         _IO('t', 120)                /* clear data terminal ready */
258
#define        TIOCGPGRP        _IOR('t', 119, int)        /* get pgrp of tty */
259
#define        TIOCSPGRP        _IOW('t', 118, int)        /* set pgrp of tty */
260
                                                /* 117-116 compat */
261
#define        TIOCOUTQ        _IOR('t', 115, int)        /* output queue size */
262
#define        TIOCSTI                _IOW('t', 114, char)        /* simulate terminal input */
263
#define        TIOCNOTTY         _IO('t', 113)                /* void tty association */
264

    
265
#define        TIOCSTOP         _IO('t', 111)                /* stop output, like ^S */
266
#define        TIOCSTART         _IO('t', 110)                /* start output, like ^Q */
267
#define        TIOCMSET        _IOW('t', 109, int)        /* set all modem bits */
268
#define        TIOCMBIS        _IOW('t', 108, int)        /* bis modem bits */
269
#define        TIOCMBIC        _IOW('t', 107, int)        /* bic modem bits */
270
#define        TIOCMGET        _IOR('t', 106, int)        /* get all modem bits */
271
#define        TIOCGWINSZ        _IOR('t', 104, struct winsize)        /* get window size */
272
#define        TIOCSWINSZ        _IOW('t', 103, struct winsize)        /* set window size */
273
#define                UIOCCMD(n)        _IO('u', n)        /* usr cntl op "n" */
274
#define        TIOCCONS        _IOW('t', 98, int)        /* become virtual console */
275
#define        TIOCSCTTY         _IO('t', 97)                /* become controlling tty */
276
#define        TIOCDRAIN         _IO('t', 94)                /* wait till output drained */
277

    
278
#define        TTYDISC                0                /* termios tty line discipline */
279
#define        TABLDISC        3                /* tablet discipline */
280
#define        SLIPDISC        4                /* serial IP discipline */
281

    
282
/* Prex unique */
283
#define        TIOCSETSIGT        _IOW('t', 200, int)        /* set signal task */
284
#define TIOCINQ                _IOR('t', 201, int)        /* input queue size */
285

    
286
/*
287
 * Defaults on "first" open.
288
 */
289
#define        TTYDEF_IFLAG        (tcflag_t)(BRKINT | ICRNL | IXON | IXANY)
290
#define TTYDEF_OFLAG        (tcflag_t)(OPOST | ONLCR | OXTABS)
291
#define TTYDEF_LFLAG        (tcflag_t)(ECHO | ICANON | ISIG | ECHOE|ECHOK|ECHONL)
292
#define TTYDEF_CFLAG        (tcflag_t)(CREAD | CS8 | HUPCL)
293
#define TTYDEF_SPEED        (B9600)
294

    
295
/*
296
 * Control Character Defaults
297
 */
298
#define CTRL(x)        (cc_t)(x&037)
299
#define        CEOF                CTRL('d')
300
#define        CEOL                ((unsigned char)'\377')        /* XXX avoid _POSIX_VDISABLE */
301
#define        CERASE                0177
302
#define        CINTR                CTRL('c')
303
#define        CSTATUS                ((unsigned char)'\377')        /* XXX avoid _POSIX_VDISABLE */
304
#define        CKILL                CTRL('u')
305
#define        CMIN                1
306
#define        CQUIT                034                /* FS, ^\ */
307
#define        CSUSP                CTRL('z')
308
#define        CTIME                0
309
#define        CDSUSP                CTRL('y')
310
#define        CSTART                CTRL('q')
311
#define        CSTOP                CTRL('s')
312
#define        CLNEXT                CTRL('v')
313
#define        CDISCARD         CTRL('o')
314
#define        CWERASE         CTRL('w')
315
#define        CREPRINT         CTRL('r')
316
#define        CEOT                CEOF
317
/* compat */
318
#define        CBRK                CEOL
319
#define CRPRNT                CREPRINT
320
#define        CFLUSH                CDISCARD
321
#define        CKDB                CTRL('k')
322

    
323
#ifdef KERNEL
324
/*
325
 * #define TTYDEFCHARS to include an array of default control characters.
326
 */
327
#define TTYDEFCHARS \
328
{ \
329
        CEOF,        CEOL,        CEOL,        CERASE, CWERASE, CKILL, CREPRINT, \
330
        _POSIX_VDISABLE, CINTR,        CQUIT,        CSUSP,        CDSUSP,        CSTART,        CSTOP,        CLNEXT, \
331
        CDISCARD, CMIN,        CTIME,  CSTATUS, CKDB \
332
}
333
#endif /* KERNEL */
334

    
335
/*
336
 * END OF PROTECTED INCLUDE.
337
 */
338
#endif /* !_SYS_TERMIOS_H_ */