xref: /freebsd/sys/compat/linux/linux_ioctl.h (revision f6a3b357e9be4c6423c85eff9a847163a0d307c8)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 1999 Marcel Moolenaar
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30 
31 #ifndef _LINUX_IOCTL_H_
32 #define	_LINUX_IOCTL_H_
33 
34 /*
35  * ioctl
36  *
37  * XXX comments in Linux' <asm-generic/ioctl.h> indicate these
38  * could be arch-dependant...
39  */
40 #define LINUX_IOC_VOID		0
41 #define LINUX_IOC_IN		0x40000000
42 #define LINUX_IOC_OUT		0x80000000
43 #define LINUX_IOC_INOUT		(LINUX_IOC_IN|LINUX_IOC_OUT)
44 
45 /*
46  * disk
47  */
48 #define	LINUX_BLKROSET		0x125d
49 #define	LINUX_BLKROGET		0x125e
50 #define	LINUX_BLKRRPART		0x125f
51 #define	LINUX_BLKGETSIZE	0x1260
52 #define	LINUX_BLKFLSBUF		0x1261
53 #define	LINUX_BLKRASET		0x1262
54 #define	LINUX_BLKRAGET		0x1263
55 #define	LINUX_BLKFRASET		0x1264
56 #define	LINUX_BLKFRAGET		0x1265
57 #define	LINUX_BLKSECTSET	0x1266
58 #define	LINUX_BLKSECTGET	0x1267
59 #define	LINUX_BLKSSZGET		0x1268
60 
61 #define LINUX_IOCTL_DISK_MIN    LINUX_BLKROSET
62 #define LINUX_IOCTL_DISK_MAX    LINUX_BLKSSZGET
63 
64 /*
65  * hdio
66  */
67 #define LINUX_HDIO_GET_GEO	0x0301
68 #define LINUX_HDIO_GET_IDENTITY	0x030D	/* not yet implemented */
69 #define LINUX_HDIO_GET_GEO_BIG	0x0330
70 
71 #define LINUX_IOCTL_HDIO_MIN	LINUX_HDIO_GET_GEO
72 #define LINUX_IOCTL_HDIO_MAX	LINUX_HDIO_GET_GEO_BIG
73 
74 /*
75  * cdrom
76  */
77 #define	LINUX_CDROMPAUSE		0x5301
78 #define	LINUX_CDROMRESUME		0x5302
79 #define	LINUX_CDROMPLAYMSF		0x5303
80 #define	LINUX_CDROMPLAYTRKIND		0x5304
81 #define	LINUX_CDROMREADTOCHDR		0x5305
82 #define	LINUX_CDROMREADTOCENTRY		0x5306
83 #define	LINUX_CDROMSTOP			0x5307
84 #define	LINUX_CDROMSTART		0x5308
85 #define	LINUX_CDROMEJECT		0x5309
86 #define	LINUX_CDROMVOLCTRL		0x530a
87 #define	LINUX_CDROMSUBCHNL		0x530b
88 #define	LINUX_CDROMREADMODE2		0x530c
89 #define	LINUX_CDROMREADMODE1		0x530d
90 #define	LINUX_CDROMREADAUDIO		0x530e
91 #define	LINUX_CDROMEJECT_SW		0x530f
92 #define	LINUX_CDROMMULTISESSION		0x5310
93 #define	LINUX_CDROM_GET_UPC		0x5311
94 #define	LINUX_CDROMRESET		0x5312
95 #define	LINUX_CDROMVOLREAD		0x5313
96 #define	LINUX_CDROMREADRAW		0x5314
97 #define	LINUX_CDROMREADCOOKED		0x5315
98 #define	LINUX_CDROMSEEK			0x5316
99 #define	LINUX_CDROMPLAYBLK		0x5317
100 #define	LINUX_CDROMREADALL		0x5318
101 #define	LINUX_CDROMCLOSETRAY		0x5319
102 #define	LINUX_CDROMLOADFROMSLOT		0x531a
103 #define	LINUX_CDROMGETSPINDOWN		0x531d
104 #define	LINUX_CDROMSETSPINDOWN		0x531e
105 #define	LINUX_CDROM_SET_OPTIONS		0x5320
106 #define	LINUX_CDROM_CLEAR_OPTIONS	0x5321
107 #define	LINUX_CDROM_SELECT_SPEED	0x5322
108 #define	LINUX_CDROM_SELECT_DISC		0x5323
109 #define	LINUX_CDROM_MEDIA_CHANGED	0x5325
110 #define	LINUX_CDROM_DRIVE_STATUS	0x5326
111 #define	LINUX_CDROM_DISC_STATUS		0x5327
112 #define	LINUX_CDROM_CHANGER_NSLOTS	0x5328
113 #define	LINUX_CDROM_LOCKDOOR		0x5329
114 #define	LINUX_CDROM_DEBUG		0x5330
115 #define	LINUX_CDROM_GET_CAPABILITY	0x5331
116 #define	LINUX_CDROMAUDIOBUFSIZ		0x5382
117 #define LINUX_SCSI_GET_IDLUN		0x5382
118 #define LINUX_SCSI_GET_BUS_NUMBER	0x5386
119 #define	LINUX_DVD_READ_STRUCT		0x5390
120 #define	LINUX_DVD_WRITE_STRUCT		0x5391
121 #define	LINUX_DVD_AUTH			0x5392
122 #define	LINUX_CDROM_SEND_PACKET		0x5393
123 #define	LINUX_CDROM_NEXT_WRITABLE	0x5394
124 #define	LINUX_CDROM_LAST_WRITTEN	0x5395
125 
126 #define	LINUX_IOCTL_CDROM_MIN	LINUX_CDROMPAUSE
127 #define	LINUX_IOCTL_CDROM_MAX	LINUX_CDROM_LAST_WRITTEN
128 
129 #define	LINUX_CDROM_LBA		0x01
130 #define	LINUX_CDROM_MSF		0x02
131 
132 #define	LINUX_DVD_LU_SEND_AGID		0
133 #define	LINUX_DVD_HOST_SEND_CHALLENGE	1
134 #define	LINUX_DVD_LU_SEND_KEY1		2
135 #define	LINUX_DVD_LU_SEND_CHALLENGE	3
136 #define	LINUX_DVD_HOST_SEND_KEY2	4
137 #define	LINUX_DVD_AUTH_ESTABLISHED	5
138 #define	LINUX_DVD_AUTH_FAILURE		6
139 #define	LINUX_DVD_LU_SEND_TITLE_KEY	7
140 #define	LINUX_DVD_LU_SEND_ASF		8
141 #define	LINUX_DVD_INVALIDATE_AGID	9
142 #define	LINUX_DVD_LU_SEND_RPC_STATE	10
143 #define	LINUX_DVD_HOST_SEND_RPC_STATE	11
144 
145 /*
146  * SG
147  */
148 #define	LINUX_SG_SET_TIMEOUT		0x2201
149 #define	LINUX_SG_GET_TIMEOUT		0x2202
150 #define	LINUX_SG_EMULATED_HOST		0x2203
151 #define	LINUX_SG_SET_TRANSFORM		0x2204
152 #define	LINUX_SG_GET_TRANSFORM		0x2205
153 #define	LINUX_SG_GET_COMMAND_Q		0x2270
154 #define	LINUX_SG_SET_COMMAND_Q		0x2271
155 #define	LINUX_SG_SET_RESERVED_SIZE	0x2275
156 #define	LINUX_SG_GET_RESERVED_SIZE	0x2272
157 #define	LINUX_SG_GET_SCSI_ID		0x2276
158 #define	LINUX_SG_SET_FORCE_LOW_DMA	0x2279
159 #define	LINUX_SG_GET_LOW_DMA		0x227a
160 #define	LINUX_SG_SET_FORCE_PACK_ID	0x227b
161 #define	LINUX_SG_GET_PACK_ID		0x227c
162 #define	LINUX_SG_GET_NUM_WAITING	0x227d
163 #define	LINUX_SG_SET_DEBUG		0x227e
164 #define	LINUX_SG_GET_SG_TABLESIZE	0x227f
165 #define	LINUX_SG_GET_VERSION_NUM	0x2282
166 #define	LINUX_SG_NEXT_CMD_LEN		0x2283
167 #define	LINUX_SG_SCSI_RESET		0x2284
168 #define	LINUX_SG_IO			0x2285
169 #define	LINUX_SG_GET_REQUEST_TABLE	0x2286
170 #define	LINUX_SG_SET_KEEP_ORPHAN	0x2287
171 #define	LINUX_SG_GET_KEEP_ORPHAN	0x2288
172 #define	LINUX_SG_GET_ACCESS_COUNT	0x2289
173 
174 #define	LINUX_IOCTL_SG_MIN	0x2200
175 #define	LINUX_IOCTL_SG_MAX	0x22ff
176 
177 /*
178  * VFAT
179  */
180 #define	LINUX_VFAT_READDIR_BOTH	0x7201
181 
182 #define	LINUX_IOCTL_VFAT_MIN	LINUX_VFAT_READDIR_BOTH
183 #define	LINUX_IOCTL_VFAT_MAX	LINUX_VFAT_READDIR_BOTH
184 
185 /*
186  * console
187  */
188 #define	LINUX_KIOCSOUND		0x4B2F
189 #define	LINUX_KDMKTONE		0x4B30
190 #define	LINUX_KDGETLED		0x4B31
191 #define	LINUX_KDSETLED		0x4B32
192 #define	LINUX_KDSETMODE		0x4B3A
193 #define	LINUX_KDGETMODE		0x4B3B
194 #define	LINUX_KDGKBMODE		0x4B44
195 #define	LINUX_KDSKBMODE		0x4B45
196 #define	LINUX_VT_OPENQRY	0x5600
197 #define	LINUX_VT_GETMODE	0x5601
198 #define	LINUX_VT_SETMODE	0x5602
199 #define	LINUX_VT_GETSTATE	0x5603
200 #define	LINUX_VT_RELDISP	0x5605
201 #define	LINUX_VT_ACTIVATE	0x5606
202 #define	LINUX_VT_WAITACTIVE	0x5607
203 
204 #define	LINUX_IOCTL_CONSOLE_MIN	LINUX_KIOCSOUND
205 #define	LINUX_IOCTL_CONSOLE_MAX	LINUX_VT_WAITACTIVE
206 
207 #define	LINUX_LED_SCR		0x01
208 #define	LINUX_LED_NUM		0x02
209 #define	LINUX_LED_CAP		0x04
210 
211 #define	LINUX_KD_TEXT		0x0
212 #define	LINUX_KD_GRAPHICS	0x1
213 #define	LINUX_KD_TEXT0		0x2
214 #define	LINUX_KD_TEXT1		0x3
215 
216 #define	LINUX_KBD_RAW		0
217 #define	LINUX_KBD_XLATE		1
218 #define	LINUX_KBD_MEDIUMRAW	2
219 
220 /*
221  * socket
222  */
223 #define	LINUX_FIOSETOWN		0x8901
224 #define	LINUX_SIOCSPGRP		0x8902
225 #define	LINUX_FIOGETOWN		0x8903
226 #define	LINUX_SIOCGPGRP		0x8904
227 #define	LINUX_SIOCATMARK	0x8905
228 #define	LINUX_SIOCGSTAMP	0x8906
229 #define	LINUX_SIOCGIFNAME	0x8910
230 #define	LINUX_SIOCGIFCONF	0x8912
231 #define	LINUX_SIOCGIFFLAGS	0x8913
232 #define	LINUX_SIOCGIFADDR	0x8915
233 #define	LINUX_SIOCSIFADDR	0x8916
234 #define	LINUX_SIOCGIFDSTADDR	0x8917
235 #define	LINUX_SIOCGIFBRDADDR	0x8919
236 #define	LINUX_SIOCGIFNETMASK	0x891b
237 #define	LINUX_SIOCSIFNETMASK	0x891c
238 #define	LINUX_SIOCGIFMTU	0x8921
239 #define	LINUX_SIOCSIFMTU	0x8922
240 #define	LINUX_SIOCSIFNAME	0x8923
241 #define	LINUX_SIOCSIFHWADDR	0x8924
242 #define	LINUX_SIOCGIFHWADDR	0x8927
243 #define	LINUX_SIOCADDMULTI	0x8931
244 #define	LINUX_SIOCDELMULTI	0x8932
245 #define	LINUX_SIOCGIFINDEX	0x8933
246 #define	LINUX_SIOGIFINDEX	LINUX_SIOCGIFINDEX
247 #define	LINUX_SIOCGIFCOUNT	0x8938
248 
249 #define	LINUX_IOCTL_SOCKET_MIN	LINUX_FIOSETOWN
250 #define	LINUX_IOCTL_SOCKET_MAX	LINUX_SIOCGIFCOUNT
251 
252 /*
253  * Device private ioctl calls
254  */
255 #define LINUX_SIOCDEVPRIVATE	0x89F0  /* to 89FF */
256 #define LINUX_IOCTL_PRIVATE_MIN	LINUX_SIOCDEVPRIVATE
257 #define LINUX_IOCTL_PRIVATE_MAX	LINUX_SIOCDEVPRIVATE+0xf
258 
259 /*
260  * sound
261  */
262 #define	LINUX_SOUND_MIXER_WRITE_VOLUME	0x4d00
263 #define	LINUX_SOUND_MIXER_WRITE_BASS	0x4d01
264 #define	LINUX_SOUND_MIXER_WRITE_TREBLE	0x4d02
265 #define	LINUX_SOUND_MIXER_WRITE_SYNTH	0x4d03
266 #define	LINUX_SOUND_MIXER_WRITE_PCM	0x4d04
267 #define	LINUX_SOUND_MIXER_WRITE_SPEAKER	0x4d05
268 #define	LINUX_SOUND_MIXER_WRITE_LINE	0x4d06
269 #define	LINUX_SOUND_MIXER_WRITE_MIC	0x4d07
270 #define	LINUX_SOUND_MIXER_WRITE_CD	0x4d08
271 #define	LINUX_SOUND_MIXER_WRITE_IMIX	0x4d09
272 #define	LINUX_SOUND_MIXER_WRITE_ALTPCM	0x4d0A
273 #define	LINUX_SOUND_MIXER_WRITE_RECLEV	0x4d0B
274 #define	LINUX_SOUND_MIXER_WRITE_IGAIN	0x4d0C
275 #define	LINUX_SOUND_MIXER_WRITE_OGAIN	0x4d0D
276 #define	LINUX_SOUND_MIXER_WRITE_LINE1	0x4d0E
277 #define	LINUX_SOUND_MIXER_WRITE_LINE2	0x4d0F
278 #define	LINUX_SOUND_MIXER_WRITE_LINE3	0x4d10
279 #define	LINUX_SOUND_MIXER_INFO		0x4d65
280 #define	LINUX_OSS_GETVERSION		0x4d76
281 #define	LINUX_SOUND_MIXER_READ_STEREODEVS	0x4dfb
282 #define	LINUX_SOUND_MIXER_READ_CAPS	0x4dfc
283 #define	LINUX_SOUND_MIXER_READ_RECMASK	0x4dfd
284 #define	LINUX_SOUND_MIXER_READ_DEVMASK	0x4dfe
285 #define	LINUX_SOUND_MIXER_WRITE_RECSRC	0x4dff
286 #define	LINUX_SNDCTL_DSP_RESET		0x5000
287 #define	LINUX_SNDCTL_DSP_SYNC		0x5001
288 #define	LINUX_SNDCTL_DSP_SPEED		0x5002
289 #define	LINUX_SNDCTL_DSP_STEREO		0x5003
290 #define	LINUX_SNDCTL_DSP_GETBLKSIZE	0x5004
291 #define	LINUX_SNDCTL_DSP_SETBLKSIZE	LINUX_SNDCTL_DSP_GETBLKSIZE
292 #define	LINUX_SNDCTL_DSP_SETFMT		0x5005
293 #define	LINUX_SOUND_PCM_WRITE_CHANNELS	0x5006
294 #define	LINUX_SOUND_PCM_WRITE_FILTER	0x5007
295 #define	LINUX_SNDCTL_DSP_POST		0x5008
296 #define	LINUX_SNDCTL_DSP_SUBDIVIDE	0x5009
297 #define	LINUX_SNDCTL_DSP_SETFRAGMENT	0x500A
298 #define	LINUX_SNDCTL_DSP_GETFMTS	0x500B
299 #define	LINUX_SNDCTL_DSP_GETOSPACE	0x500C
300 #define	LINUX_SNDCTL_DSP_GETISPACE	0x500D
301 #define	LINUX_SNDCTL_DSP_NONBLOCK	0x500E
302 #define	LINUX_SNDCTL_DSP_GETCAPS	0x500F
303 #define	LINUX_SNDCTL_DSP_GETTRIGGER	0x5010
304 #define	LINUX_SNDCTL_DSP_SETTRIGGER	LINUX_SNDCTL_DSP_GETTRIGGER
305 #define	LINUX_SNDCTL_DSP_GETIPTR	0x5011
306 #define	LINUX_SNDCTL_DSP_GETOPTR	0x5012
307 #define	LINUX_SNDCTL_DSP_SETDUPLEX	0x5016
308 #define	LINUX_SNDCTL_DSP_GETODELAY	0x5017
309 #define	LINUX_SNDCTL_SEQ_RESET		0x5100
310 #define	LINUX_SNDCTL_SEQ_SYNC		0x5101
311 #define	LINUX_SNDCTL_SYNTH_INFO		0x5102
312 #define	LINUX_SNDCTL_SEQ_CTRLRATE	0x5103
313 #define	LINUX_SNDCTL_SEQ_GETOUTCOUNT	0x5104
314 #define	LINUX_SNDCTL_SEQ_GETINCOUNT	0x5105
315 #define	LINUX_SNDCTL_SEQ_PERCMODE	0x5106
316 #define	LINUX_SNDCTL_FM_LOAD_INSTR	0x5107
317 #define	LINUX_SNDCTL_SEQ_TESTMIDI	0x5108
318 #define	LINUX_SNDCTL_SEQ_RESETSAMPLES	0x5109
319 #define	LINUX_SNDCTL_SEQ_NRSYNTHS	0x510A
320 #define	LINUX_SNDCTL_SEQ_NRMIDIS	0x510B
321 #define	LINUX_SNDCTL_MIDI_INFO		0x510C
322 #define	LINUX_SNDCTL_SEQ_TRESHOLD	0x510D
323 #define	LINUX_SNDCTL_SYNTH_MEMAVL	0x510E
324 
325 #define	LINUX_IOCTL_SOUND_MIN	LINUX_SOUND_MIXER_WRITE_VOLUME
326 #define	LINUX_IOCTL_SOUND_MAX	LINUX_SNDCTL_SYNTH_MEMAVL
327 
328 /*
329  * termio
330  */
331 #define	LINUX_TCGETS		0x5401
332 #define	LINUX_TCSETS		0x5402
333 #define	LINUX_TCSETSW		0x5403
334 #define	LINUX_TCSETSF		0x5404
335 #define	LINUX_TCGETA		0x5405
336 #define	LINUX_TCSETA		0x5406
337 #define	LINUX_TCSETAW		0x5407
338 #define	LINUX_TCSETAF		0x5408
339 #define	LINUX_TCSBRK		0x5409
340 #define	LINUX_TCXONC		0x540A
341 #define	LINUX_TCFLSH		0x540B
342 
343 #define	LINUX_TIOCEXCL		0x540C
344 #define	LINUX_TIOCNXCL		0x540D
345 #define	LINUX_TIOCSCTTY		0x540E
346 
347 #define	LINUX_TIOCGPGRP		0x540F
348 #define	LINUX_TIOCSPGRP		0x5410
349 
350 #define	LINUX_TIOCOUTQ		0x5411
351 #define	LINUX_TIOCSTI		0x5412
352 
353 #define	LINUX_TIOCGWINSZ	0x5413
354 #define	LINUX_TIOCSWINSZ	0x5414
355 
356 #define	LINUX_TIOCMGET		0x5415
357 #define	LINUX_TIOCMBIS		0x5416
358 #define	LINUX_TIOCMBIC		0x5417
359 #define	LINUX_TIOCMSET		0x5418
360 #define	LINUX_TIOCGSOFTCAR	0x5419
361 #define	LINUX_TIOCSSOFTCAR	0x541A
362 
363 #define	LINUX_FIONREAD		0x541B
364 
365 #define	LINUX_TIOCINQ		FIONREAD
366 #define	LINUX_TIOCLINUX		0x541C
367 #define	LINUX_TIOCCONS		0x541D
368 #define	LINUX_TIOCGSERIAL	0x541E
369 #define	LINUX_TIOCSSERIAL	0x541F
370 #define	LINUX_TIOCPKT		0x5420
371 
372 #define	LINUX_FIONBIO		0x5421
373 
374 #define	LINUX_TIOCNOTTY		0x5422
375 #define	LINUX_TIOCSETD		0x5423
376 #define	LINUX_TIOCGETD		0x5424
377 #define	LINUX_TCSBRKP		0x5425
378 #define	LINUX_TIOCTTYGSTRUCT	0x5426
379 
380 #define	LINUX_TIOCSBRK		0x5427
381 #define	LINUX_TIOCCBRK		0x5428
382 
383 #define LINUX_TIOCGPTN		0x5430
384 #define LINUX_TIOCSPTLCK	0x5431
385 
386 #define	LINUX_FIONCLEX		0x5450
387 #define	LINUX_FIOCLEX		0x5451
388 #define	LINUX_FIOASYNC		0x5452
389 
390 #define	LINUX_TIOCSERCONFIG	0x5453
391 #define	LINUX_TIOCSERGWILD	0x5454
392 #define	LINUX_TIOCSERSWILD	0x5455
393 #define	LINUX_TIOCGLCKTRMIOS	0x5456
394 #define	LINUX_TIOCSLCKTRMIOS	0x5457
395 
396 #define	LINUX_IOCTL_TERMIO_MIN	LINUX_TCGETS
397 #define	LINUX_IOCTL_TERMIO_MAX	LINUX_TIOCSLCKTRMIOS
398 
399 /* arguments for tcflow() and LINUX_TCXONC */
400 #define	LINUX_TCOOFF		0
401 #define	LINUX_TCOON		1
402 #define	LINUX_TCIOFF		2
403 #define	LINUX_TCION		3
404 
405 /* arguments for tcflush() and LINUX_TCFLSH */
406 #define	LINUX_TCIFLUSH		0
407 #define	LINUX_TCOFLUSH		1
408 #define	LINUX_TCIOFLUSH		2
409 
410 /* line disciplines */
411 #define	LINUX_N_TTY		0
412 #define	LINUX_N_SLIP		1
413 #define	LINUX_N_MOUSE		2
414 #define	LINUX_N_PPP		3
415 
416 /* Linux termio c_cc values */
417 #define	LINUX_VINTR		0
418 #define	LINUX_VQUIT		1
419 #define	LINUX_VERASE		2
420 #define	LINUX_VKILL		3
421 #define	LINUX_VEOF		4
422 #define	LINUX_VTIME		5
423 #define	LINUX_VMIN		6
424 #define	LINUX_VSWTC		7
425 #define	LINUX_NCC		8
426 
427 /* Linux termios c_cc values */
428 /* In addition to the termio values */
429 #define	LINUX_VSTART		8
430 #define	LINUX_VSTOP		9
431 #define	LINUX_VSUSP		10
432 #define	LINUX_VEOL		11
433 #define	LINUX_VREPRINT		12
434 #define	LINUX_VDISCARD		13
435 #define	LINUX_VWERASE		14
436 #define	LINUX_VLNEXT		15
437 #define	LINUX_VEOL2		16
438 #define	LINUX_NCCS		19
439 
440 #define	LINUX_POSIX_VDISABLE	'\0'
441 
442 /* Linux c_iflag masks */
443 #define	LINUX_IGNBRK		0x0000001
444 #define	LINUX_BRKINT		0x0000002
445 #define	LINUX_IGNPAR		0x0000004
446 #define	LINUX_PARMRK		0x0000008
447 #define	LINUX_INPCK		0x0000010
448 #define	LINUX_ISTRIP		0x0000020
449 #define	LINUX_INLCR		0x0000040
450 #define	LINUX_IGNCR		0x0000080
451 #define	LINUX_ICRNL		0x0000100
452 
453 #define	LINUX_IUCLC		0x0000200
454 #define	LINUX_IXON		0x0000400
455 #define	LINUX_IXANY		0x0000800
456 #define	LINUX_IXOFF		0x0001000
457 
458 #define	LINUX_IMAXBEL		0x0002000
459 
460 /* Linux c_oflag masks */
461 #define	LINUX_OPOST		0x0000001
462 
463 #define	LINUX_OLCUC		0x0000002
464 #define	LINUX_ONLCR		0x0000004
465 
466 #define	LINUX_OCRNL		0x0000008
467 #define	LINUX_ONOCR		0x0000010
468 #define	LINUX_ONLRET		0x0000020
469 #define	LINUX_OFILL		0x0000040
470 #define	LINUX_OFDEL		0x0000080
471 
472 #define	LINUX_NLDLY		0x0000100
473 #define	LINUX_NL0		0x0000000
474 #define	LINUX_NL1		0x0000100
475 #define	LINUX_CRDLY		0x0000600
476 #define	LINUX_CR0		0x0000000
477 #define	LINUX_CR1		0x0000200
478 #define	LINUX_CR2		0x0000400
479 #define	LINUX_CR3		0x0000600
480 #define	LINUX_TABDLY		0x0001800
481 #define	LINUX_TAB0		0x0000000
482 #define	LINUX_TAB1		0x0000800
483 #define	LINUX_TAB2		0x0001000
484 #define	LINUX_TAB3		0x0001800
485 #define	LINUX_XTABS		0x0001800
486 #define	LINUX_BSDLY		0x0002000
487 #define	LINUX_BS0		0x0000000
488 #define	LINUX_BS1		0x0002000
489 #define	LINUX_VTDLY		0x0004000
490 #define	LINUX_VT0		0x0000000
491 #define	LINUX_VT1		0x0004000
492 #define	LINUX_FFDLY		0x0008000
493 #define	LINUX_FF0		0x0000000
494 #define	LINUX_FF1		0x0008000
495 
496 #define	LINUX_CBAUD		0x0000100f
497 
498 #define	LINUX_B0		0x00000000
499 #define	LINUX_B50		0x00000001
500 #define	LINUX_B75		0x00000002
501 #define	LINUX_B110		0x00000003
502 #define	LINUX_B134		0x00000004
503 #define	LINUX_B150		0x00000005
504 #define	LINUX_B200		0x00000006
505 #define	LINUX_B300		0x00000007
506 #define	LINUX_B600		0x00000008
507 #define	LINUX_B1200		0x00000009
508 #define	LINUX_B1800		0x0000000a
509 #define	LINUX_B2400		0x0000000b
510 #define	LINUX_B4800		0x0000000c
511 #define	LINUX_B9600		0x0000000d
512 #define	LINUX_B19200		0x0000000e
513 #define	LINUX_B38400		0x0000000f
514 #define	LINUX_EXTA		LINUX_B19200
515 #define	LINUX_EXTB		LINUX_B38400
516 
517 #define	LINUX_CBAUDEX		0x00001000
518 #define	LINUX_B57600		0x00001001
519 #define	LINUX_B115200		0x00001002
520 
521 #define	LINUX_CSIZE		0x00000030
522 #define	LINUX_CS5		0x00000000
523 #define	LINUX_CS6		0x00000010
524 #define	LINUX_CS7		0x00000020
525 #define	LINUX_CS8		0x00000030
526 #define	LINUX_CSTOPB		0x00000040
527 #define	LINUX_CREAD		0x00000080
528 #define	LINUX_PARENB		0x00000100
529 #define	LINUX_PARODD		0x00000200
530 #define	LINUX_HUPCL		0x00000400
531 #define	LINUX_CLOCAL		0x00000800
532 
533 #define	LINUX_CRTSCTS		0x80000000
534 
535 /* Linux c_lflag masks */
536 #define	LINUX_ISIG		0x00000001
537 #define	LINUX_ICANON		0x00000002
538 #define	LINUX_XCASE		0x00000004
539 #define	LINUX_ECHO		0x00000008
540 #define	LINUX_ECHOE		0x00000010
541 #define	LINUX_ECHOK		0x00000020
542 #define	LINUX_ECHONL		0x00000040
543 #define	LINUX_NOFLSH		0x00000080
544 #define	LINUX_TOSTOP		0x00000100
545 #define	LINUX_ECHOCTL		0x00000200
546 #define	LINUX_ECHOPRT		0x00000400
547 #define	LINUX_ECHOKE		0x00000800
548 #define	LINUX_FLUSHO		0x00001000
549 #define	LINUX_PENDIN		0x00002000
550 #define	LINUX_IEXTEN		0x00008000
551 
552 /* serial_struct values for TIOC[GS]SERIAL ioctls */
553 #define	LINUX_ASYNC_CLOSING_WAIT_INF  0
554 #define	LINUX_ASYNC_CLOSING_WAIT_NONE 65535
555 
556 #define	LINUX_PORT_UNKNOWN	0
557 #define	LINUX_PORT_8250		1
558 #define	LINUX_PORT_16450	2
559 #define	LINUX_PORT_16550	3
560 #define	LINUX_PORT_16550A	4
561 #define	LINUX_PORT_CIRRUS	5
562 #define	LINUX_PORT_16650	6
563 
564 #define	LINUX_PORT_MAX		6
565 
566 #define	LINUX_ASYNC_HUP_NOTIFY		0x0001
567 #define	LINUX_ASYNC_FOURPORT		0x0002
568 #define	LINUX_ASYNC_SAK			0x0004
569 #define	LINUX_ASYNC_SPLIT_TERMIOS	0x0008
570 #define	LINUX_ASYNC_SPD_MASK		0x0030
571 #define	LINUX_ASYNC_SPD_HI		0x0010
572 #define	LINUX_ASYNC_SPD_VHI		0x0020
573 #define	LINUX_ASYNC_SPD_CUST		0x0030
574 #define	LINUX_ASYNC_SKIP_TEST		0x0040
575 #define	LINUX_ASYNC_AUTO_IRQ		0x0080
576 #define	LINUX_ASYNC_SESSION_LOCKOUT	0x0100
577 #define	LINUX_ASYNC_PGRP_LOCKOUT	0x0200
578 #define	LINUX_ASYNC_CALLOUT_NOHUP	0x0400
579 #define	LINUX_ASYNC_FLAGS		0x0FFF
580 
581 #define	LINUX_IOCTL_DRM_MIN	0x6400
582 #define	LINUX_IOCTL_DRM_MAX	0x64ff
583 
584 /*
585  * video
586  */
587 #define LINUX_VIDIOCGCAP		0x7601
588 #define LINUX_VIDIOCGCHAN		0x7602
589 #define LINUX_VIDIOCSCHAN		0x7603
590 #define LINUX_VIDIOCGTUNER		0x7604
591 #define LINUX_VIDIOCSTUNER		0x7605
592 #define LINUX_VIDIOCGPICT		0x7606
593 #define LINUX_VIDIOCSPICT		0x7607
594 #define LINUX_VIDIOCCAPTURE		0x7608
595 #define LINUX_VIDIOCGWIN		0x7609
596 #define LINUX_VIDIOCSWIN		0x760a
597 #define LINUX_VIDIOCGFBUF		0x760b
598 #define LINUX_VIDIOCSFBUF		0x760c
599 #define LINUX_VIDIOCKEY			0x760d
600 #define LINUX_VIDIOCGFREQ		0x760e
601 #define LINUX_VIDIOCSFREQ		0x760f
602 #define LINUX_VIDIOCGAUDIO		0x7610
603 #define LINUX_VIDIOCSAUDIO		0x7611
604 #define LINUX_VIDIOCSYNC		0x7623
605 #define LINUX_VIDIOCMCAPTURE		0x7613
606 #define LINUX_VIDIOCGMBUF		0x7614
607 #define LINUX_VIDIOCGUNIT		0x7615
608 #define LINUX_VIDIOCGCAPTURE		0x7616
609 #define LINUX_VIDIOCSCAPTURE		0x7617
610 #define LINUX_VIDIOCSPLAYMODE		0x7618
611 #define LINUX_VIDIOCSWRITEMODE		0x7619
612 #define LINUX_VIDIOCGPLAYINFO		0x761a
613 #define LINUX_VIDIOCSMICROCODE		0x761b
614 #define LINUX_VIDIOCGVBIFMT		0x761c
615 #define LINUX_VIDIOCSVBIFMT		0x761d
616 
617 #define LINUX_IOCTL_VIDEO_MIN	LINUX_VIDIOCGCAP
618 #define LINUX_IOCTL_VIDEO_MAX	LINUX_VIDIOCSVBIFMT
619 
620 /* videodev2 aka V4L2 */
621 
622 #define LINUX_VIDIOC_QUERYCAP			0x5600 /* 0x80685600 */
623 #define LINUX_VIDIOC_RESERVED			0x5601 /* 0x00005601 */
624 #define LINUX_VIDIOC_ENUM_FMT			0x5602 /* 0xc0405602 */
625 #define LINUX_VIDIOC_G_FMT			0x5604 /* 0xc0cc5604 */
626 #define LINUX_VIDIOC_S_FMT			0x5605 /* 0xc0cc5605 */
627 #define LINUX_VIDIOC_REQBUFS			0x5608 /* 0xc0145608 */
628 #define LINUX_VIDIOC_QUERYBUF			0x5609 /* 0xc0445609 */
629 #define LINUX_VIDIOC_G_FBUF			0x560a /* 0x802c560a */
630 #define LINUX_VIDIOC_S_FBUF			0x560b /* 0x402c560b */
631 #define LINUX_VIDIOC_OVERLAY			0x560e /* 0x4004560e */
632 #define LINUX_VIDIOC_QBUF			0x560f /* 0xc044560f */
633 #define LINUX_VIDIOC_DQBUF			0x5611 /* 0xc0445611 */
634 #define LINUX_VIDIOC_STREAMON			0x5612 /* 0x40045612 */
635 #define LINUX_VIDIOC_STREAMOFF			0x5613 /* 0x40045613 */
636 #define LINUX_VIDIOC_G_PARM			0x5615 /* 0xc0cc5615 */
637 #define LINUX_VIDIOC_S_PARM			0x5616 /* 0xc0cc5616 */
638 #define LINUX_VIDIOC_G_STD			0x5617 /* 0x80085617 */
639 #define LINUX_VIDIOC_S_STD			0x5618 /* 0x40085618 */
640 #define LINUX_VIDIOC_ENUMSTD			0x5619 /* 0xc0405619 */
641 #define LINUX_VIDIOC_ENUMINPUT			0x561a /* 0xc04c561a */
642 #define LINUX_VIDIOC_G_CTRL			0x561b /* 0xc008561b */
643 #define LINUX_VIDIOC_S_CTRL			0x561c /* 0xc008561c */
644 #define LINUX_VIDIOC_G_TUNER			0x561d /* 0xc054561d */
645 #define LINUX_VIDIOC_S_TUNER			0x561e /* 0x4054561e */
646 #define LINUX_VIDIOC_G_AUDIO			0x5621 /* 0x80345621 */
647 #define LINUX_VIDIOC_S_AUDIO			0x5622 /* 0x40345622 */
648 #define LINUX_VIDIOC_QUERYCTRL			0x5624 /* 0xc0445624 */
649 #define LINUX_VIDIOC_QUERYMENU			0x5625 /* 0xc02c5625 */
650 #define LINUX_VIDIOC_G_INPUT			0x5626 /* 0x80045626 */
651 #define LINUX_VIDIOC_S_INPUT			0x5627 /* 0xc0045627 */
652 #define LINUX_VIDIOC_G_OUTPUT			0x562e /* 0x8004562e */
653 #define LINUX_VIDIOC_S_OUTPUT			0x562f /* 0xc004562f */
654 #define LINUX_VIDIOC_ENUMOUTPUT			0x5630 /* 0xc0485630 */
655 #define LINUX_VIDIOC_G_AUDOUT			0x5631 /* 0x80345631 */
656 #define LINUX_VIDIOC_S_AUDOUT			0x5632 /* 0x40345632 */
657 #define LINUX_VIDIOC_G_MODULATOR		0x5636 /* 0xc0445636 */
658 #define LINUX_VIDIOC_S_MODULATOR		0x5637 /* 0x40445637 */
659 #define LINUX_VIDIOC_G_FREQUENCY		0x5638 /* 0xc02c5638 */
660 #define LINUX_VIDIOC_S_FREQUENCY		0x5639 /* 0x402c5639 */
661 #define LINUX_VIDIOC_CROPCAP			0x563a /* 0xc02c563a */
662 #define LINUX_VIDIOC_G_CROP			0x563b /* 0xc014563b */
663 #define LINUX_VIDIOC_S_CROP			0x563c /* 0x4014563c */
664 #define LINUX_VIDIOC_G_JPEGCOMP			0x563d /* 0x808c563d */
665 #define LINUX_VIDIOC_S_JPEGCOMP			0x563e /* 0x408c563e */
666 #define LINUX_VIDIOC_QUERYSTD			0x563f /* 0x8008563f */
667 #define LINUX_VIDIOC_TRY_FMT			0x5640 /* 0xc0cc5640 */
668 #define LINUX_VIDIOC_ENUMAUDIO			0x5641 /* 0xc0345641 */
669 #define LINUX_VIDIOC_ENUMAUDOUT			0x5642 /* 0xc0345642 */
670 #define LINUX_VIDIOC_G_PRIORITY			0x5643 /* 0x80045643 */
671 #define LINUX_VIDIOC_S_PRIORITY			0x5644 /* 0x40045644 */
672 #define LINUX_VIDIOC_G_SLICED_VBI_CAP		0x5645 /* 0xc0745645 */
673 #define LINUX_VIDIOC_LOG_STATUS			0x5646 /* 0x00005646 */
674 #define LINUX_VIDIOC_G_EXT_CTRLS		0x5647 /* 0xc0185647 */
675 #define LINUX_VIDIOC_S_EXT_CTRLS		0x5648 /* 0xc0185648 */
676 #define LINUX_VIDIOC_TRY_EXT_CTRLS		0x5649 /* 0xc0185649 */
677 #define LINUX_VIDIOC_ENUM_FRAMESIZES		0x564a /* 0xc02c564a */
678 #define LINUX_VIDIOC_ENUM_FRAMEINTERVALS	0x564b /* 0xc034564b */
679 #define LINUX_VIDIOC_G_ENC_INDEX		0x564c /* 0x8818564c */
680 #define LINUX_VIDIOC_ENCODER_CMD		0x564d /* 0xc028564d */
681 #define LINUX_VIDIOC_TRY_ENCODER_CMD		0x564e /* 0xc028564e */
682 #define LINUX_VIDIOC_DBG_S_REGISTER		0x564f /* 0x4038564f */
683 #define LINUX_VIDIOC_DBG_G_REGISTER		0x5650 /* 0xc0385650 */
684 #define LINUX_VIDIOC_DBG_G_CHIP_IDENT		0x5651 /* 0xc02c5651 */
685 #define LINUX_VIDIOC_S_HW_FREQ_SEEK		0x5652 /* 0x40305652 */
686 #define LINUX_VIDIOC_ENUM_DV_PRESETS		0x5653 /* 0xc0405653 */
687 #define LINUX_VIDIOC_S_DV_PRESET		0x5654 /* 0xc0145654 */
688 #define LINUX_VIDIOC_G_DV_PRESET		0x5655 /* 0xc0145655 */
689 #define LINUX_VIDIOC_QUERY_DV_PRESET		0x5656 /* 0x80145656 */
690 #define LINUX_VIDIOC_S_DV_TIMINGS		0x5657 /* 0xc0845657 */
691 #define LINUX_VIDIOC_G_DV_TIMINGS		0x5658 /* 0xc0845658 */
692 #define LINUX_VIDIOC_DQEVENT			0x5659 /* 0x80785659 */
693 #define LINUX_VIDIOC_SUBSCRIBE_EVENT		0x565a /* 0x4020565a */
694 #define LINUX_VIDIOC_UNSUBSCRIBE_EVENT		0x565b /* 0x4020565b */
695 
696 #define LINUX_VIDIOC_OVERLAY_OLD		0x560e /* 0xc004560e */
697 #define LINUX_VIDIOC_S_PARM_OLD			0x5616 /* 0x40cc5616 */
698 #define LINUX_VIDIOC_S_CTRL_OLD			0x561c /* 0x4008561c */
699 #define LINUX_VIDIOC_G_AUDIO_OLD		0x5621 /* 0xc0345621 */
700 #define LINUX_VIDIOC_G_AUDOUT_OLD		0x5631 /* 0xc0345631 */
701 #define LINUX_VIDIOC_CROPCAP_OLD		0x563a /* 0x802c563a */
702 
703 #define LINUX_IOCTL_VIDEO2_MIN	LINUX_VIDIOC_QUERYCAP
704 #define LINUX_IOCTL_VIDEO2_MAX	LINUX_VIDIOC_UNSUBSCRIBE_EVENT
705 
706 /*
707  * Our libusb(8) calls emulated within linux(4).
708  */
709 #define	FBSD_LUSB_DEVICEENUMERATE	0xffff
710 #define	FBSD_LUSB_DEV_QUIRK_ADD		0xfffe
711 #define	FBSD_LUSB_DEV_QUIRK_GET		0xfffd
712 #define	FBSD_LUSB_DEV_QUIRK_REMOVE	0xfffc
713 #define	FBSD_LUSB_DO_REQUEST		0xfffb
714 #define	FBSD_LUSB_FS_CLEAR_STALL_SYNC	0xfffa
715 #define	FBSD_LUSB_FS_CLOSE		0xfff9
716 #define	FBSD_LUSB_FS_COMPLETE		0xfff8
717 #define	FBSD_LUSB_FS_INIT		0xfff7
718 #define	FBSD_LUSB_FS_OPEN		0xfff6
719 #define	FBSD_LUSB_FS_START		0xfff5
720 #define	FBSD_LUSB_FS_STOP		0xfff4
721 #define	FBSD_LUSB_FS_UNINIT		0xfff3
722 #define	FBSD_LUSB_GET_CONFIG		0xfff2
723 #define	FBSD_LUSB_GET_DEVICEINFO	0xfff1
724 #define	FBSD_LUSB_GET_DEVICE_DESC	0xfff0
725 #define	FBSD_LUSB_GET_FULL_DESC		0xffef
726 #define	FBSD_LUSB_GET_IFACE_DRIVER	0xffee
727 #define	FBSD_LUSB_GET_PLUGTIME		0xffed
728 #define	FBSD_LUSB_GET_POWER_MODE	0xffec
729 #define	FBSD_LUSB_GET_REPORT_DESC	0xffeb
730 #define	FBSD_LUSB_GET_REPORT_ID		0xffea
731 #define	FBSD_LUSB_GET_TEMPLATE		0xffe9
732 #define	FBSD_LUSB_IFACE_DRIVER_ACTIVE	0xffe8
733 #define	FBSD_LUSB_IFACE_DRIVER_DETACH	0xffe7
734 #define	FBSD_LUSB_QUIRK_NAME_GET	0xffe6
735 #define	FBSD_LUSB_READ_DIR		0xffe5
736 #define	FBSD_LUSB_SET_ALTINTERFACE	0xffe4
737 #define	FBSD_LUSB_SET_CONFIG		0xffe3
738 #define	FBSD_LUSB_SET_IMMED		0xffe2
739 #define	FBSD_LUSB_SET_POWER_MODE	0xffe1
740 #define	FBSD_LUSB_SET_TEMPLATE		0xffe0
741 #define	FBSD_LUSB_FS_OPEN_STREAM	0xffdf
742 #define	FBSD_LUSB_GET_DEV_PORT_PATH	0xffde
743 #define	FBSD_LUSB_GET_POWER_USAGE	0xffdd
744 
745 #define	FBSD_LUSB_MAX			0xffff
746 #define	FBSD_LUSB_MIN			0xffdd
747 
748 /*
749  * Linux btrfs clone operation
750  */
751 #define LINUX_BTRFS_IOC_CLONE		0x9409 /* 0x40049409 */
752 #define LINUX_FS_IOC_FIEMAP		0x660b
753 
754 /*
755  * Linux evdev ioctl min and max
756  */
757 #define LINUX_IOCTL_EVDEV_MIN		0x4500
758 #define LINUX_IOCTL_EVDEV_MAX		0x45ff
759 #define LINUX_IOCTL_EVDEV_CLK		LINUX_CLOCK_REALTIME |	\
760 	    LINUX_CLOCK_MONOTONIC |LINUX_CLOCK_BOOTTIME
761 /*
762  * Pluggable ioctl handlers
763  */
764 struct linux_ioctl_args;
765 struct thread;
766 
767 typedef int linux_ioctl_function_t(struct thread *, struct linux_ioctl_args *);
768 
769 struct linux_ioctl_handler {
770 	linux_ioctl_function_t *func;
771 	int	low, high;
772 };
773 
774 struct linux_ioctl_handler_element
775 {
776 	TAILQ_ENTRY(linux_ioctl_handler_element) list;
777 	int	(*func)(struct thread *, struct linux_ioctl_args *);
778 	int	low, high, span;
779 };
780 
781 int	linux_ioctl_register_handler(struct linux_ioctl_handler *h);
782 int	linux_ioctl_unregister_handler(struct linux_ioctl_handler *h);
783 #ifdef COMPAT_LINUX32
784 int	linux32_ioctl_register_handler(struct linux_ioctl_handler *h);
785 int	linux32_ioctl_unregister_handler(struct linux_ioctl_handler *h);
786 #endif
787 
788 #endif /* !_LINUX_IOCTL_H_ */
789