2.9
[glibc/nacl-glibc.git] / sysdeps / mach / hurd / bits / ioctls.h
blob8718aacd835991ac3c5910eba5ddbe4b735e1a96
1 /* Copyright (C) 1992,93,96,97,98,99,2001,2007 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #ifndef __BITS_IOCTLS_H
20 #define __BITS_IOCTLS_H 1
22 #if !defined _HURD_IOCTL_H && !defined _SYS_IOCTL_H
23 # error "Never use <bits/ioctls.h> directly; include <hurd/ioctl.h> instead."
24 #endif
26 /* These macros are also defined in <bits/termios.h> (with numerically
27 identical values) but this serves to shut up cpp's complaining. */
29 #ifdef NL0
30 # undef NL0
31 #endif
32 #ifdef NL1
33 # undef NL1
34 #endif
35 #ifdef TAB0
36 # undef TAB0
37 #endif
38 #ifdef TAB1
39 # undef TAB1
40 #endif
41 #ifdef TAB2
42 # undef TAB2
43 #endif
44 #ifdef CR0
45 # undef CR0
46 #endif
47 #ifdef CR1
48 # undef CR1
49 #endif
50 #ifdef CR2
51 # undef CR2
52 #endif
53 #ifdef CR3
54 # undef CR3
55 #endif
56 #ifdef FF0
57 # undef FF0
58 #endif
59 #ifdef FF1
60 # undef FF1
61 #endif
62 #ifdef BS0
63 # undef BS0
64 #endif
65 #ifdef BS1
66 # undef BS1
67 #endif
68 #ifdef MDMBUF
69 # undef MDMBUF
70 #endif
71 #ifdef ECHO
72 # undef ECHO
73 #endif
74 #ifdef TOSTOP
75 # undef TOSTOP
76 #endif
77 #ifdef FLUSHO
78 # undef FLUSHO
79 #endif
80 #ifdef PENDIN
81 # undef PENDIN
82 #endif
83 #ifdef NOFLSH
84 # undef NOFLSH
85 #endif
87 /* Hurd ioctl request are made up of several fields:
89 10987654321098765432109876543210
90 IOt0t1t2cc0c0cc1c1cc2ggggccccccc
92 bits [31,30]: inout direction (enum __ioctl_dir)
93 bits [29,11]: type encoding as follows; zero count indicates omitted datum
94 [29,28]: datum #0 type (enum __ioctl_datum)
95 [27,26]: datum #1 type (enum __ioctl_datum)
96 [24,25]: datum #2 type (enum __ioctl_datum)
97 [23,19]: datum #0 count [0,31]
98 [18,14]: datum #1 count [0,31]
99 [13,11]: datum #2 count [0,3]
100 bits [07,10]: group (letter - 'f': ['f','v'])
101 bits [00,06]: command [0,127]
103 The following macros construct and dissect these fields. */
105 enum __ioctl_dir
107 IOC_VOID = 0, /* No parameters. */
108 IOC_OUT = 1, /* Data is written into the user's buffer. */
109 IOC_IN = 2, /* Data is read from the user's buffer. */
110 IOC_INOUT = (IOC_IN|IOC_OUT)
113 enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 };
115 /* Construct an ioctl from constructed type plus other fields. */
116 #define _IOC(inout, group, num, type) \
117 ((num) | ((((group) - 'f') | ((type) | (inout) << 19) << 4) << 7))
119 /* Dissect an ioctl into its component fields. */
120 #define _IOC_INOUT(request) (((unsigned int) (request) >> 30) & IOC_INOUT)
121 #define _IOC_GROUP(request) ('f' + (((unsigned int) (request) >> 7) & 0xf))
122 #define _IOC_COMMAND(request) ((unsigned int) (request) & 0x7f)
123 #define _IOC_TYPE(request) (((unsigned int) (request) >> 11) & 0x7ffff)
124 #define _IOC_NOTYPE(request) ((unsigned int) (request) & 0x3ff)
126 /* Construct a type information field from
127 the broken-out type and count fields. */
128 #define _IOT(t0, c0, t1, c1, t2, c2) \
129 ((c2) | (((c1) | ((c0) | ((t2) | ((t1) | (t0) << 2) << 2) << 5) << 5) << 3))
131 /* Dissect a type information field into the type and count fields. */
132 #define _IOT_TYPE0(type) (((unsigned int) (type) >> 17) & 3)
133 #define _IOT_TYPE1(type) (((unsigned int) (type) >> 15) & 3)
134 #define _IOT_TYPE2(type) (((unsigned int) (type) >> 13) & 3)
135 #define _IOT_COUNT0(type) (((unsigned int) (type) >> 8) & 0x1f)
136 #define _IOT_COUNT1(type) (((unsigned int) (type) >> 3) & 0x1f)
137 #define _IOT_COUNT2(type) (((unsigned int) (type) >> 0) & 7)
139 /* Construct an ioctl from all the broken-out fields. */
140 #define _IOCT(inout, group, num, t0, c0, t1, c1, t2, c2) \
141 _IOC ((inout), (group), (num), _IOT ((t0), (c0), (t1), (c1), (t2), (c2)))
143 /* Construct an individual type field for TYPE. */
144 #define _IOTS(type) \
145 (sizeof (type) == 8 ? IOC_64 : (sizeof (type) >> 1))
147 /* Construct a type information field for
148 a single argument of the scalar TYPE. */
149 #define _IOT_SIMPLE(type) _IOT (_IOTS (type), 1, 0, 0, 0, 0)
151 /* Basic C types. */
152 #define _IOT__IOTBASE_int _IOT_SIMPLE (int)
153 #define _IOT__IOTBASE_char _IOT_SIMPLE (char)
154 #define _IOT__IOTBASE_short _IOT_SIMPLE (short)
157 /* Standard flavors of ioctls.
158 _IOT_foobar is defined either in this file,
159 or where struct foobar is defined. */
160 #define _IO(g, n) _IOC (IOC_VOID, (g), (n), 0)
161 #define _IOR(g, n, t) _IOC (IOC_OUT, (g), (n), _IOC_ENCODE_TYPE (t))
162 #define _IOW(g, n, t) _IOC (IOC_IN, (g), (n), _IOC_ENCODE_TYPE (t))
163 #define _IOWR(g, n, t) _IOC (IOC_INOUT, (g), (n), _IOC_ENCODE_TYPE (t))
165 /* These macros do some preprocessor gymnastics to turn a TYPESPEC of
166 `struct foobar' into the identifier `_IOT_foobar', which is generally
167 defined using `_IOT' (above) in whatever file defines `struct foobar'.
168 For a TYPESPEC that does not begin with `struct' produces a different
169 identifier: `int' produces `_IOT__IOTBASE_int'. These identifiers
170 are defined for the basic C types above. */
171 #define _IOC_ENCODE_TYPE(typespec) _IOC_ENCODE_TYPE_1(_IOTBASE_##typespec)
172 #define _IOTBASE_struct
173 #define _IOC_ENCODE_TYPE_1(typespec) _IOC_ENCODE_TYPE_2(typespec)
174 #define _IOC_ENCODE_TYPE_2(typespec) _IOT_##typespec
177 /* ioctls verbatim from 4.4 <sys/ioctl.h>. */
179 #define TIOCMODG _IOR('t', 3, int) /* get modem control state */
180 #define TIOCMODS _IOW('t', 4, int) /* set modem control state */
181 #define TIOCM_LE 0001 /* line enable */
182 #define TIOCM_DTR 0002 /* data terminal ready */
183 #define TIOCM_RTS 0004 /* request to send */
184 #define TIOCM_ST 0010 /* secondary transmit */
185 #define TIOCM_SR 0020 /* secondary receive */
186 #define TIOCM_CTS 0040 /* clear to send */
187 #define TIOCM_CAR 0100 /* carrier detect */
188 #define TIOCM_CD TIOCM_CAR
189 #define TIOCM_RNG 0200 /* ring */
190 #define TIOCM_RI TIOCM_RNG
191 #define TIOCM_DSR 0400 /* data set ready */
192 /* 8-10 compat */
193 #define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */
194 #define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */
195 /* 15 unused */
196 #define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
197 /* 17-18 compat */
198 #define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */
199 #define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */
200 #define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */
201 #define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */
202 #define TIOCGETD _IOR('t', 26, int) /* get line discipline */
203 #define TIOCSETD _IOW('t', 27, int) /* set line discipline */
204 /* 127-124 compat */
205 #define TIOCSBRK _IO('t', 123) /* set break bit */
206 #define TIOCCBRK _IO('t', 122) /* clear break bit */
207 #define TIOCSDTR _IO('t', 121) /* set data terminal ready */
208 #define TIOCCDTR _IO('t', 120) /* clear data terminal ready */
209 #define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
210 #define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
211 /* 117-116 compat */
212 #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
213 #define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */
214 #define TIOCNOTTY _IO('t', 113) /* void tty association */
215 #define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */
216 #define TIOCPKT_DATA 0x00 /* data packet */
217 #define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
218 #define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
219 #define TIOCPKT_STOP 0x04 /* stop output */
220 #define TIOCPKT_START 0x08 /* start output */
221 #define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
222 #define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
223 #define TIOCPKT_IOCTL 0x40 /* state change of pty driver */
224 #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
225 #define TIOCSTART _IO('t', 110) /* start output, like ^Q */
226 #define TIOCMSET _IOW('t', 109, int) /* set all modem bits */
227 #define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */
228 #define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */
229 #define TIOCMGET _IOR('t', 106, int) /* get all modem bits */
230 #define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */
231 #define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
232 #define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
233 #define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */
234 #define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */
235 #define TIOCCONS _IOW('t', 98, int) /* become virtual console */
236 #define TIOCSCTTY _IO('t', 97) /* become controlling tty */
237 #define TIOCEXT _IOW('t', 96, int) /* pty: external processing */
238 #define TIOCSIG _IO('t', 95) /* pty: generate signal */
239 #define TIOCDRAIN _IO('t', 94) /* wait till output drained */
241 #define TTYDISC 0 /* termios tty line discipline */
242 #define TABLDISC 3 /* tablet discipline */
243 #define SLIPDISC 4 /* serial IP discipline */
246 #define FIOCLEX _IO('f', 1) /* set close on exec on fd */
247 #define FIONCLEX _IO('f', 2) /* remove close on exec */
248 #define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
249 #define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
250 #define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */
251 #define FIOSETOWN _IOW('f', 124, int) /* set owner */
252 #define FIOGETOWN _IOR('f', 123, int) /* get owner */
254 /* socket i/o controls */
255 #define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
256 #define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
257 #define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
258 #define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
259 #define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
260 #define SIOCSPGRP _IOW('s', 8, int) /* set process group */
261 #define SIOCGPGRP _IOR('s', 9, int) /* get process group */
263 #define SIOCADDRT _IOW('r', 10, struct ortentry) /* add route */
264 #define SIOCDELRT _IOW('r', 11, struct ortentry) /* delete route */
266 #define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */
267 #define OSIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */
268 #define SIOCGIFADDR _IOWR('i',33, struct ifreq) /* get ifnet address */
269 #define SIOCGIFHWADDR _IOWR('i',39, struct ifreq) /* get hwaddress */
270 #define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */
271 #define OSIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */
272 #define SIOCGIFDSTADDR _IOWR('i',34, struct ifreq) /* get p-p address */
273 #define SIOCSIFFLAGS _IOW('i', 16, struct ifreq_short)/* set ifnet flags */
274 #define SIOCGIFFLAGS _IOWR('i',17, struct ifreq_short)/* get ifnet flags */
275 #define OSIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */
276 #define SIOCGIFBRDADDR _IOWR('i',35, struct ifreq) /* get broadcast addr */
277 #define SIOCSIFBRDADDR _IOW('i',19, struct ifreq) /* set broadcast addr */
278 #define OSIOCGIFCONF _IOWR('i',20, struct ifconf) /* get ifnet list */
279 #define SIOCGIFCONF _IOWR('i',36, struct ifconf) /* get ifnet list */
280 #define OSIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */
281 #define SIOCGIFNETMASK _IOWR('i',37, struct ifreq) /* get net addr mask */
282 #define SIOCSIFNETMASK _IOW('i',22, struct ifreq) /* set net addr mask */
283 #define SIOCGIFMETRIC _IOWR('i',23, struct ifreq_int) /* get IF metric */
284 #define SIOCSIFMETRIC _IOW('i',24, struct ifreq_int) /* set IF metric */
285 #define SIOCDIFADDR _IOW('i',25, struct ifreq) /* delete IF addr */
286 #define SIOCAIFADDR _IOW('i',26, struct ifaliasreq) /* add/chg IF alias */
288 #define SIOCSARP _IOW('i', 30, struct arpreq) /* set arp entry */
289 #define OSIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */
290 #define SIOCGARP _IOWR('i',38, struct arpreq) /* get arp entry */
291 #define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */
293 #define SIOCGIFMTU _IOWR('i', 51, struct ifreq_int)/* get IF mtu */
294 #define SIOCSIFMTU _IOW('i', 52, struct ifreq_int) /* set IF mtu */
296 #define SIOCGIFINDEX _IOWR('i', 90, struct ifreq_int)/* get IF index */
297 #define SIOCGIFNAME _IOWR('i', 91, struct ifreq_int)/* set IF name */
300 /* Compatibility with 4.3 BSD terminal driver.
301 From 4.4 <sys/ioctl_compat.h>. */
303 #ifdef USE_OLD_TTY
304 # undef TIOCGETD
305 # define TIOCGETD _IOR('t', 0, int) /* get line discipline */
306 # undef TIOCSETD
307 # define TIOCSETD _IOW('t', 1, int) /* set line discipline */
308 #else
309 # define OTIOCGETD _IOR('t', 0, int) /* get line discipline */
310 # define OTIOCSETD _IOW('t', 1, int) /* set line discipline */
311 #endif
312 #define TIOCHPCL _IO('t', 2) /* hang up on last close */
313 #define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
314 #define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */
315 #define TIOCSETN _IOW('t',10,struct sgttyb)/* as above, but no flushtty*/
316 #define TIOCSETC _IOW('t',17,struct tchars)/* set special characters */
317 #define TIOCGETC _IOR('t',18,struct tchars)/* get special characters */
318 #define TANDEM 0x00000001 /* send stopc on out q full */
319 #define CBREAK 0x00000002 /* half-cooked mode */
320 #define LCASE 0x00000004 /* simulate lower case */
321 #define ECHO 0x00000008 /* echo input */
322 #define CRMOD 0x00000010 /* map \r to \r\n on output */
323 #define RAW 0x00000020 /* no i/o processing */
324 #define ODDP 0x00000040 /* get/send odd parity */
325 #define EVENP 0x00000080 /* get/send even parity */
326 #define ANYP 0x000000c0 /* get any parity/send none */
327 #define NLDELAY 0x00000300 /* \n delay */
328 #define NL0 0x00000000
329 #define NL1 0x00000100 /* tty 37 */
330 #define NL2 0x00000200 /* vt05 */
331 #define NL3 0x00000300
332 #define TBDELAY 0x00000c00 /* horizontal tab delay */
333 #define TAB0 0x00000000
334 #define TAB1 0x00000400 /* tty 37 */
335 #define TAB2 0x00000800
336 #define XTABS 0x00000c00 /* expand tabs on output */
337 #define CRDELAY 0x00003000 /* \r delay */
338 #define CR0 0x00000000
339 #define CR1 0x00001000 /* tn 300 */
340 #define CR2 0x00002000 /* tty 37 */
341 #define CR3 0x00003000 /* concept 100 */
342 #define VTDELAY 0x00004000 /* vertical tab delay */
343 #define FF0 0x00000000
344 #define FF1 0x00004000 /* tty 37 */
345 #define BSDELAY 0x00008000 /* \b delay */
346 #define BS0 0x00000000
347 #define BS1 0x00008000
348 #define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
349 #define CRTBS 0x00010000 /* do backspacing for crt */
350 #define PRTERA 0x00020000 /* \ ... / erase */
351 #define CRTERA 0x00040000 /* " \b " to wipe out char */
352 #define TILDE 0x00080000 /* hazeltine tilde kludge */
353 #define MDMBUF 0x00100000 /*start/stop output on carrier*/
354 #define LITOUT 0x00200000 /* literal output */
355 #define TOSTOP 0x00400000 /*SIGSTOP on background output*/
356 #define FLUSHO 0x00800000 /* flush output to terminal */
357 #define NOHANG 0x01000000 /* (no-op) was no SIGHUP on carrier drop */
358 #define L001000 0x02000000
359 #define CRTKIL 0x04000000 /* kill line with " \b " */
360 #define PASS8 0x08000000
361 #define CTLECH 0x10000000 /* echo control chars as ^X */
362 #define PENDIN 0x20000000 /* tp->t_rawq needs reread */
363 #define DECCTQ 0x40000000 /* only ^Q starts after ^S */
364 #define NOFLSH 0x80000000 /* no output flush on signal */
365 #define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */
366 #define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */
367 #define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */
368 #define TIOCLGET _IOR('t', 124, int) /* get local modes */
369 #define LCRTBS (CRTBS>>16)
370 #define LPRTERA (PRTERA>>16)
371 #define LCRTERA (CRTERA>>16)
372 #define LTILDE (TILDE>>16)
373 #define LMDMBUF (MDMBUF>>16)
374 #define LLITOUT (LITOUT>>16)
375 #define LTOSTOP (TOSTOP>>16)
376 #define LFLUSHO (FLUSHO>>16)
377 #define LNOHANG (NOHANG>>16)
378 #define LCRTKIL (CRTKIL>>16)
379 #define LPASS8 (PASS8>>16)
380 #define LCTLECH (CTLECH>>16)
381 #define LPENDIN (PENDIN>>16)
382 #define LDECCTQ (DECCTQ>>16)
383 #define LNOFLSH (NOFLSH>>16)
384 #define TIOCSLTC _IOW('t',117,struct ltchars)/* set local special chars*/
385 #define TIOCGLTC _IOR('t',116,struct ltchars)/* get local special chars*/
386 #define OTIOCCONS _IO('t', 98) /* for hp300 -- sans int arg */
387 #define OTTYDISC 0
388 #define NETLDISC 1
389 #define NTTYDISC 2
391 /* From 4.4 <sys/ttydev.h>. */
392 #ifdef USE_OLD_TTY
393 # define B0 0
394 # define B50 1
395 # define B75 2
396 # define B110 3
397 # define B134 4
398 # define B150 5
399 # define B200 6
400 # define B300 7
401 # define B600 8
402 # define B1200 9
403 # define B1800 10
404 # define B2400 11
405 # define B4800 12
406 # define B9600 13
407 # define EXTA 14
408 # define EXTB 15
409 #endif /* USE_OLD_TTY */
411 #endif /* bits/ioctls.h */